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