Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out/cs_border_solid.h
Warning:line 433, column 31
Value stored to 'data' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gl.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -fapprox-func -funsafe-math-optimizations -fno-signed-zeros -mreassociate -freciprocal-math -ffp-contract=off -fno-rounding-math -mrecip=none -complex-range=basic -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/gfx/wr/swgl -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/root/firefox-clang/gfx/wr/swgl -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/gfx/wr/swgl/../webrender/res -I src -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out -D _GLIBCXX_USE_CXX11_ABI=0 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-character-conversion -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c++ src/gl.cc
1struct cs_border_solid_common {
2struct Samplers {
3 sampler2D_impl sGpuBufferF_impl;
4 int sGpuBufferF_slot;
5 isampler2D_impl sGpuBufferI_impl;
6 int sGpuBufferI_slot;
7 bool set_slot(int index, int value) {
8 switch (index) {
9 case 1:
10 sGpuBufferF_slot = value;
11 return true;
12 case 2:
13 sGpuBufferI_slot = value;
14 return true;
15 }
16 return false;
17 }
18} samplers;
19struct AttribLocations {
20 int aPosition = NULL_ATTRIB16;
21 int aTaskOrigin = NULL_ATTRIB16;
22 int aFlags = NULL_ATTRIB16;
23 int aGpuDataAddress = NULL_ATTRIB16;
24 int aClipParams1 = NULL_ATTRIB16;
25 int aClipParams2 = NULL_ATTRIB16;
26 void bind_loc(const char* name, int index) {
27 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
28 if (strcmp("aTaskOrigin", name) == 0) { aTaskOrigin = index; return; }
29 if (strcmp("aFlags", name) == 0) { aFlags = index; return; }
30 if (strcmp("aGpuDataAddress", name) == 0) { aGpuDataAddress = index; return; }
31 if (strcmp("aClipParams1", name) == 0) { aClipParams1 = index; return; }
32 if (strcmp("aClipParams2", name) == 0) { aClipParams2 = index; return; }
33 }
34 int get_loc(const char* name) const {
35 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
36 if (strcmp("aTaskOrigin", name) == 0) { return aTaskOrigin != NULL_ATTRIB16 ? aTaskOrigin : -1; }
37 if (strcmp("aFlags", name) == 0) { return aFlags != NULL_ATTRIB16 ? aFlags : -1; }
38 if (strcmp("aGpuDataAddress", name) == 0) { return aGpuDataAddress != NULL_ATTRIB16 ? aGpuDataAddress : -1; }
39 if (strcmp("aClipParams1", name) == 0) { return aClipParams1 != NULL_ATTRIB16 ? aClipParams1 : -1; }
40 if (strcmp("aClipParams2", name) == 0) { return aClipParams2 != NULL_ATTRIB16 ? aClipParams2 : -1; }
41 return -1;
42 }
43} attrib_locations;
44ivec2_scalar vGpuDataAddress;
45vec4_scalar vColor0;
46vec4_scalar vColor1;
47vec4_scalar vColorLine;
48ivec2_scalar vMixColors;
49vec4_scalar vClipCenter_Sign;
50vec4_scalar vClipRadii;
51vec4_scalar vHorizontalClipCenter_Sign;
52vec2_scalar vHorizontalClipRadii;
53vec4_scalar vVerticalClipCenter_Sign;
54vec2_scalar vVerticalClipRadii;
55sampler2D sGpuBufferF;
56isampler2D sGpuBufferI;
57mat4_scalar uTransform;
58void bind_textures() {
59 sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot);
60 sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot);
61}
62};
63struct cs_border_solid_vert : VertexShaderImpl, cs_border_solid_common {
64private:
65typedef cs_border_solid_vert Self;
66// mat4_scalar uTransform;
67vec2 aPosition;
68struct RectWithSize_scalar {
69vec2_scalar p0;
70vec2_scalar size;
71RectWithSize_scalar() = default;
72RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
73};
74struct RectWithSize {
75vec2 p0;
76vec2 size;
77RectWithSize() = default;
78RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
79RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
80}
81IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
82}
83friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
84if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
85}};
86struct RectWithEndpoint_scalar {
87vec2_scalar p0;
88vec2_scalar p1;
89RectWithEndpoint_scalar() = default;
90RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
91};
92struct RectWithEndpoint {
93vec2 p0;
94vec2 p1;
95RectWithEndpoint() = default;
96RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
97RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
98}
99IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
100}
101friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
102if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
103}};
104// sampler2D sGpuBufferF;
105// isampler2D sGpuBufferI;
106vec2_scalar aTaskOrigin;
107int32_t aFlags;
108int32_t aGpuDataAddress;
109vec4_scalar aClipParams1;
110vec4_scalar aClipParams2;
111struct BorderInstanceGpuData_scalar {
112vec4_scalar rect;
113vec4_scalar color0;
114vec4_scalar color1;
115vec2_scalar widths;
116vec2_scalar radii;
117BorderInstanceGpuData_scalar() = default;
118BorderInstanceGpuData_scalar(vec4_scalar rect, vec4_scalar color0, vec4_scalar color1, vec2_scalar widths, vec2_scalar radii) : rect(rect), color0(color0), color1(color1), widths(widths), radii(radii){}
119};
120struct BorderInstanceGpuData {
121vec4 rect;
122vec4 color0;
123vec4 color1;
124vec2 widths;
125vec2 radii;
126BorderInstanceGpuData() = default;
127BorderInstanceGpuData(vec4 rect, vec4 color0, vec4 color1, vec2 widths, vec2 radii) : rect(rect), color0(color0), color1(color1), widths(widths), radii(radii){}
128BorderInstanceGpuData(vec4_scalar rect, vec4_scalar color0, vec4_scalar color1, vec2_scalar widths, vec2_scalar radii):rect(rect),color0(color0),color1(color1),widths(widths),radii(radii){
129}
130IMPLICIT BorderInstanceGpuData(BorderInstanceGpuData_scalar s):rect(s.rect),color0(s.color0),color1(s.color1),widths(s.widths),radii(s.radii){
131}
132friend BorderInstanceGpuData if_then_else(I32 c, BorderInstanceGpuData t, BorderInstanceGpuData e) { return BorderInstanceGpuData(
133if_then_else(c, t.rect, e.rect), if_then_else(c, t.color0, e.color0), if_then_else(c, t.color1, e.color1), if_then_else(c, t.widths, e.widths), if_then_else(c, t.radii, e.radii));
134}};
135// ivec2_scalar vGpuDataAddress;
136// vec4_scalar vColor0;
137// vec4_scalar vColor1;
138// vec4_scalar vColorLine;
139// ivec2_scalar vMixColors;
140// vec4_scalar vClipCenter_Sign;
141// vec4_scalar vClipRadii;
142// vec4_scalar vHorizontalClipCenter_Sign;
143// vec2_scalar vHorizontalClipRadii;
144// vec4_scalar vVerticalClipCenter_Sign;
145// vec2_scalar vVerticalClipRadii;
146vec2 vPos;
147ivec2_scalar get_gpu_buffer_uv(int32_t address) {
148 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
149}
150Array<vec4_scalar,4> fetch_from_gpu_buffer_4f_direct(ivec2_scalar uv) {
151 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 3, 0, 0);
152 return Array<vec4_scalar,4>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 2, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 3, 0)}};
153}
154Array<vec4_scalar,4> fetch_from_gpu_buffer_4f(int32_t address) {
155 ivec2_scalar uv = get_gpu_buffer_uv(address);
156 return fetch_from_gpu_buffer_4f_direct(uv);
157}
158BorderInstanceGpuData_scalar fetch_gpu_data(int32_t index) {
159 BorderInstanceGpuData_scalar data;
160 Array<vec4_scalar,4> texels = fetch_from_gpu_buffer_4f(index);
161 (data).rect = texels[0];
162 (data).color0 = texels[1];
163 (data).color1 = texels[2];
164 (data).widths = (texels[3]).sel(X,Y);
165 (data).radii = (texels[3]).sel(Z,W);
166 return data;
167}
168vec2_scalar get_outer_corner_scale(int32_t segment) {
169 vec2_scalar p;
170 switch (segment) {
171 case 0:
172 p = make_vec2(0.f, 0.f);
173 break;
174 case 1:
175 p = make_vec2(1.f, 0.f);
176 break;
177 case 2:
178 p = make_vec2(1.f, 1.f);
179 break;
180 case 3:
181 p = make_vec2(0.f, 1.f);
182 break;
183 default:
184 p = make_vec2(0.f);
185 break;
186 }
187 return p;
188}
189ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
190 BorderInstanceGpuData_scalar data = fetch_gpu_data(aGpuDataAddress);
191 (vGpuDataAddress).x = aGpuDataAddress;
192 int32_t segment = (aFlags)&(255);
193 bool do_aa = (((aFlags)>>(28))&(1))!=(0);
194 vec2_scalar outer_scale = get_outer_corner_scale(segment);
195 vec2_scalar size = (((data).rect).sel(Z,W))-(((data).rect).sel(X,Y));
196 vec2_scalar outer = (outer_scale)*(size);
197 vec2_scalar clip_sign = (1.f)-((2.f)*(outer_scale));
198 int32_t mix_colors;
199 switch (segment) {
200 case 0:
201 case 1:
202 case 2:
203 case 3:
204 {
205 mix_colors = do_aa ? 1 : 2;
206 break;
207 }
208 default:
209 mix_colors = 0;
210 break;
211 }
212 (vMixColors).x = mix_colors;
213 vPos = (size)*((aPosition).sel(X,Y));
214 vColor0 = (data).color0;
215 vColor1 = (data).color1;
216 vClipCenter_Sign = make_vec4((outer)+((clip_sign)*((data).radii)), clip_sign);
217 vClipRadii = make_vec4((data).radii, max(((data).radii)-((data).widths), 0.f));
218 vColorLine = make_vec4(outer, (((data).widths).y)*(-((clip_sign).y)), (((data).widths).x)*((clip_sign).x));
219 vec2_scalar horizontal_clip_sign = make_vec2(-((clip_sign).x), (clip_sign).y);
220 vHorizontalClipCenter_Sign = make_vec4(((aClipParams1).sel(X,Y))+((horizontal_clip_sign)*((aClipParams1).sel(Z,W))), horizontal_clip_sign);
221 vHorizontalClipRadii = (aClipParams1).sel(Z,W);
222 vec2_scalar vertical_clip_sign = make_vec2((clip_sign).x, -((clip_sign).y));
223 vVerticalClipCenter_Sign = make_vec4(((aClipParams2).sel(X,Y))+((vertical_clip_sign)*((aClipParams2).sel(Z,W))), vertical_clip_sign);
224 vVerticalClipRadii = (aClipParams2).sel(Z,W);
225 gl_Position = (uTransform)*(make_vec4(((aTaskOrigin)+(((data).rect).sel(X,Y)))+(vPos), 0.f, 1.f));
226}
227static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
228 Self* self = (Self*)impl;
229 if (self->samplers.set_slot(index, value)) return;
230 switch (index) {
231 case 1:
232 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
233 break;
234 case 2:
235 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
236 break;
237 case 3:
238 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
239 break;
240 }
241}
242static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
243 Self* self = (Self*)impl;
244 switch (index) {
245 case 1:
246 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
247 break;
248 case 2:
249 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
250 break;
251 case 3:
252 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
253 break;
254 }
255}
256static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
257 Self* self = (Self*)impl;
258 switch (index) {
259 case 1:
260 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
261 break;
262 case 2:
263 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
264 break;
265 case 3:
266 self->uTransform = mat4_scalar::load_from_ptr(value);
267 break;
268 }
269}
270static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
271 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
272 load_flat_attrib(self->aTaskOrigin, attribs[self->attrib_locations.aTaskOrigin], start, instance, count);
273 load_flat_attrib(self->aFlags, attribs[self->attrib_locations.aFlags], start, instance, count);
274 load_flat_attrib(self->aGpuDataAddress, attribs[self->attrib_locations.aGpuDataAddress], start, instance, count);
275 load_flat_attrib(self->aClipParams1, attribs[self->attrib_locations.aClipParams1], start, instance, count);
276 load_flat_attrib(self->aClipParams2, attribs[self->attrib_locations.aClipParams2], start, instance, count);
277}
278public:
279struct InterpOutputs {
280vec2_scalar vPos;
281};
282private:
283ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
284 for(int n = 0; n < 4; n++) {
285 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
286 dest->vPos = get_nth(vPos, n);
287 dest_ptr += stride;
288 }
289}
290static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
291 Self* self = (Self*)impl;
292 self->main();
293 self->store_interp_outputs(interps, interp_stride);
294}
295static void init_batch(VertexShaderImpl* impl) {
296 Self* self = (Self*)impl; self->bind_textures(); }
297public:
298cs_border_solid_vert() {
299 set_uniform_1i_func = &set_uniform_1i;
300 set_uniform_4fv_func = &set_uniform_4fv;
301 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
302 init_batch_func = &init_batch;
303 load_attribs_func = &load_attribs;
304 run_primitive_func = &run;
305}
306};
307
308
309struct cs_border_solid_frag : FragmentShaderImpl, cs_border_solid_vert {
310private:
311typedef cs_border_solid_frag Self;
312#define oFragColorgl_FragColor gl_FragColor
313// vec4 oFragColor;
314struct RectWithSize_scalar {
315vec2_scalar p0;
316vec2_scalar size;
317RectWithSize_scalar() = default;
318RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
319};
320struct RectWithSize {
321vec2 p0;
322vec2 size;
323RectWithSize() = default;
324RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
325RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
326}
327IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
328}
329friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
330if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
331}};
332struct RectWithEndpoint_scalar {
333vec2_scalar p0;
334vec2_scalar p1;
335RectWithEndpoint_scalar() = default;
336RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
337};
338struct RectWithEndpoint {
339vec2 p0;
340vec2 p1;
341RectWithEndpoint() = default;
342RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
343RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
344}
345IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
346}
347friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
348if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
349}};
350// sampler2D sGpuBufferF;
351// isampler2D sGpuBufferI;
352struct BorderInstanceGpuData_scalar {
353vec4_scalar rect;
354vec4_scalar color0;
355vec4_scalar color1;
356vec2_scalar widths;
357vec2_scalar radii;
358BorderInstanceGpuData_scalar() = default;
359BorderInstanceGpuData_scalar(vec4_scalar rect, vec4_scalar color0, vec4_scalar color1, vec2_scalar widths, vec2_scalar radii) : rect(rect), color0(color0), color1(color1), widths(widths), radii(radii){}
360};
361struct BorderInstanceGpuData {
362vec4 rect;
363vec4 color0;
364vec4 color1;
365vec2 widths;
366vec2 radii;
367BorderInstanceGpuData() = default;
368BorderInstanceGpuData(vec4 rect, vec4 color0, vec4 color1, vec2 widths, vec2 radii) : rect(rect), color0(color0), color1(color1), widths(widths), radii(radii){}
369BorderInstanceGpuData(vec4_scalar rect, vec4_scalar color0, vec4_scalar color1, vec2_scalar widths, vec2_scalar radii):rect(rect),color0(color0),color1(color1),widths(widths),radii(radii){
370}
371IMPLICIT BorderInstanceGpuData(BorderInstanceGpuData_scalar s):rect(s.rect),color0(s.color0),color1(s.color1),widths(s.widths),radii(s.radii){
372}
373friend BorderInstanceGpuData if_then_else(I32 c, BorderInstanceGpuData t, BorderInstanceGpuData e) { return BorderInstanceGpuData(
374if_then_else(c, t.rect, e.rect), if_then_else(c, t.color0, e.color0), if_then_else(c, t.color1, e.color1), if_then_else(c, t.widths, e.widths), if_then_else(c, t.radii, e.radii));
375}};
376// ivec2_scalar vGpuDataAddress;
377// vec4_scalar vColor0;
378// vec4_scalar vColor1;
379// vec4_scalar vColorLine;
380// ivec2_scalar vMixColors;
381// vec4_scalar vClipCenter_Sign;
382// vec4_scalar vClipRadii;
383// vec4_scalar vHorizontalClipCenter_Sign;
384// vec2_scalar vHorizontalClipRadii;
385// vec4_scalar vVerticalClipCenter_Sign;
386// vec2_scalar vVerticalClipRadii;
387vec2 vPos;
388ivec2_scalar get_gpu_buffer_uv(int32_t address) {
389 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
390}
391Array<vec4_scalar,4> fetch_from_gpu_buffer_4f_direct(ivec2_scalar uv) {
392 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 3, 0, 0);
393 return Array<vec4_scalar,4>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 2, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 3, 0)}};
394}
395Array<vec4_scalar,4> fetch_from_gpu_buffer_4f(int32_t address) {
396 ivec2_scalar uv = get_gpu_buffer_uv(address);
397 return fetch_from_gpu_buffer_4f_direct(uv);
398}
399BorderInstanceGpuData_scalar fetch_gpu_data(int32_t index) {
400 BorderInstanceGpuData_scalar data;
401 Array<vec4_scalar,4> texels = fetch_from_gpu_buffer_4f(index);
402 (data).rect = texels[0];
403 (data).color0 = texels[1];
404 (data).color1 = texels[2];
405 (data).widths = (texels[3]).sel(X,Y);
406 (data).radii = (texels[3]).sel(Z,W);
407 return data;
408}
409float compute_aa_range(vec2 position) {
410 return recip((fwidth(position)).x);
411}
412Float distance_to_line(vec2_scalar p0, vec2_scalar perp_dir, vec2 p) {
413 vec2 dir_to_p0 = (p0)-(p);
414 return dot(normalize(perp_dir), dir_to_p0);
415}
416Float distance_aa(float aa_range, Float signed_distance) {
417 Float dist = (signed_distance)*(aa_range);
418 return clamp((0.5f)-(dist), 0.f, 1.f);
419}
420Float distance_to_ellipse_approx(vec2 p, vec2_scalar inv_radii_sq, float scale) {
421 vec2 p_r = (p)*(inv_radii_sq);
422 Float g = (dot(p, p_r))-(scale);
423 vec2 dG = ((1.f)+(scale))*(p_r);
424 return (g)*(inversesqrt(dot(dG, dG)));
425}
426vec2_scalar inverse_radii_squared(vec2_scalar radii) {
427 return (1.f)/(max((radii)*(radii), 0.000001f));
428}
429Float distance_to_ellipse(vec2 p, vec2_scalar radii) {
430 return distance_to_ellipse_approx(p, inverse_radii_squared(radii), make_float((make_int(all(greaterThan(radii, make_vec2(0.f)))))&(1)));
431}
432ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
433 BorderInstanceGpuData_scalar data = fetch_gpu_data((vGpuDataAddress).x);
Value stored to 'data' during its initialization is never read
434 float aa_range = compute_aa_range(vPos);
435 bool do_aa = ((vMixColors).x)!=(2);
436 Float mix_factor = 0.f;
437 if (((vMixColors).x)!=(0)) {
438 {
439 Float d_line = distance_to_line((vColorLine).sel(X,Y), (vColorLine).sel(Z,W), vPos);
440 if (do_aa) {
441 {
442 mix_factor = distance_aa(aa_range, -(d_line));
443 }
444 } else {
445 mix_factor = if_then_else(((d_line)+(0.0001f))>=(0.f), 1.f, 0.f);
446 }
447 }
448 }
449 vec2 clip_relative_pos = (vPos)-((vClipCenter_Sign).sel(X,Y));
450 Bool in_clip_region = all(lessThan(((vClipCenter_Sign).sel(Z,W))*(clip_relative_pos), make_vec2(0.f)));
451 Float d = -(1.f);
452 auto _c4_ = in_clip_region;
453 {
454 Float d_radii_a;
455 Float d_radii_b;
456 d_radii_a = if_then_else(_c4_,distance_to_ellipse(clip_relative_pos, (vClipRadii).sel(X,Y)),d_radii_a);
457 d_radii_b = if_then_else(_c4_,distance_to_ellipse(clip_relative_pos, (vClipRadii).sel(Z,W)),d_radii_b);
458 d = if_then_else(_c4_,max(d_radii_a, -(d_radii_b)),d);
459 }
460 clip_relative_pos = (vPos)-((vHorizontalClipCenter_Sign).sel(X,Y));
461 in_clip_region = all(lessThan(((vHorizontalClipCenter_Sign).sel(Z,W))*(clip_relative_pos), make_vec2(0.f)));
462 auto _c5_ = in_clip_region;
463 {
464 Float d_radii = distance_to_ellipse(clip_relative_pos, (vHorizontalClipRadii).sel(X,Y));
465 d = if_then_else(_c5_,max(d_radii, d),d);
466 }
467 clip_relative_pos = (vPos)-((vVerticalClipCenter_Sign).sel(X,Y));
468 in_clip_region = all(lessThan(((vVerticalClipCenter_Sign).sel(Z,W))*(clip_relative_pos), make_vec2(0.f)));
469 auto _c6_ = in_clip_region;
470 {
471 Float d_radii = distance_to_ellipse(clip_relative_pos, (vVerticalClipRadii).sel(X,Y));
472 d = if_then_else(_c6_,max(d_radii, d),d);
473 }
474 Float alpha = do_aa ? distance_aa(aa_range, d) : 1.f;
475 vec4 color = mix(vColor0, vColor1, mix_factor);
476 oFragColorgl_FragColor = (color)*(alpha);
477}
478typedef cs_border_solid_vert::InterpOutputs InterpInputs;
479InterpInputs interp_step;
480struct InterpPerspective {
481vec2 vPos;
482};
483InterpPerspective interp_perspective;
484static 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_;
485 self->vPos = init_interp(init->vPos, step->vPos);
486 self->interp_step.vPos = step->vPos * 4.0f;
487}
488static 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_;
489 Float w = 1.0f / self->gl_FragCoord.w;
490 self->interp_perspective.vPos = init_interp(init->vPos, step->vPos);
491 self->vPos = self->interp_perspective.vPos * w;
492 self->interp_step.vPos = step->vPos * 4.0f;
493}
494ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
495 float chunks = steps * 0.25f;
496 vPos += interp_step.vPos * chunks;
497}
498ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
499 step_perspective(steps);
500 float chunks = steps * 0.25f;
501 Float w = 1.0f / gl_FragCoord.w;
502 interp_perspective.vPos += interp_step.vPos * chunks;
503 vPos = w * interp_perspective.vPos;
504}
505static void run(FragmentShaderImpl* impl) {
506 Self* self = (Self*)impl;
507 self->main();
508 self->step_interp_inputs();
509}
510static void skip(FragmentShaderImpl* impl, int steps) {
511 Self* self = (Self*)impl;
512 self->step_interp_inputs(steps);
513}
514static void run_perspective(FragmentShaderImpl* impl) {
515 Self* self = (Self*)impl;
516 self->main();
517 self->step_perspective_inputs();
518}
519static void skip_perspective(FragmentShaderImpl* impl, int steps) {
520 Self* self = (Self*)impl;
521 self->step_perspective_inputs(steps);
522}
523public:
524cs_border_solid_frag() {
525 init_span_func = &read_interp_inputs;
526 run_func = &run;
527 skip_func = &skip;
528 enable_perspective();
529 init_span_w_func = &read_perspective_inputs;
530 run_w_func = &run_perspective;
531 skip_w_func = &skip_perspective;
532}
533};
534
535struct cs_border_solid_program : ProgramImpl, cs_border_solid_frag {
536int get_uniform(const char *name) const override {
537 if (strcmp("sGpuBufferF", name) == 0) { return 1; }
538 if (strcmp("sGpuBufferI", name) == 0) { return 2; }
539 if (strcmp("uTransform", name) == 0) { return 3; }
540 return -1;
541}
542void bind_attrib(const char* name, int index) override {
543 attrib_locations.bind_loc(name, index);
544}
545int get_attrib(const char* name) const override {
546 return attrib_locations.get_loc(name);
547}
548size_t interpolants_size() const override { return sizeof(InterpOutputs); }
549VertexShaderImpl* get_vertex_shader() override {
550 return this;
551}
552FragmentShaderImpl* get_fragment_shader() override {
553 return this;
554}
555const char* get_name() const override { return "cs_border_solid"; }
556static ProgramImpl* loader() { return new cs_border_solid_program; }
557};
558