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