| File: | var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-63ae0a99caba1c8a/out/composite_FAST_PATH_TEXTURE_RECT.h |
| Warning: | line 70, column 16 Value stored to 'texture_size' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | struct composite_FAST_PATH_TEXTURE_RECT_common { |
| 2 | struct Samplers { |
| 3 | sampler2DRect_impl sColor0_impl; |
| 4 | int sColor0_slot; |
| 5 | bool set_slot(int index, int value) { |
| 6 | switch (index) { |
| 7 | case 2: |
| 8 | sColor0_slot = value; |
| 9 | return true; |
| 10 | } |
| 11 | return false; |
| 12 | } |
| 13 | } samplers; |
| 14 | struct AttribLocations { |
| 15 | int aPosition = NULL_ATTRIB16; |
| 16 | int aDeviceRect = NULL_ATTRIB16; |
| 17 | int aDeviceClipRect = NULL_ATTRIB16; |
| 18 | int aParams = NULL_ATTRIB16; |
| 19 | int aFlip = NULL_ATTRIB16; |
| 20 | int aUvRect0 = NULL_ATTRIB16; |
| 21 | void bind_loc(const char* name, int index) { |
| 22 | if (strcmp("aPosition", name) == 0) { aPosition = index; return; } |
| 23 | if (strcmp("aDeviceRect", name) == 0) { aDeviceRect = index; return; } |
| 24 | if (strcmp("aDeviceClipRect", name) == 0) { aDeviceClipRect = index; return; } |
| 25 | if (strcmp("aParams", name) == 0) { aParams = index; return; } |
| 26 | if (strcmp("aFlip", name) == 0) { aFlip = index; return; } |
| 27 | if (strcmp("aUvRect0", name) == 0) { aUvRect0 = index; return; } |
| 28 | } |
| 29 | int get_loc(const char* name) const { |
| 30 | if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; } |
| 31 | if (strcmp("aDeviceRect", name) == 0) { return aDeviceRect != NULL_ATTRIB16 ? aDeviceRect : -1; } |
| 32 | if (strcmp("aDeviceClipRect", name) == 0) { return aDeviceClipRect != NULL_ATTRIB16 ? aDeviceClipRect : -1; } |
| 33 | if (strcmp("aParams", name) == 0) { return aParams != NULL_ATTRIB16 ? aParams : -1; } |
| 34 | if (strcmp("aFlip", name) == 0) { return aFlip != NULL_ATTRIB16 ? aFlip : -1; } |
| 35 | if (strcmp("aUvRect0", name) == 0) { return aUvRect0 != NULL_ATTRIB16 ? aUvRect0 : -1; } |
| 36 | return -1; |
| 37 | } |
| 38 | } attrib_locations; |
| 39 | sampler2DRect sColor0; |
| 40 | mat4_scalar uTransform; |
| 41 | void bind_textures() { |
| 42 | sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot); |
| 43 | } |
| 44 | }; |
| 45 | struct composite_FAST_PATH_TEXTURE_RECT_vert : VertexShaderImpl, composite_FAST_PATH_TEXTURE_RECT_common { |
| 46 | private: |
| 47 | typedef composite_FAST_PATH_TEXTURE_RECT_vert Self; |
| 48 | // mat4_scalar uTransform; |
| 49 | vec2 aPosition; |
| 50 | // sampler2DRect sColor0; |
| 51 | // sampler2DRect sColor1; |
| 52 | // sampler2DRect sColor2; |
| 53 | vec2 vUv; |
| 54 | vec4_scalar aDeviceRect; |
| 55 | vec4_scalar aDeviceClipRect; |
| 56 | vec4_scalar aColor; |
| 57 | vec4_scalar aParams; |
| 58 | vec2_scalar aFlip; |
| 59 | vec4_scalar aUvRect0; |
| 60 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
| 61 | vec4_scalar device_rect = mix((aDeviceRect).sel(X,Y,Z,W), (aDeviceRect).sel(Z,W,X,Y), (aFlip).sel(X,Y,X,Y)); |
| 62 | vec2 world_pos = mix((device_rect).sel(X,Y), (device_rect).sel(Z,W), (aPosition).sel(X,Y)); |
| 63 | vec2 clipped_world_pos = clamp(world_pos, (aDeviceClipRect).sel(X,Y), (aDeviceClipRect).sel(Z,W)); |
| 64 | vec2 uv = ((clipped_world_pos)-((device_rect).sel(X,Y)))/(((device_rect).sel(Z,W))-((device_rect).sel(X,Y))); |
| 65 | uv = mix((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W), uv); |
| 66 | vec4_scalar uvBounds = make_vec4(min((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W)), max((aUvRect0).sel(X,Y), (aUvRect0).sel(Z,W))); |
| 67 | int32_t rescale_uv = make_int((aParams).y); |
| 68 | if ((rescale_uv)==(1)) { |
| 69 | { |
| 70 | vec2_scalar texture_size = make_vec2(1.f, 1.f); |
Value stored to 'texture_size' during its initialization is never read | |
| 71 | uvBounds += make_vec4(0.5f, 0.5f, -(0.5f), -(0.5f)); |
| 72 | } |
| 73 | } |
| 74 | vUv = uv; |
| 75 | gl_Position = (uTransform)*(make_vec4(clipped_world_pos, 0.f, 1.f)); |
| 76 | } |
| 77 | static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) { |
| 78 | Self* self = (Self*)impl; |
| 79 | if (self->samplers.set_slot(index, value)) return; |
| 80 | switch (index) { |
| 81 | case 2: |
| 82 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
| 83 | break; |
| 84 | case 1: |
| 85 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
| 86 | break; |
| 87 | } |
| 88 | } |
| 89 | static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) { |
| 90 | Self* self = (Self*)impl; |
| 91 | switch (index) { |
| 92 | case 2: |
| 93 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
| 94 | break; |
| 95 | case 1: |
| 96 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) { |
| 101 | Self* self = (Self*)impl; |
| 102 | switch (index) { |
| 103 | case 2: |
| 104 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
| 105 | break; |
| 106 | case 1: |
| 107 | self->uTransform = mat4_scalar::load_from_ptr(value); |
| 108 | break; |
| 109 | } |
| 110 | } |
| 111 | static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl; |
| 112 | load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count); |
| 113 | load_flat_attrib(self->aDeviceRect, attribs[self->attrib_locations.aDeviceRect], start, instance, count); |
| 114 | load_flat_attrib(self->aDeviceClipRect, attribs[self->attrib_locations.aDeviceClipRect], start, instance, count); |
| 115 | load_flat_attrib(self->aParams, attribs[self->attrib_locations.aParams], start, instance, count); |
| 116 | load_flat_attrib(self->aFlip, attribs[self->attrib_locations.aFlip], start, instance, count); |
| 117 | load_flat_attrib(self->aUvRect0, attribs[self->attrib_locations.aUvRect0], start, instance, count); |
| 118 | } |
| 119 | public: |
| 120 | struct InterpOutputs { |
| 121 | vec2_scalar vUv; |
| 122 | }; |
| 123 | private: |
| 124 | ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) { |
| 125 | for(int n = 0; n < 4; n++) { |
| 126 | auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr); |
| 127 | dest->vUv = get_nth(vUv, n); |
| 128 | dest_ptr += stride; |
| 129 | } |
| 130 | } |
| 131 | static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) { |
| 132 | Self* self = (Self*)impl; |
| 133 | self->main(); |
| 134 | self->store_interp_outputs(interps, interp_stride); |
| 135 | } |
| 136 | static void init_batch(VertexShaderImpl* impl) { |
| 137 | Self* self = (Self*)impl; self->bind_textures(); } |
| 138 | public: |
| 139 | composite_FAST_PATH_TEXTURE_RECT_vert() { |
| 140 | set_uniform_1i_func = &set_uniform_1i; |
| 141 | set_uniform_4fv_func = &set_uniform_4fv; |
| 142 | set_uniform_matrix4fv_func = &set_uniform_matrix4fv; |
| 143 | init_batch_func = &init_batch; |
| 144 | load_attribs_func = &load_attribs; |
| 145 | run_primitive_func = &run; |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | |
| 150 | struct composite_FAST_PATH_TEXTURE_RECT_frag : FragmentShaderImpl, composite_FAST_PATH_TEXTURE_RECT_vert { |
| 151 | private: |
| 152 | typedef composite_FAST_PATH_TEXTURE_RECT_frag Self; |
| 153 | #define oFragColorgl_FragColor gl_FragColor |
| 154 | // vec4 oFragColor; |
| 155 | // sampler2DRect sColor0; |
| 156 | // sampler2DRect sColor1; |
| 157 | // sampler2DRect sColor2; |
| 158 | vec2 vUv; |
| 159 | void write_output(vec4 color) { |
| 160 | oFragColorgl_FragColor = color; |
| 161 | } |
| 162 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
| 163 | vec2 uv = vUv; |
| 164 | vec4 texel = texture(sColor0, (uv).sel(X,Y)); |
| 165 | vec4 color = texel; |
| 166 | write_output(color); |
| 167 | } |
| 168 | void swgl_drawSpanRGBA8() { |
| 169 | vec4_scalar color = make_vec4(1.f); |
| 170 | vec4_scalar uvBounds = make_vec4(make_vec2(0.f), make_vec2(textureSize(sColor0))); |
| 171 | if ((color)!=(make_vec4(1.f))) { |
| 172 | { |
| 173 | swgl_commitTextureColorRGBA8(sColor0, vUv, uvBounds, color)do { if (sColor0->filter == TextureFilter::LINEAR) { do { auto packed_color = packColor(swgl_OutRGBA8, color); int len = (swgl_SpanLength ); int drawn = 0; if (LinearFilter filter = needsTextureLinear (sColor0, vUv, len)) { if (blend_key) { drawn = blendTextureLinear <true>(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8 , filter); } else { drawn = blendTextureLinear<false>(sColor0 , vUv, len, uvBounds, packed_color, swgl_OutRGBA8, filter); } } else if (blend_key) { drawn = blendTextureNearestFast<true >(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8 ); } else { drawn = blendTextureNearestFast<false>(sColor0 , vUv, len, uvBounds, packed_color, swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while (0); } else { do { auto packed_color = packColor(swgl_OutRGBA8, color); int drawn = 0; if (needsNearestFallback(sColor0, vUv, swgl_SpanLength) ) { if (blend_key) { drawn = blendTextureNearestRepeat<true , false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds, packed_color , swgl_OutRGBA8); } else { drawn = blendTextureNearestRepeat< false, false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds , packed_color, swgl_OutRGBA8); } } else if (blend_key) { drawn = blendTextureNearestFast<true>(sColor0, vUv, swgl_SpanLength , uvBounds, packed_color, swgl_OutRGBA8); } else { drawn = blendTextureNearestFast <false>(sColor0, vUv, swgl_SpanLength, uvBounds, packed_color , swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while (0); } } while (0); |
| 174 | } |
| 175 | } else { |
| 176 | swgl_commitTextureRGBA8(sColor0, vUv, uvBounds)do { if (sColor0->filter == TextureFilter::LINEAR) { do { auto packed_color = packColor(swgl_OutRGBA8, NoColor()); int len = (swgl_SpanLength); int drawn = 0; if (LinearFilter filter = needsTextureLinear (sColor0, vUv, len)) { if (blend_key) { drawn = blendTextureLinear <true>(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8 , filter); } else { drawn = blendTextureLinear<false>(sColor0 , vUv, len, uvBounds, packed_color, swgl_OutRGBA8, filter); } } else if (blend_key) { drawn = blendTextureNearestFast<true >(sColor0, vUv, len, uvBounds, packed_color, swgl_OutRGBA8 ); } else { drawn = blendTextureNearestFast<false>(sColor0 , vUv, len, uvBounds, packed_color, swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while (0); } else { do { auto packed_color = packColor(swgl_OutRGBA8, NoColor()); int drawn = 0; if (needsNearestFallback(sColor0, vUv, swgl_SpanLength )) { if (blend_key) { drawn = blendTextureNearestRepeat<true , false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds, packed_color , swgl_OutRGBA8); } else { drawn = blendTextureNearestRepeat< false, false>( sColor0, vUv, swgl_SpanLength, 0.0f, uvBounds , packed_color, swgl_OutRGBA8); } } else if (blend_key) { drawn = blendTextureNearestFast<true>(sColor0, vUv, swgl_SpanLength , uvBounds, packed_color, swgl_OutRGBA8); } else { drawn = blendTextureNearestFast <false>(sColor0, vUv, swgl_SpanLength, uvBounds, packed_color , swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while (0); } } while (0); |
| 177 | } |
| 178 | } |
| 179 | typedef composite_FAST_PATH_TEXTURE_RECT_vert::InterpOutputs InterpInputs; |
| 180 | InterpInputs interp_step; |
| 181 | struct InterpPerspective { |
| 182 | vec2 vUv; |
| 183 | }; |
| 184 | InterpPerspective interp_perspective; |
| 185 | static void read_interp_inputs(FragmentShaderImpl* impl, const void* init_, const void* step_) {Self* self = (Self*)impl;const InterpInputs* init = (const InterpInputs*)init_;const InterpInputs* step = (const InterpInputs*)step_; |
| 186 | self->vUv = init_interp(init->vUv, step->vUv); |
| 187 | self->interp_step.vUv = step->vUv * 4.0f; |
| 188 | } |
| 189 | static void read_perspective_inputs(FragmentShaderImpl* impl, const void* init_, const void* step_) {Self* self = (Self*)impl;const InterpInputs* init = (const InterpInputs*)init_;const InterpInputs* step = (const InterpInputs*)step_; |
| 190 | Float w = 1.0f / self->gl_FragCoord.w; |
| 191 | self->interp_perspective.vUv = init_interp(init->vUv, step->vUv); |
| 192 | self->vUv = self->interp_perspective.vUv * w; |
| 193 | self->interp_step.vUv = step->vUv * 4.0f; |
| 194 | } |
| 195 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) { |
| 196 | float chunks = steps * 0.25f; |
| 197 | vUv += interp_step.vUv * chunks; |
| 198 | } |
| 199 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) { |
| 200 | step_perspective(steps); |
| 201 | float chunks = steps * 0.25f; |
| 202 | Float w = 1.0f / gl_FragCoord.w; |
| 203 | interp_perspective.vUv += interp_step.vUv * chunks; |
| 204 | vUv = w * interp_perspective.vUv; |
| 205 | } |
| 206 | static void run(FragmentShaderImpl* impl) { |
| 207 | Self* self = (Self*)impl; |
| 208 | self->main(); |
| 209 | self->step_interp_inputs(); |
| 210 | } |
| 211 | static void skip(FragmentShaderImpl* impl, int steps) { |
| 212 | Self* self = (Self*)impl; |
| 213 | self->step_interp_inputs(steps); |
| 214 | } |
| 215 | static void run_perspective(FragmentShaderImpl* impl) { |
| 216 | Self* self = (Self*)impl; |
| 217 | self->main(); |
| 218 | self->step_perspective_inputs(); |
| 219 | } |
| 220 | static void skip_perspective(FragmentShaderImpl* impl, int steps) { |
| 221 | Self* self = (Self*)impl; |
| 222 | self->step_perspective_inputs(steps); |
| 223 | } |
| 224 | static int draw_span_RGBA8(FragmentShaderImpl* impl) { |
| 225 | Self* self = (Self*)impl; DISPATCH_DRAW_SPAN(self, RGBA8)do { int total = self->swgl_SpanLength; self->swgl_drawSpanRGBA8 (); int drawn = total - self->swgl_SpanLength; if (drawn) self ->step_interp_inputs(drawn); return drawn; } while (0); } |
| 226 | public: |
| 227 | composite_FAST_PATH_TEXTURE_RECT_frag() { |
| 228 | init_span_func = &read_interp_inputs; |
| 229 | run_func = &run; |
| 230 | skip_func = &skip; |
| 231 | draw_span_RGBA8_func = &draw_span_RGBA8; |
| 232 | enable_perspective(); |
| 233 | init_span_w_func = &read_perspective_inputs; |
| 234 | run_w_func = &run_perspective; |
| 235 | skip_w_func = &skip_perspective; |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | struct composite_FAST_PATH_TEXTURE_RECT_program : ProgramImpl, composite_FAST_PATH_TEXTURE_RECT_frag { |
| 240 | int get_uniform(const char *name) const override { |
| 241 | if (strcmp("sColor0", name) == 0) { return 2; } |
| 242 | if (strcmp("uTransform", name) == 0) { return 1; } |
| 243 | return -1; |
| 244 | } |
| 245 | void bind_attrib(const char* name, int index) override { |
| 246 | attrib_locations.bind_loc(name, index); |
| 247 | } |
| 248 | int get_attrib(const char* name) const override { |
| 249 | return attrib_locations.get_loc(name); |
| 250 | } |
| 251 | size_t interpolants_size() const override { return sizeof(InterpOutputs); } |
| 252 | VertexShaderImpl* get_vertex_shader() override { |
| 253 | return this; |
| 254 | } |
| 255 | FragmentShaderImpl* get_fragment_shader() override { |
| 256 | return this; |
| 257 | } |
| 258 | const char* get_name() const override { return "composite_FAST_PATH_TEXTURE_RECT"; } |
| 259 | static ProgramImpl* loader() { return new composite_FAST_PATH_TEXTURE_RECT_program; } |
| 260 | }; |
| 261 |