Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out/ps_quad_mask_SUPERELLIPSE.h
Warning:line 1039, column 8
Value stored to 'aa_start' 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 ps_quad_mask_SUPERELLIPSE_common {
2struct Samplers {
3 sampler2D_impl sGpuBufferF_impl;
4 int sGpuBufferF_slot;
5 isampler2D_impl sGpuBufferI_impl;
6 int sGpuBufferI_slot;
7 sampler2D_impl sRenderTasks_impl;
8 int sRenderTasks_slot;
9 sampler2D_impl sTransformPalette_impl;
10 int sTransformPalette_slot;
11 bool set_slot(int index, int value) {
12 switch (index) {
13 case 3:
14 sGpuBufferF_slot = value;
15 return true;
16 case 4:
17 sGpuBufferI_slot = value;
18 return true;
19 case 2:
20 sRenderTasks_slot = value;
21 return true;
22 case 1:
23 sTransformPalette_slot = value;
24 return true;
25 }
26 return false;
27 }
28} samplers;
29struct AttribLocations {
30 int aPosition = NULL_ATTRIB16;
31 int aData = NULL_ATTRIB16;
32 int aClipData = NULL_ATTRIB16;
33 void bind_loc(const char* name, int index) {
34 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
35 if (strcmp("aData", name) == 0) { aData = index; return; }
36 if (strcmp("aClipData", name) == 0) { aClipData = index; return; }
37 }
38 int get_loc(const char* name) const {
39 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
40 if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; }
41 if (strcmp("aClipData", name) == 0) { return aClipData != NULL_ATTRIB16 ? aClipData : -1; }
42 return -1;
43 }
44} attrib_locations;
45vec4_scalar vTransformBounds;
46vec4_scalar v_color;
47ivec4_scalar v_flags;
48vec4_scalar vClipCenter_Radius_TL;
49vec4_scalar vClipCenter_Radius_TR;
50vec4_scalar vClipCenter_Radius_BR;
51vec4_scalar vClipCenter_Radius_BL;
52vec4_scalar vClipPlane_A;
53vec4_scalar vClipPlane_B;
54vec4_scalar vClipPlane_C;
55vec4_scalar vClipShape;
56vec4_scalar vClipClampedInset;
57vec2_scalar vClipMode;
58sampler2D sGpuBufferF;
59isampler2D sGpuBufferI;
60sampler2D sRenderTasks;
61sampler2D sTransformPalette;
62mat4_scalar uTransform;
63void bind_textures() {
64 sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot);
65 sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot);
66 sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot);
67 sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot);
68}
69};
70struct ps_quad_mask_SUPERELLIPSE_vert : VertexShaderImpl, ps_quad_mask_SUPERELLIPSE_common {
71private:
72typedef ps_quad_mask_SUPERELLIPSE_vert Self;
73// mat4_scalar uTransform;
74vec2 aPosition;
75// sampler2D sColor0;
76// sampler2D sColor1;
77// sampler2D sColor2;
78struct RectWithSize_scalar {
79vec2_scalar p0;
80vec2_scalar size;
81RectWithSize_scalar() = default;
82RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
83};
84struct RectWithSize {
85vec2 p0;
86vec2 size;
87RectWithSize() = default;
88RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
89RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
90}
91IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
92}
93friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
94if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
95}};
96struct RectWithEndpoint_scalar {
97vec2_scalar p0;
98vec2_scalar p1;
99RectWithEndpoint_scalar() = default;
100RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
101};
102struct RectWithEndpoint {
103vec2 p0;
104vec2 p1;
105RectWithEndpoint() = default;
106RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
107RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
108}
109IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
110}
111friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
112if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
113}};
114// vec4_scalar vTransformBounds;
115// sampler2D sTransformPalette;
116struct Transform_scalar {
117mat4_scalar m;
118mat4_scalar inv_m;
119bool is_axis_aligned;
120Transform_scalar() = default;
121Transform_scalar(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
122};
123struct Transform {
124mat4 m;
125mat4 inv_m;
126Bool is_axis_aligned;
127Transform() = default;
128Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
129Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){
130}
131IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){
132}
133friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform(
134if_then_else(c, t.m, e.m), if_then_else(c, t.inv_m, e.inv_m), if_then_else(c, t.is_axis_aligned, e.is_axis_aligned));
135}};
136// sampler2D sRenderTasks;
137struct RenderTaskData_scalar {
138RectWithEndpoint_scalar task_rect;
139vec4_scalar user_data;
140RenderTaskData_scalar() = default;
141RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){}
142};
143struct RenderTaskData {
144RectWithEndpoint task_rect;
145vec4 user_data;
146RenderTaskData() = default;
147RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){}
148RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){
149}
150IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){
151}
152friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData(
153if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data));
154}};
155struct PictureTask_scalar {
156RectWithEndpoint_scalar task_rect;
157float device_pixel_scale;
158vec2_scalar content_origin;
159PictureTask_scalar() = default;
160PictureTask_scalar(RectWithEndpoint_scalar task_rect, float device_pixel_scale, vec2_scalar content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
161};
162struct PictureTask {
163RectWithEndpoint task_rect;
164Float device_pixel_scale;
165vec2 content_origin;
166PictureTask() = default;
167PictureTask(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
168PictureTask(RectWithEndpoint_scalar task_rect, float device_pixel_scale, vec2_scalar content_origin):task_rect(task_rect),device_pixel_scale(device_pixel_scale),content_origin(content_origin){
169}
170IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){
171}
172friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask(
173if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.device_pixel_scale, e.device_pixel_scale), if_then_else(c, t.content_origin, e.content_origin));
174}};
175struct ClipArea_scalar {
176RectWithEndpoint_scalar task_rect;
177float device_pixel_scale;
178vec2_scalar screen_origin;
179ClipArea_scalar() = default;
180ClipArea_scalar(RectWithEndpoint_scalar task_rect, float device_pixel_scale, vec2_scalar screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
181};
182struct ClipArea {
183RectWithEndpoint task_rect;
184Float device_pixel_scale;
185vec2 screen_origin;
186ClipArea() = default;
187ClipArea(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
188ClipArea(RectWithEndpoint_scalar task_rect, float device_pixel_scale, vec2_scalar screen_origin):task_rect(task_rect),device_pixel_scale(device_pixel_scale),screen_origin(screen_origin){
189}
190IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){
191}
192friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea(
193if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.device_pixel_scale, e.device_pixel_scale), if_then_else(c, t.screen_origin, e.screen_origin));
194}};
195// sampler2D sGpuBufferF;
196// isampler2D sGpuBufferI;
197// vec4_scalar v_color;
198// ivec4_scalar v_flags;
199ivec4_scalar aData;
200struct QuadSegment_scalar {
201RectWithEndpoint_scalar rect;
202RectWithEndpoint_scalar uv_rect;
203QuadSegment_scalar() = default;
204QuadSegment_scalar(RectWithEndpoint_scalar rect, RectWithEndpoint_scalar uv_rect) : rect(rect), uv_rect(uv_rect){}
205};
206struct QuadSegment {
207RectWithEndpoint rect;
208RectWithEndpoint uv_rect;
209QuadSegment() = default;
210QuadSegment(RectWithEndpoint rect, RectWithEndpoint uv_rect) : rect(rect), uv_rect(uv_rect){}
211QuadSegment(RectWithEndpoint_scalar rect, RectWithEndpoint_scalar uv_rect):rect(rect),uv_rect(uv_rect){
212}
213IMPLICIT QuadSegment(QuadSegment_scalar s):rect(s.rect),uv_rect(s.uv_rect){
214}
215friend QuadSegment if_then_else(I32 c, QuadSegment t, QuadSegment e) { return QuadSegment(
216if_then_else(c, t.rect, e.rect), if_then_else(c, t.uv_rect, e.uv_rect));
217}};
218struct PrimitiveInfo_scalar {
219vec2_scalar local_pos;
220RectWithEndpoint_scalar pattern_rect;
221RectWithEndpoint_scalar bounds;
222QuadSegment_scalar segment;
223int32_t edge_flags;
224int32_t quad_flags;
225ivec2_scalar pattern_input;
226PrimitiveInfo_scalar() = default;
227PrimitiveInfo_scalar(vec2_scalar local_pos, RectWithEndpoint_scalar pattern_rect, RectWithEndpoint_scalar bounds, QuadSegment_scalar segment, int32_t edge_flags, int32_t quad_flags, ivec2_scalar pattern_input) : local_pos(local_pos), pattern_rect(pattern_rect), bounds(bounds), segment(segment), edge_flags(edge_flags), quad_flags(quad_flags), pattern_input(pattern_input){}
228};
229struct PrimitiveInfo {
230vec2 local_pos;
231RectWithEndpoint pattern_rect;
232RectWithEndpoint bounds;
233QuadSegment segment;
234I32 edge_flags;
235I32 quad_flags;
236ivec2 pattern_input;
237PrimitiveInfo() = default;
238PrimitiveInfo(vec2 local_pos, RectWithEndpoint pattern_rect, RectWithEndpoint bounds, QuadSegment segment, I32 edge_flags, I32 quad_flags, ivec2 pattern_input) : local_pos(local_pos), pattern_rect(pattern_rect), bounds(bounds), segment(segment), edge_flags(edge_flags), quad_flags(quad_flags), pattern_input(pattern_input){}
239PrimitiveInfo(vec2_scalar local_pos, RectWithEndpoint_scalar pattern_rect, RectWithEndpoint_scalar bounds, QuadSegment_scalar segment, int32_t edge_flags, int32_t quad_flags, ivec2_scalar pattern_input):local_pos(local_pos),pattern_rect(pattern_rect),bounds(bounds),segment(segment),edge_flags(edge_flags),quad_flags(quad_flags),pattern_input(pattern_input){
240}
241IMPLICIT PrimitiveInfo(PrimitiveInfo_scalar s):local_pos(s.local_pos),pattern_rect(s.pattern_rect),bounds(s.bounds),segment(s.segment),edge_flags(s.edge_flags),quad_flags(s.quad_flags),pattern_input(s.pattern_input){
242}
243friend PrimitiveInfo if_then_else(I32 c, PrimitiveInfo t, PrimitiveInfo e) { return PrimitiveInfo(
244if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.pattern_rect, e.pattern_rect), if_then_else(c, t.bounds, e.bounds), if_then_else(c, t.segment, e.segment), if_then_else(c, t.edge_flags, e.edge_flags), if_then_else(c, t.quad_flags, e.quad_flags), if_then_else(c, t.pattern_input, e.pattern_input));
245}};
246struct QuadPrimitive_scalar {
247RectWithEndpoint_scalar bounds;
248RectWithEndpoint_scalar pattern_rect;
249RectWithEndpoint_scalar uv_rect;
250vec4_scalar pattern_scale_offset;
251vec4_scalar color;
252QuadPrimitive_scalar() = default;
253QuadPrimitive_scalar(RectWithEndpoint_scalar bounds, RectWithEndpoint_scalar pattern_rect, RectWithEndpoint_scalar uv_rect, vec4_scalar pattern_scale_offset, vec4_scalar color) : bounds(bounds), pattern_rect(pattern_rect), uv_rect(uv_rect), pattern_scale_offset(pattern_scale_offset), color(color){}
254};
255struct QuadPrimitive {
256RectWithEndpoint bounds;
257RectWithEndpoint pattern_rect;
258RectWithEndpoint uv_rect;
259vec4 pattern_scale_offset;
260vec4 color;
261QuadPrimitive() = default;
262QuadPrimitive(RectWithEndpoint bounds, RectWithEndpoint pattern_rect, RectWithEndpoint uv_rect, vec4 pattern_scale_offset, vec4 color) : bounds(bounds), pattern_rect(pattern_rect), uv_rect(uv_rect), pattern_scale_offset(pattern_scale_offset), color(color){}
263QuadPrimitive(RectWithEndpoint_scalar bounds, RectWithEndpoint_scalar pattern_rect, RectWithEndpoint_scalar uv_rect, vec4_scalar pattern_scale_offset, vec4_scalar color):bounds(bounds),pattern_rect(pattern_rect),uv_rect(uv_rect),pattern_scale_offset(pattern_scale_offset),color(color){
264}
265IMPLICIT QuadPrimitive(QuadPrimitive_scalar s):bounds(s.bounds),pattern_rect(s.pattern_rect),uv_rect(s.uv_rect),pattern_scale_offset(s.pattern_scale_offset),color(s.color){
266}
267friend QuadPrimitive if_then_else(I32 c, QuadPrimitive t, QuadPrimitive e) { return QuadPrimitive(
268if_then_else(c, t.bounds, e.bounds), if_then_else(c, t.pattern_rect, e.pattern_rect), if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.pattern_scale_offset, e.pattern_scale_offset), if_then_else(c, t.color, e.color));
269}};
270struct QuadHeader_scalar {
271int32_t transform_id;
272int32_t z_id;
273ivec2_scalar pattern_input;
274QuadHeader_scalar() = default;
275QuadHeader_scalar(int32_t transform_id, int32_t z_id, ivec2_scalar pattern_input) : transform_id(transform_id), z_id(z_id), pattern_input(pattern_input){}
276};
277struct QuadHeader {
278I32 transform_id;
279I32 z_id;
280ivec2 pattern_input;
281QuadHeader() = default;
282QuadHeader(I32 transform_id, I32 z_id, ivec2 pattern_input) : transform_id(transform_id), z_id(z_id), pattern_input(pattern_input){}
283QuadHeader(int32_t transform_id, int32_t z_id, ivec2_scalar pattern_input):transform_id(transform_id),z_id(z_id),pattern_input(pattern_input){
284}
285IMPLICIT QuadHeader(QuadHeader_scalar s):transform_id(s.transform_id),z_id(s.z_id),pattern_input(s.pattern_input){
286}
287friend QuadHeader if_then_else(I32 c, QuadHeader t, QuadHeader e) { return QuadHeader(
288if_then_else(c, t.transform_id, e.transform_id), if_then_else(c, t.z_id, e.z_id), if_then_else(c, t.pattern_input, e.pattern_input));
289}};
290struct QuadInstance_scalar {
291int32_t prim_address_i;
292int32_t prim_address_f;
293int32_t quad_flags;
294int32_t edge_flags;
295int32_t part_index;
296int32_t segment_index;
297int32_t picture_task_address;
298QuadInstance_scalar() = default;
299QuadInstance_scalar(int32_t prim_address_i, int32_t prim_address_f, int32_t quad_flags, int32_t edge_flags, int32_t part_index, int32_t segment_index, int32_t picture_task_address) : prim_address_i(prim_address_i), prim_address_f(prim_address_f), quad_flags(quad_flags), edge_flags(edge_flags), part_index(part_index), segment_index(segment_index), picture_task_address(picture_task_address){}
300};
301struct QuadInstance {
302I32 prim_address_i;
303I32 prim_address_f;
304I32 quad_flags;
305I32 edge_flags;
306I32 part_index;
307I32 segment_index;
308I32 picture_task_address;
309QuadInstance() = default;
310QuadInstance(I32 prim_address_i, I32 prim_address_f, I32 quad_flags, I32 edge_flags, I32 part_index, I32 segment_index, I32 picture_task_address) : prim_address_i(prim_address_i), prim_address_f(prim_address_f), quad_flags(quad_flags), edge_flags(edge_flags), part_index(part_index), segment_index(segment_index), picture_task_address(picture_task_address){}
311QuadInstance(int32_t prim_address_i, int32_t prim_address_f, int32_t quad_flags, int32_t edge_flags, int32_t part_index, int32_t segment_index, int32_t picture_task_address):prim_address_i(prim_address_i),prim_address_f(prim_address_f),quad_flags(quad_flags),edge_flags(edge_flags),part_index(part_index),segment_index(segment_index),picture_task_address(picture_task_address){
312}
313IMPLICIT QuadInstance(QuadInstance_scalar s):prim_address_i(s.prim_address_i),prim_address_f(s.prim_address_f),quad_flags(s.quad_flags),edge_flags(s.edge_flags),part_index(s.part_index),segment_index(s.segment_index),picture_task_address(s.picture_task_address){
314}
315friend QuadInstance if_then_else(I32 c, QuadInstance t, QuadInstance e) { return QuadInstance(
316if_then_else(c, t.prim_address_i, e.prim_address_i), if_then_else(c, t.prim_address_f, e.prim_address_f), if_then_else(c, t.quad_flags, e.quad_flags), if_then_else(c, t.edge_flags, e.edge_flags), if_then_else(c, t.part_index, e.part_index), if_then_else(c, t.segment_index, e.segment_index), if_then_else(c, t.picture_task_address, e.picture_task_address));
317}};
318struct VertexInfo_scalar {
319vec2_scalar local_pos;
320VertexInfo_scalar() = default;
321explicit VertexInfo_scalar(vec2_scalar local_pos) : local_pos(local_pos){}
322};
323struct VertexInfo {
324vec2 local_pos;
325VertexInfo() = default;
326explicit VertexInfo(vec2 local_pos) : local_pos(local_pos){}
327explicit VertexInfo(vec2_scalar local_pos):local_pos(local_pos){
328}
329IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos){
330}
331friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo(
332if_then_else(c, t.local_pos, e.local_pos));
333}};
334vec4 vClipLocalPos;
335// vec4_scalar vClipCenter_Radius_TL;
336// vec4_scalar vClipCenter_Radius_TR;
337// vec4_scalar vClipCenter_Radius_BR;
338// vec4_scalar vClipCenter_Radius_BL;
339// vec4_scalar vClipPlane_A;
340// vec4_scalar vClipPlane_B;
341// vec4_scalar vClipPlane_C;
342// vec4_scalar vClipShape;
343// vec4_scalar vClipClampedInset;
344// vec2_scalar vClipMode;
345ivec4_scalar aClipData;
346struct Clip_scalar {
347RectWithEndpoint_scalar rect;
348vec4_scalar radii_top;
349vec4_scalar radii_bottom;
350vec4_scalar shape;
351vec4_scalar inset;
352float mode;
353int32_t space;
354Clip_scalar() = default;
355Clip_scalar(RectWithEndpoint_scalar rect, vec4_scalar radii_top, vec4_scalar radii_bottom, vec4_scalar shape, vec4_scalar inset, float mode, int32_t space) : rect(rect), radii_top(radii_top), radii_bottom(radii_bottom), shape(shape), inset(inset), mode(mode), space(space){}
356};
357struct Clip {
358RectWithEndpoint rect;
359vec4 radii_top;
360vec4 radii_bottom;
361vec4 shape;
362vec4 inset;
363Float mode;
364I32 space;
365Clip() = default;
366Clip(RectWithEndpoint rect, vec4 radii_top, vec4 radii_bottom, vec4 shape, vec4 inset, Float mode, I32 space) : rect(rect), radii_top(radii_top), radii_bottom(radii_bottom), shape(shape), inset(inset), mode(mode), space(space){}
367Clip(RectWithEndpoint_scalar rect, vec4_scalar radii_top, vec4_scalar radii_bottom, vec4_scalar shape, vec4_scalar inset, float mode, int32_t space):rect(rect),radii_top(radii_top),radii_bottom(radii_bottom),shape(shape),inset(inset),mode(mode),space(space){
368}
369IMPLICIT Clip(Clip_scalar s):rect(s.rect),radii_top(s.radii_top),radii_bottom(s.radii_bottom),shape(s.shape),inset(s.inset),mode(s.mode),space(s.space){
370}
371friend Clip if_then_else(I32 c, Clip t, Clip e) { return Clip(
372if_then_else(c, t.rect, e.rect), if_then_else(c, t.radii_top, e.radii_top), if_then_else(c, t.radii_bottom, e.radii_bottom), if_then_else(c, t.shape, e.shape), if_then_else(c, t.inset, e.inset), if_then_else(c, t.mode, e.mode), if_then_else(c, t.space, e.space));
373}};
374QuadInstance_scalar decode_instance() {
375 QuadInstance_scalar qi = QuadInstance_scalar((aData).x, (aData).y, (((aData).z)>>(24))&(255), (((aData).z)>>(16))&(255), (((aData).z)>>(8))&(255), (((aData).z)>>(0))&(255), (aData).w);
376 return qi;
377}
378ivec2_scalar get_gpu_buffer_uv(int32_t address) {
379 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
380}
381ivec4_scalar fetch_from_gpu_buffer_1i(int32_t address) {
382 ivec2_scalar uv = get_gpu_buffer_uv(address);
383 return texelFetch(sGpuBufferI, uv, 0);
384}
385QuadHeader_scalar fetch_header(int32_t address) {
386 ivec4_scalar header = fetch_from_gpu_buffer_1i(address);
387 QuadHeader_scalar qh = QuadHeader_scalar((header).x, (header).y, (header).sel(Z,W));
388 return qh;
389}
390Transform_scalar fetch_transform(int32_t id) {
391 Transform_scalar transform;
392 (transform).is_axis_aligned = ((id)>>(23))==(0);
393 int32_t index = (id)&(4194303);
394 ivec2_scalar uv = make_ivec2(make_int((8u)*((make_uint(index))%((1024u)/(8u)))), make_int((make_uint(index))/((1024u)/(8u))));
395 ivec2_scalar uv0 = make_ivec2(((uv).x)+(0), (uv).y);
396 auto sTransformPalette_uv0_fetch = texelFetchPtr(sTransformPalette, uv0, 0, 7, 0, 0);
397 (transform).m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 0, 0);
398 (transform).m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 1, 0);
399 (transform).m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 2, 0);
400 (transform).m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 3, 0);
401 (transform).inv_m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 4, 0);
402 (transform).inv_m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 5, 0);
403 (transform).inv_m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 6, 0);
404 (transform).inv_m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 7, 0);
405 return transform;
406}
407RenderTaskData_scalar fetch_render_task_data(int32_t index) {
408 ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
409 auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0);
410 vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0);
411 vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0);
412 RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W));
413 RenderTaskData_scalar data = RenderTaskData_scalar(task_rect, texel1);
414 return data;
415}
416PictureTask_scalar fetch_picture_task(int32_t address) {
417 RenderTaskData_scalar task_data = fetch_render_task_data(address);
418 PictureTask_scalar task = PictureTask_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
419 return task;
420}
421Array<vec4_scalar,5> fetch_from_gpu_buffer_5f_direct(ivec2_scalar uv) {
422 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 4, 0, 0);
423 return Array<vec4_scalar,5>{{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), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 4, 0)}};
424}
425Array<vec4_scalar,5> fetch_from_gpu_buffer_5f(int32_t address) {
426 ivec2_scalar uv = get_gpu_buffer_uv(address);
427 return fetch_from_gpu_buffer_5f_direct(uv);
428}
429QuadPrimitive_scalar fetch_primitive(int32_t index) {
430 QuadPrimitive_scalar prim;
431 Array<vec4_scalar,5> texels = fetch_from_gpu_buffer_5f(index);
432 (prim).bounds = RectWithEndpoint_scalar((texels[0]).sel(X,Y), (texels[0]).sel(Z,W));
433 (prim).pattern_rect = RectWithEndpoint_scalar((texels[1]).sel(X,Y), (texels[1]).sel(Z,W));
434 (prim).uv_rect = RectWithEndpoint_scalar((texels[2]).sel(X,Y), (texels[2]).sel(Z,W));
435 (prim).pattern_scale_offset = texels[3];
436 (prim).color = texels[4];
437 return prim;
438}
439Array<vec4_scalar,2> fetch_from_gpu_buffer_2f_direct(ivec2_scalar uv) {
440 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 1, 0, 0);
441 return Array<vec4_scalar,2>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0)}};
442}
443Array<vec4_scalar,2> fetch_from_gpu_buffer_2f(int32_t address) {
444 ivec2_scalar uv = get_gpu_buffer_uv(address);
445 return fetch_from_gpu_buffer_2f_direct(uv);
446}
447QuadSegment_scalar fetch_segment(int32_t base, int32_t index) {
448 QuadSegment_scalar seg;
449 Array<vec4_scalar,2> texels = fetch_from_gpu_buffer_2f(((base)+(5))+((index)*(2)));
450 (seg).rect = RectWithEndpoint_scalar((texels[0]).sel(X,Y), (texels[0]).sel(Z,W));
451 (seg).uv_rect = RectWithEndpoint_scalar((texels[1]).sel(X,Y), (texels[1]).sel(Z,W));
452 return seg;
453}
454vec2 rect_clamp(RectWithEndpoint_scalar rect, vec2 pt) {
455 return clamp(pt, (rect).p0, (rect).p1);
456}
457VertexInfo write_vertex(vec2 local_pos, float z, Transform_scalar transform, vec2_scalar content_origin, RectWithEndpoint_scalar task_rect, int32_t quad_flags) {
458 VertexInfo vi;
459 vec4 transformed = ((transform).m)*(make_vec4(local_pos, 0.f, 1.f));
460 vec2 device_pos = (transformed).sel(X,Y);
461 Float w = (transformed).w;
462 if (((quad_flags)&(2))!=(0)) {
463 {
464 RectWithEndpoint_scalar device_clip_rect = RectWithEndpoint_scalar(content_origin, ((content_origin)+((task_rect).p1))-((task_rect).p0));
465 device_pos = rect_clamp(device_clip_rect, device_pos);
466 (vi).local_pos = (((transform).inv_m)*(make_vec4(device_pos, 0.f, 1.f))).sel(X,Y);
467 }
468 } else {
469 (vi).local_pos = local_pos;
470 }
471 vec2_scalar final_offset = (-(content_origin))+((task_rect).p0);
472 gl_Position = (uTransform)*(make_vec4((device_pos)+((final_offset)*(w)), (z)*(w), w));
473 return vi;
474}
475vec2_scalar scale_offset_map_point(vec4_scalar scale_offset, vec2_scalar p) {
476 return ((p)*((scale_offset).sel(X,Y)))+((scale_offset).sel(Z,W));
477}
478RectWithEndpoint_scalar scale_offset_map_rect(vec4_scalar scale_offset, RectWithEndpoint_scalar r) {
479 vec2_scalar p0 = scale_offset_map_point(scale_offset, (r).p0);
480 vec2_scalar p1 = scale_offset_map_point(scale_offset, (r).p1);
481 return RectWithEndpoint_scalar(min(p0, p1), max(p0, p1));
482}
483vec2 scale_offset_map_point(vec4_scalar scale_offset, vec2 p) {
484 return ((p)*((scale_offset).sel(X,Y)))+((scale_offset).sel(Z,W));
485}
486PrimitiveInfo quad_primive_info(void) {
487 QuadInstance_scalar qi = decode_instance();
488 QuadHeader_scalar qh = fetch_header((qi).prim_address_i);
489 Transform_scalar transform = fetch_transform((qh).transform_id);
490 PictureTask_scalar task = fetch_picture_task((qi).picture_task_address);
491 QuadPrimitive_scalar prim = fetch_primitive((qi).prim_address_f);
492 float z = make_float((qh).z_id);
493 QuadSegment_scalar seg;
494 if (((qi).segment_index)==(255)) {
495 {
496 (seg).rect = (prim).bounds;
497 (seg).uv_rect = (prim).uv_rect;
498 }
499 } else {
500 seg = fetch_segment((qi).prim_address_f, (qi).segment_index);
501 }
502 RectWithEndpoint_scalar local_coverage_rect = (seg).rect;
503 (local_coverage_rect).p0 = max((local_coverage_rect).p0, ((prim).bounds).p0);
504 (local_coverage_rect).p1 = min((local_coverage_rect).p1, ((prim).bounds).p1);
505 (local_coverage_rect).p1 = max((local_coverage_rect).p0, (local_coverage_rect).p1);
506 float aa_left = (((qi).edge_flags)&(1))!=(0) ? 1.f : 0.f;
507 float aa_top = (((qi).edge_flags)&(2))!=(0) ? 1.f : 0.f;
508 float aa_right = (((qi).edge_flags)&(4))!=(0) ? 1.f : 0.f;
509 float aa_bottom = (((qi).edge_flags)&(8))!=(0) ? 1.f : 0.f;
510 switch ((qi).part_index) {
511 case 1:
512 ((local_coverage_rect).p1).x = (((local_coverage_rect).p0).x)+(2.f);
513 swgl_antiAlias(1)do { swgl_AAEdgeMask = calcAAEdgeMask(1); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
514 break;
515 case 2:
516 ((local_coverage_rect).p0).x += (aa_left)*(2.f);
517 ((local_coverage_rect).p1).x -= (aa_right)*(2.f);
518 ((local_coverage_rect).p1).y = (((local_coverage_rect).p0).y)+(2.f);
519 swgl_antiAlias(2)do { swgl_AAEdgeMask = calcAAEdgeMask(2); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
520 break;
521 case 3:
522 ((local_coverage_rect).p0).x = (((local_coverage_rect).p1).x)-(2.f);
523 swgl_antiAlias(4)do { swgl_AAEdgeMask = calcAAEdgeMask(4); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
524 break;
525 case 4:
526 ((local_coverage_rect).p0).x += (aa_left)*(2.f);
527 ((local_coverage_rect).p1).x -= (aa_right)*(2.f);
528 ((local_coverage_rect).p0).y = (((local_coverage_rect).p1).y)-(2.f);
529 swgl_antiAlias(8)do { swgl_AAEdgeMask = calcAAEdgeMask(8); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
530 break;
531 case 0:
532 ((local_coverage_rect).p0).x += (aa_left)*(2.f);
533 ((local_coverage_rect).p1).x -= (aa_right)*(2.f);
534 ((local_coverage_rect).p0).y += (aa_top)*(2.f);
535 ((local_coverage_rect).p1).y -= (aa_bottom)*(2.f);
536 break;
537 case 5:
538 default:
539 swgl_antiAlias((qi).edge_flags)do { swgl_AAEdgeMask = calcAAEdgeMask((qi).edge_flags); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
540 break;
541 }
542 vec2 local_pos = mix((local_coverage_rect).p0, (local_coverage_rect).p1, aPosition);
543 VertexInfo vi = write_vertex(local_pos, z, transform, (task).content_origin, (task).task_rect, (qi).quad_flags);
544 v_color = (prim).color;
545 vec4_scalar pattern_tx = (prim).pattern_scale_offset;
546 (seg).rect = scale_offset_map_rect(pattern_tx, (seg).rect);
547 return PrimitiveInfo(scale_offset_map_point(pattern_tx, (vi).local_pos), scale_offset_map_rect(pattern_tx, (prim).pattern_rect), scale_offset_map_rect(pattern_tx, (prim).bounds), seg, (qi).edge_flags, (qi).quad_flags, (qh).pattern_input);
548}
549void antialiasing_vertex(PrimitiveInfo prim) {
550}
551Array<vec4_scalar,6> fetch_from_gpu_buffer_6f_direct(ivec2_scalar uv) {
552 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 5, 0, 0);
553 return Array<vec4_scalar,6>{{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), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 4, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 5, 0)}};
554}
555Array<vec4_scalar,6> fetch_from_gpu_buffer_6f(int32_t address) {
556 ivec2_scalar uv = get_gpu_buffer_uv(address);
557 return fetch_from_gpu_buffer_6f_direct(uv);
558}
559Clip_scalar fetch_clip(int32_t index) {
560 Clip_scalar clip;
561 (clip).space = (aClipData).z;
562 Array<vec4_scalar,6> texels = fetch_from_gpu_buffer_6f(index);
563 (clip).rect = RectWithEndpoint_scalar((texels[0]).sel(X,Y), (texels[0]).sel(Z,W));
564 (clip).radii_top = texels[1];
565 (clip).radii_bottom = texels[2];
566 (clip).mode = (texels[3]).x;
567 (clip).shape = texels[4];
568 (clip).inset = texels[5];
569 return clip;
570}
571vec2_scalar inverse_radii_squared(vec2_scalar radii) {
572 return (1.f)/(max((radii)*(radii), 0.000001f));
573}
574float compute_superellipse_half_corner_approx(float shape) {
575 shape = min(1.f, abs__glsl_abs(shape));
576 return ((0.25f)*(shape))+(0.5f);
577}
578vec4_scalar compute_superellipse_normals(vec2_scalar radii, float shape) {
579 float convex_half_corner = compute_superellipse_half_corner_approx(shape);
580 vec2_scalar tangent = make_vec2((0.5f)-((2.f)*(convex_half_corner)), ((2.f)*(convex_half_corner))-(1.5f));
581 radii = max(radii, 0.1f);
582 vec2_scalar n1 = normalize(((radii).sel(Y,X))*((tangent).sel(Y,X)));
583 vec2_scalar n2 = normalize(((radii).sel(Y,X))*((tangent).sel(X,Y)));
584 return make_vec4(n1, n2);
585}
586vec4_scalar compute_contoured_superellipse(vec2_scalar radii, float shape, vec2_scalar inset) {
587 vec4_scalar normals = compute_superellipse_normals(radii, shape);
588 if ((shape)<(0.f)) {
589 {
590 normals = (normals).sel(Z,W,X,Y);
591 }
592 }
593 vec4_scalar delta = (normals)*((inset).sel(Y,Y,X,X));
594 vec2_scalar offset = make_vec2((delta).x, (delta).w);
595 vec2_scalar contourRadii = max(((radii)+(make_vec2((delta).z, (delta).y)))-(offset), 0.1f);
596 return make_vec4(offset, contourRadii);
597}
598vec2_scalar inverse_radii(vec2_scalar radii) {
599 return (1.f)/(max(radii, 0.001f));
600}
601vec4_scalar precalc_corner(vec2_scalar center, vec2_scalar radii, vec2_scalar inset, vec2_scalar clip_sign, float k) {
602 if ((k)==(1.f)) {
603 {
604 return make_vec4(center, inverse_radii_squared(radii));
605 }
606 } else {
607 if ((k)<(1.f)) {
608 {
609 vec2_scalar reference_radii = (radii)==(make_vec2(0.f)) ? make_vec2(0.f) : (radii)+(inset);
610 vec4_scalar offset_radii = compute_contoured_superellipse(reference_radii, k, inset);
611 center += ((offset_radii).sel(X,Y))*(clip_sign);
612 radii = (offset_radii).sel(Z,W);
613 }
614 }
615 return make_vec4(center, inverse_radii(radii));
616 }
617}
618void pattern_vertex(PrimitiveInfo prim_info) {
619 Clip_scalar clip = fetch_clip((aClipData).y);
620 Transform_scalar clip_transform = fetch_transform((aClipData).x);
621 vClipLocalPos = ((clip_transform).m)*(make_vec4((prim_info).local_pos, 0.f, 1.f));
622 if (((clip).space)==(0)) {
623 {
624 vTransformBounds = make_vec4(((clip).rect).p0, ((clip).rect).p1);
625 }
626 } else {
627 RectWithEndpoint xf_bounds = RectWithEndpoint(max(((clip).rect).p0, ((prim_info).bounds).p0), min(((clip).rect).p1, ((prim_info).bounds).p1));
628 vTransformBounds = force_scalar(make_vec4((xf_bounds).p0, (xf_bounds).p1));
629 }
630 (vClipMode).x = (clip).mode;
631 vec2_scalar r_tl = ((clip).radii_top).sel(X,Y);
632 vec2_scalar r_tr = ((clip).radii_top).sel(Z,W);
633 vec2_scalar r_br = ((clip).radii_bottom).sel(Z,W);
634 vec2_scalar r_bl = ((clip).radii_bottom).sel(X,Y);
635 vClipCenter_Radius_TL = precalc_corner((((clip).rect).p0)+(r_tl), r_tl, ((clip).inset).sel(W,X), make_vec2(-(1.f), -(1.f)), ((clip).shape).x);
636 vClipCenter_Radius_TR = precalc_corner(make_vec2(((((clip).rect).p1).x)-((r_tr).x), ((((clip).rect).p0).y)+((r_tr).y)), r_tr, ((clip).inset).sel(Y,X), make_vec2(1.f, -(1.f)), ((clip).shape).y);
637 vClipCenter_Radius_BR = precalc_corner((((clip).rect).p1)-(r_br), r_br, ((clip).inset).sel(Y,Z), make_vec2(1.f, 1.f), ((clip).shape).z);
638 vClipCenter_Radius_BL = precalc_corner(make_vec2(((((clip).rect).p0).x)+((r_bl).x), ((((clip).rect).p1).y)-((r_bl).y)), r_bl, ((clip).inset).sel(W,Z), make_vec2(-(1.f), 1.f), ((clip).shape).w);
639 vec2_scalar n_tl = -((r_tl).sel(Y,X));
640 vec2_scalar n_tr = make_vec2((r_tr).y, -((r_tr).x));
641 vec2_scalar n_br = (r_br).sel(Y,X);
642 vec2_scalar n_bl = make_vec2(-((r_bl).y), (r_bl).x);
643 vec3_scalar tl = make_vec3(n_tl, dot(n_tl, make_vec2((((clip).rect).p0).x, ((((clip).rect).p0).y)+((r_tl).y))));
644 vec3_scalar tr = make_vec3(n_tr, dot(n_tr, make_vec2(((((clip).rect).p1).x)-((r_tr).x), (((clip).rect).p0).y)));
645 vec3_scalar br = make_vec3(n_br, dot(n_br, make_vec2((((clip).rect).p1).x, ((((clip).rect).p1).y)-((r_br).y))));
646 vec3_scalar bl = make_vec3(n_bl, dot(n_bl, make_vec2(((((clip).rect).p0).x)+((r_bl).x), (((clip).rect).p1).y)));
647 vClipPlane_A = make_vec4((tl).x, (tl).y, (tl).z, (tr).x);
648 vClipPlane_B = make_vec4((tr).y, (tr).z, (br).x, (br).y);
649 vClipPlane_C = make_vec4((br).z, (bl).x, (bl).y, (bl).z);
650 vClipShape = (clip).shape;
651 vClipClampedInset = min((clip).inset, 0.f);
652}
653ALWAYS_INLINE__attribute__((always_inline)) inline void main() {
654 PrimitiveInfo prim = quad_primive_info();
655 auto _c2_ = (((prim).quad_flags)&(16))!=(0);
656 {
657 if (_c2_[0]) { (v_flags).z = 1; };
658 }
659 {
660 if (~(_c2_)[0]) { (v_flags).z = 0; };
661 }
662 antialiasing_vertex(prim);
663 pattern_vertex(prim);
664}
665static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
666 Self* self = (Self*)impl;
667 if (self->samplers.set_slot(index, value)) return;
668 switch (index) {
669 case 3:
670 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
671 break;
672 case 4:
673 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
674 break;
675 case 2:
676 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
677 break;
678 case 1:
679 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
680 break;
681 case 5:
682 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
683 break;
684 }
685}
686static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
687 Self* self = (Self*)impl;
688 switch (index) {
689 case 3:
690 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
691 break;
692 case 4:
693 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
694 break;
695 case 2:
696 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
697 break;
698 case 1:
699 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
700 break;
701 case 5:
702 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
703 break;
704 }
705}
706static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
707 Self* self = (Self*)impl;
708 switch (index) {
709 case 3:
710 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
711 break;
712 case 4:
713 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
714 break;
715 case 2:
716 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
717 break;
718 case 1:
719 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
720 break;
721 case 5:
722 self->uTransform = mat4_scalar::load_from_ptr(value);
723 break;
724 }
725}
726static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
727 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
728 load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count);
729 load_flat_attrib(self->aClipData, attribs[self->attrib_locations.aClipData], start, instance, count);
730}
731public:
732struct InterpOutputs {
733vec4_scalar vClipLocalPos;
734};
735private:
736ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
737 for(int n = 0; n < 4; n++) {
738 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
739 dest->vClipLocalPos = get_nth(vClipLocalPos, n);
740 dest_ptr += stride;
741 }
742}
743static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
744 Self* self = (Self*)impl;
745 self->main();
746 self->store_interp_outputs(interps, interp_stride);
747}
748static void init_batch(VertexShaderImpl* impl) {
749 Self* self = (Self*)impl; self->bind_textures(); }
750public:
751ps_quad_mask_SUPERELLIPSE_vert() {
752 set_uniform_1i_func = &set_uniform_1i;
753 set_uniform_4fv_func = &set_uniform_4fv;
754 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
755 init_batch_func = &init_batch;
756 load_attribs_func = &load_attribs;
757 run_primitive_func = &run;
758}
759};
760
761
762struct ps_quad_mask_SUPERELLIPSE_frag : FragmentShaderImpl, ps_quad_mask_SUPERELLIPSE_vert {
763private:
764typedef ps_quad_mask_SUPERELLIPSE_frag Self;
765#define oFragColorgl_FragColor gl_FragColor
766// vec4 oFragColor;
767// sampler2D sColor0;
768// sampler2D sColor1;
769// sampler2D sColor2;
770struct RectWithSize_scalar {
771vec2_scalar p0;
772vec2_scalar size;
773RectWithSize_scalar() = default;
774RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
775};
776struct RectWithSize {
777vec2 p0;
778vec2 size;
779RectWithSize() = default;
780RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
781RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
782}
783IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
784}
785friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
786if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
787}};
788struct RectWithEndpoint_scalar {
789vec2_scalar p0;
790vec2_scalar p1;
791RectWithEndpoint_scalar() = default;
792RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
793};
794struct RectWithEndpoint {
795vec2 p0;
796vec2 p1;
797RectWithEndpoint() = default;
798RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
799RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
800}
801IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
802}
803friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
804if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
805}};
806// vec4_scalar vTransformBounds;
807// sampler2D sGpuBufferF;
808// isampler2D sGpuBufferI;
809// vec4_scalar v_color;
810// ivec4_scalar v_flags;
811vec4 vClipLocalPos;
812// vec4_scalar vClipCenter_Radius_TL;
813// vec4_scalar vClipCenter_Radius_TR;
814// vec4_scalar vClipCenter_Radius_BR;
815// vec4_scalar vClipCenter_Radius_BL;
816// vec4_scalar vClipPlane_A;
817// vec4_scalar vClipPlane_B;
818// vec4_scalar vClipPlane_C;
819// vec4_scalar vClipShape;
820// vec4_scalar vClipClampedInset;
821// vec2_scalar vClipMode;
822float antialiasing_fragment() {
823 float alpha = 1.f;
824 return alpha;
825}
826float compute_aa_range(vec2 position) {
827 return recip((fwidth(position)).x);
828}
829Float distance_to_ellipse_approx(vec2 p, vec2 inv_radii_sq, float scale) {
830 vec2 p_r = (p)*(inv_radii_sq);
831 Float g = (dot(p, p_r))-(scale);
832 vec2 dG = ((1.f)+(scale))*(p_r);
833 return (g)*(inversesqrt(dot(dG, dG)));
834}
835vec2 signed_distance_rect_xy(vec2 pos, vec2_scalar p0, vec2_scalar p1) {
836 return max((p0)-(pos), (pos)-(p1));
837}
838Float signed_distance_rect(vec2 pos, vec2_scalar p0, vec2_scalar p1) {
839 vec2 d = signed_distance_rect_xy(pos, p0, p1);
840 return max((d).x, (d).y);
841}
842Float distance_to_rounded_rect(vec2 pos, vec3_scalar plane_tl, vec4 center_radius_tl, vec3_scalar plane_tr, vec4 center_radius_tr, vec3_scalar plane_br, vec4 center_radius_br, vec3_scalar plane_bl, vec4 center_radius_bl, vec4_scalar rect_bounds) {
843 vec4 corner = make_vec4(make_vec2(0.000001f), make_vec2(1.f));
844 (center_radius_tl).lsel(X,Y) = ((center_radius_tl).sel(X,Y))-(pos);
845 (center_radius_tr).lsel(X,Y) = (((center_radius_tr).sel(X,Y))-(pos))*(make_vec2(-(1.f), 1.f));
846 (center_radius_br).lsel(X,Y) = (pos)-((center_radius_br).sel(X,Y));
847 (center_radius_bl).lsel(X,Y) = (((center_radius_bl).sel(X,Y))-(pos))*(make_vec2(1.f, -(1.f)));
848 auto _c5_ = (dot(pos, (plane_tl).sel(X,Y)))>((plane_tl).z);
849 {
850 corner = if_then_else(_c5_,center_radius_tl,corner);
851 }
852 auto _c6_ = (dot(pos, (plane_tr).sel(X,Y)))>((plane_tr).z);
853 {
854 corner = if_then_else(_c6_,center_radius_tr,corner);
855 }
856 auto _c7_ = (dot(pos, (plane_br).sel(X,Y)))>((plane_br).z);
857 {
858 corner = if_then_else(_c7_,center_radius_br,corner);
859 }
860 auto _c8_ = (dot(pos, (plane_bl).sel(X,Y)))>((plane_bl).z);
861 {
862 corner = if_then_else(_c8_,center_radius_bl,corner);
863 }
864 return max(distance_to_ellipse_approx((corner).sel(X,Y), (corner).sel(Z,W), 1.f), signed_distance_rect(pos, (rect_bounds).sel(X,Y), (rect_bounds).sel(Z,W)));
865}
866Float distance_to_ellipse_approx(vec2 p, vec2_scalar inv_radii_sq, float scale) {
867 vec2 p_r = (p)*(inv_radii_sq);
868 Float g = (dot(p, p_r))-(scale);
869 vec2 dG = ((1.f)+(scale))*(p_r);
870 return (g)*(inversesqrt(dot(dG, dG)));
871}
872float compute_superellipse_half_corner_approx(float shape) {
873 shape = min(1.f, abs__glsl_abs(shape));
874 return ((0.25f)*(shape))+(0.5f);
875}
876vec4_scalar compute_superellipse_normals(vec2_scalar radii, float shape) {
877 float convex_half_corner = compute_superellipse_half_corner_approx(shape);
878 vec2_scalar tangent = make_vec2((0.5f)-((2.f)*(convex_half_corner)), ((2.f)*(convex_half_corner))-(1.5f));
879 radii = max(radii, 0.1f);
880 vec2_scalar n1 = normalize(((radii).sel(Y,X))*((tangent).sel(Y,X)));
881 vec2_scalar n2 = normalize(((radii).sel(Y,X))*((tangent).sel(X,Y)));
882 return make_vec4(n1, n2);
883}
884Float distance_to_superellipse_approx(vec2 p, vec2_scalar inv_radii, float k) {
885 I32 ret_mask = ~0;
886 Float ret;
887 if ((k)>(10.f)) {
888 {
889 vec2_scalar radii = (1.f)/(inv_radii);
890 return max(((p).x)-((radii).x), ((p).y)-((radii).y));
891 }
892 }
893 if ((k)<(-(10.f))) {
894 {
895 return min((p).x, (p).y);
896 }
897 }
898 if ((k)==(0.f)) {
899 {
900 Float g = (dot(p, inv_radii))-(1.f);
901 return (g)*(inversesqrt(dot(inv_radii, inv_radii)));
902 }
903 }
904 if ((k)<(0.f)) {
905 {
906 vec2_scalar radii = (1.f)/(inv_radii);
907 p = (radii)-(p);
908 }
909 }
910 float n = exp2__glsl_exp2(abs__glsl_abs(k));
911 vec2 q = (p)*(inv_radii);
912 auto _c18_ = any(lessThanEqual(q, make_vec2(0.f)));
913 {
914 vec2_scalar radii = (1.f)/(inv_radii);
915 vec4_scalar normals = compute_superellipse_normals(radii, k);
916 Float d1 = (dot(p, (normals).sel(X,Y)))-(((normals).y)*((radii).y));
917 Float d2 = (dot(p, (normals).sel(Z,W)))-(((normals).z)*((radii).x));
918 if ((k)>=(0.f)) {
919 {
920 ret = max(-(d1), -(d2));
921 ret_mask = ~I32(_c18_);
922 }
923 } else {
924 ret = if_then_else(ret_mask & I32(_c18_), min(d1, d2), ret);
925 ret_mask &= ~I32(_c18_);
926 }
927 }
928 vec2 qn = pow__glsl_pow(q, make_vec2(n));
929 qn = clamp(qn, 0.f, 1000.f);
930 Float f = (((qn).x)+((qn).y))-(1.f);
931 vec2 qn1 = pow__glsl_pow(q, make_vec2((n)-(1.f)));
932 qn1 = clamp(qn1, 0.f, 100.f);
933 vec2 grad = ((n)*(qn1))*(inv_radii);
934 grad = max(grad, inv_radii);
935 ret = if_then_else(ret_mask, ((sign(k))*(f))*(inversesqrt(dot(grad, grad))), ret);
936 return ret;
937}
938Float distance_to_shaped_corner(vec2 pos, vec2_scalar inv_radii, float shape) {
939 if ((shape)==(1.f)) {
940 {
941 return distance_to_ellipse_approx(pos, inv_radii, 1.f);
942 }
943 } else {
944 return distance_to_superellipse_approx(pos, inv_radii, shape);
945 }
946}
947Float distance_to_shaped_rect(vec2 pos, vec4_scalar center_radius_tl, vec4_scalar center_radius_tr, vec4_scalar center_radius_br, vec4_scalar center_radius_bl, vec4_scalar rect_bounds, vec4_scalar corner_shapes, vec4_scalar clamped_inset) {
948 Float d = signed_distance_rect(pos, (rect_bounds).sel(X,Y), (rect_bounds).sel(Z,W));
949 vec2 p_tl = ((center_radius_tl).sel(X,Y))-(pos);
950 vec2 p_tr = (((center_radius_tr).sel(X,Y))-(pos))*(make_vec2(-(1.f), 1.f));
951 vec2 p_br = (pos)-((center_radius_br).sel(X,Y));
952 vec2 p_bl = (((center_radius_bl).sel(X,Y))-(pos))*(make_vec2(1.f, -(1.f)));
953 vec2_scalar i_tl = ((corner_shapes).x)==(1.f) ? make_vec2(0.f) : (clamped_inset).sel(X,W);
954 vec2_scalar i_tr = ((corner_shapes).y)==(1.f) ? make_vec2(0.f) : (clamped_inset).sel(X,Y);
955 vec2_scalar i_br = ((corner_shapes).z)==(1.f) ? make_vec2(0.f) : (clamped_inset).sel(Z,Y);
956 vec2_scalar i_bl = ((corner_shapes).w)==(1.f) ? make_vec2(0.f) : (clamped_inset).sel(Z,W);
957 auto _c13_ = (((p_tl).x)>=((i_tl).x))&&(((p_tl).y)>=((i_tl).y));
958 {
959 d = if_then_else(_c13_,max(d, distance_to_shaped_corner(p_tl, (center_radius_tl).sel(Z,W), (corner_shapes).x)),d);
960 }
961 auto _c14_ = (((p_tr).x)>=((i_tr).x))&&(((p_tr).y)>=((i_tr).y));
962 {
963 d = if_then_else(_c14_,max(d, distance_to_shaped_corner(p_tr, (center_radius_tr).sel(Z,W), (corner_shapes).y)),d);
964 }
965 auto _c15_ = (((p_br).x)>=((i_br).x))&&(((p_br).y)>=((i_br).y));
966 {
967 d = if_then_else(_c15_,max(d, distance_to_shaped_corner(p_br, (center_radius_br).sel(Z,W), (corner_shapes).z)),d);
968 }
969 auto _c16_ = (((p_bl).x)>=((i_bl).x))&&(((p_bl).y)>=((i_bl).y));
970 {
971 d = if_then_else(_c16_,max(d, distance_to_shaped_corner(p_bl, (center_radius_bl).sel(Z,W), (corner_shapes).w)),d);
972 }
973 return d;
974}
975Float distance_aa(float aa_range, Float signed_distance) {
976 Float dist = (signed_distance)*(aa_range);
977 return clamp((0.5f)-(dist), 0.f, 1.f);
978}
979vec4 pattern_fragment(vec4_scalar _base_color) {
980 vec2 clip_local_pos = ((vClipLocalPos).sel(X,Y))/((vClipLocalPos).w);
981 float aa_range = compute_aa_range(clip_local_pos);
982 vec3_scalar plane_tl = make_vec3((vClipPlane_A).x, (vClipPlane_A).y, (vClipPlane_A).z);
983 vec3_scalar plane_tr = make_vec3((vClipPlane_A).w, (vClipPlane_B).x, (vClipPlane_B).y);
984 vec3_scalar plane_br = make_vec3((vClipPlane_B).z, (vClipPlane_B).w, (vClipPlane_C).x);
985 vec3_scalar plane_bl = make_vec3((vClipPlane_C).y, (vClipPlane_C).z, (vClipPlane_C).w);
986 Float dist;
987 if ((vClipShape)==(make_vec4(1.f))) {
988 {
989 dist = distance_to_rounded_rect(clip_local_pos, plane_tl, vClipCenter_Radius_TL, plane_tr, vClipCenter_Radius_TR, plane_br, vClipCenter_Radius_BR, plane_bl, vClipCenter_Radius_BL, vTransformBounds);
990 }
991 } else {
992 dist = distance_to_shaped_rect(clip_local_pos, vClipCenter_Radius_TL, vClipCenter_Radius_TR, vClipCenter_Radius_BR, vClipCenter_Radius_BL, vTransformBounds, vClipShape, vClipClampedInset);
993 }
994 Float alpha = distance_aa(aa_range, dist);
995 Float final_alpha = mix(alpha, (1.f)-(alpha), (vClipMode).x);
996 return make_vec4(final_alpha);
997}
998ALWAYS_INLINE__attribute__((always_inline)) inline void main() {
999 vec4_scalar base_color = v_color;
1000 base_color *= antialiasing_fragment();
1001 vec4 output_color = pattern_fragment(base_color);
1002 if (((v_flags).z)!=(0)) {
1003 {
1004 output_color = (output_color).sel(R,R,R,R);
1005 }
1006 }
1007 oFragColorgl_FragColor = output_color;
1008}
1009void swgl_drawSpanR8() {
1010 if (((swgl_interpStep(vClipLocalPos)(interp_step.vClipLocalPos)).w)!=(0.f)) {
1011 {
1012 return;
1013 }
1014 }
1015 float w = swgl_forceScalar((vClipLocalPos).w);
1016 if ((w)<=(0.f)) {
1017 {
1018 swgl_commitSolidR8(0.f)do { int len = (swgl_SpanLength); if (blend_key) { if (swgl_ClipFlags
& SWGL_CLIP_FLAG_MASK) { commit_masked_solid_span(swgl_OutR8
, packColor(swgl_OutR8, (0.f)), len); } else if (swgl_ClipFlags
& SWGL_CLIP_FLAG_AA) { commit_aa_solid_span(swgl_OutR8, pack_span
(swgl_OutR8, (0.f)), len); } else { commit_solid_span<true
>(swgl_OutR8, pack_span(swgl_OutR8, (0.f)), len); } } else
{ commit_solid_span<false>(swgl_OutR8, pack_span(swgl_OutR8
, (0.f)), len); } swgl_OutR8 += len; swgl_SpanLength -= len; }
while (0)
;
1019 return;
1020 }
1021 }
1022 w = (1.f)/(w);
1023 vec2 local_pos = ((vClipLocalPos).sel(X,Y))*(w);
1024 vec2_scalar local_pos0 = swgl_forceScalar(local_pos);
1025 vec2_scalar local_step = ((swgl_interpStep(vClipLocalPos)(interp_step.vClipLocalPos)).sel(X,Y))*(w);
1026 float step_scale = max(dot(local_step, local_step), 0.000001f);
1027 float aa_range = compute_aa_range(local_pos);
1028 float aa_margin = inversesqrt(((aa_range)*(aa_range))*(step_scale));
1029 vec4_scalar clip_rect = vTransformBounds;
1030 vec4_scalar clip_dist = (mix(clip_rect, (clip_rect).sel(Z,W,X,Y), (lessThan(local_step, make_vec2(0.f))).sel(X,Y,X,Y)))-((local_pos0).sel(X,Y,X,Y));
1031 float aa_band = (0.5f)*(recip(aa_range));
1032 vec2_scalar inset = min(-((clip_dist).sel(X,Y)), (clip_dist).sel(Z,W));
1033 bvec2_scalar flat_axis = equal(local_step, make_vec2(0.f));
1034 bvec2_scalar partial = lessThan(inset, make_vec2(aa_band));
1035 bool aa_span = (((flat_axis).x)&&((partial).x))||(((flat_axis).y)&&((partial).y));
1036 clip_dist = mix((1000000.f)*(step(0.f, (clip_dist)-(make_vec4(aa_band, aa_band, -(aa_band), -(aa_band))))), (clip_dist)*((recip(local_step)).sel(X,Y,X,Y)), (notEqual(local_step, make_vec2(0.f))).sel(X,Y,X,Y));
1037 float opaque_start = max((clip_dist).x, (clip_dist).y);
1038 float opaque_end = min((clip_dist).z, (clip_dist).w);
1039 float aa_start = opaque_start;
Value stored to 'aa_start' during its initialization is never read
1040 float aa_end = opaque_end;
1041 vec3_scalar start_plane = make_vec3(1000000.f);
1042 vec3_scalar end_plane = make_vec3(1000000.f);
1043 return;
1044 vec3_scalar plane_tl = make_vec3((vClipPlane_A).x, (vClipPlane_A).y, (vClipPlane_A).z);
1045 vec3_scalar plane_tr = make_vec3((vClipPlane_A).w, (vClipPlane_B).x, (vClipPlane_B).y);
1046 vec3_scalar plane_br = make_vec3((vClipPlane_B).z, (vClipPlane_B).w, (vClipPlane_C).x);
1047 vec3_scalar plane_bl = make_vec3((vClipPlane_C).y, (vClipPlane_C).z, (vClipPlane_C).w);
1048 vec4_scalar start_corner = make_vec4(make_vec2(1000000.f), make_vec2(1.f));
1049 vec4_scalar end_corner = make_vec4(make_vec2(1000000.f), make_vec2(1.f));
1050 do {
1051 float dist = (dot(local_pos0, (plane_tl).sel(X,Y)))-((plane_tl).z);
1052 float scale = -(dot(local_step, (plane_tl).sel(X,Y)));
1053 if ((scale)>=(0.f)) {
1054 {
1055 if ((dist)>((opaque_start)*(scale))) {
1056 {
1057 start_corner = vClipCenter_Radius_TL;
1058 start_plane = plane_tl;
1059 float inv_scale = recip(max(scale, 0.000001f));
1060 opaque_start = (dist)*(inv_scale);
1061 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_tl).x)*((plane_tl).y)));
1062 aa_start = (opaque_start)-((apex)*(inv_scale));
1063 }
1064 }
1065 }
1066 } else if ((dist)>((opaque_end)*(scale))) {
1067 {
1068 end_corner = vClipCenter_Radius_TL;
1069 end_plane = plane_tl;
1070 float inv_scale = recip(min(scale, -(0.000001f)));
1071 opaque_end = (dist)*(inv_scale);
1072 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_tl).x)*((plane_tl).y)));
1073 aa_end = (opaque_end)-((apex)*(inv_scale));
1074 }
1075 }
1076 }
1077 while (false);
1078 do {
1079 float dist = (dot(local_pos0, (plane_tr).sel(X,Y)))-((plane_tr).z);
1080 float scale = -(dot(local_step, (plane_tr).sel(X,Y)));
1081 if ((scale)>=(0.f)) {
1082 {
1083 if ((dist)>((opaque_start)*(scale))) {
1084 {
1085 start_corner = vClipCenter_Radius_TR;
1086 start_plane = plane_tr;
1087 float inv_scale = recip(max(scale, 0.000001f));
1088 opaque_start = (dist)*(inv_scale);
1089 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_tr).x)*((plane_tr).y)));
1090 aa_start = (opaque_start)-((apex)*(inv_scale));
1091 }
1092 }
1093 }
1094 } else if ((dist)>((opaque_end)*(scale))) {
1095 {
1096 end_corner = vClipCenter_Radius_TR;
1097 end_plane = plane_tr;
1098 float inv_scale = recip(min(scale, -(0.000001f)));
1099 opaque_end = (dist)*(inv_scale);
1100 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_tr).x)*((plane_tr).y)));
1101 aa_end = (opaque_end)-((apex)*(inv_scale));
1102 }
1103 }
1104 }
1105 while (false);
1106 do {
1107 float dist = (dot(local_pos0, (plane_br).sel(X,Y)))-((plane_br).z);
1108 float scale = -(dot(local_step, (plane_br).sel(X,Y)));
1109 if ((scale)>=(0.f)) {
1110 {
1111 if ((dist)>((opaque_start)*(scale))) {
1112 {
1113 start_corner = vClipCenter_Radius_BR;
1114 start_plane = plane_br;
1115 float inv_scale = recip(max(scale, 0.000001f));
1116 opaque_start = (dist)*(inv_scale);
1117 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_br).x)*((plane_br).y)));
1118 aa_start = (opaque_start)-((apex)*(inv_scale));
1119 }
1120 }
1121 }
1122 } else if ((dist)>((opaque_end)*(scale))) {
1123 {
1124 end_corner = vClipCenter_Radius_BR;
1125 end_plane = plane_br;
1126 float inv_scale = recip(min(scale, -(0.000001f)));
1127 opaque_end = (dist)*(inv_scale);
1128 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_br).x)*((plane_br).y)));
1129 aa_end = (opaque_end)-((apex)*(inv_scale));
1130 }
1131 }
1132 }
1133 while (false);
1134 do {
1135 float dist = (dot(local_pos0, (plane_bl).sel(X,Y)))-((plane_bl).z);
1136 float scale = -(dot(local_step, (plane_bl).sel(X,Y)));
1137 if ((scale)>=(0.f)) {
1138 {
1139 if ((dist)>((opaque_start)*(scale))) {
1140 {
1141 start_corner = vClipCenter_Radius_BL;
1142 start_plane = plane_bl;
1143 float inv_scale = recip(max(scale, 0.000001f));
1144 opaque_start = (dist)*(inv_scale);
1145 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_bl).x)*((plane_bl).y)));
1146 aa_start = (opaque_start)-((apex)*(inv_scale));
1147 }
1148 }
1149 }
1150 } else if ((dist)>((opaque_end)*(scale))) {
1151 {
1152 end_corner = vClipCenter_Radius_BL;
1153 end_plane = plane_bl;
1154 float inv_scale = recip(min(scale, -(0.000001f)));
1155 opaque_end = (dist)*(inv_scale);
1156 float apex = (((0.7071f)-(0.5f))*(2.f))*(abs__glsl_abs(((plane_bl).x)*((plane_bl).y)));
1157 aa_end = (opaque_end)-((apex)*(inv_scale));
1158 }
1159 }
1160 }
1161 while (false);
1162 aa_margin = max((aa_margin)-(max((aa_start)-(aa_end), 0.f)), 0.f);
1163 aa_start -= aa_margin;
1164 aa_end += aa_margin;
1165 if (aa_span) {
1166 {
1167 opaque_end = min(opaque_end, opaque_start);
1168 }
1169 }
1170 ivec4_scalar steps = make_ivec4(clamp((swgl_SpanLength)-((swgl_StepSize)*(make_vec4(floor__glsl_floor(aa_start), ceil__glsl_ceil(opaque_start), floor__glsl_floor(opaque_end), ceil__glsl_ceil(aa_end)))), 0.f, swgl_SpanLength));
1171 int32_t aa_start_len = (steps).x;
1172 int32_t opaque_start_len = (steps).y;
1173 int32_t opaque_end_len = (steps).z;
1174 int32_t aa_end_len = (steps).w;
1175 if ((swgl_SpanLength)>(aa_start_len)) {
1176 {
1177 int32_t num_aa = (swgl_SpanLength)-(aa_start_len);
1178 swgl_commitPartialSolidR8(num_aa, (vClipMode).x)do { int len = (min(int(num_aa), swgl_SpanLength)); if (blend_key
) { if (swgl_ClipFlags & SWGL_CLIP_FLAG_MASK) { commit_masked_solid_span
(swgl_OutR8, packColor(swgl_OutR8, ((vClipMode).x)), len); } else
if (swgl_ClipFlags & SWGL_CLIP_FLAG_AA) { commit_aa_solid_span
(swgl_OutR8, pack_span(swgl_OutR8, ((vClipMode).x)), len); } else
{ commit_solid_span<true>(swgl_OutR8, pack_span(swgl_OutR8
, ((vClipMode).x)), len); } } else { commit_solid_span<false
>(swgl_OutR8, pack_span(swgl_OutR8, ((vClipMode).x)), len)
; } swgl_OutR8 += len; swgl_SpanLength -= len; } while (0)
;
1179 local_pos += (make_float((num_aa)/(swgl_StepSize)))*(local_step);
1180 }
1181 }
1182 if (((start_plane).x)<(100000.f)) {
1183 {
1184 while ((swgl_SpanLength)>(opaque_start_len)) {
1185 Float alpha = distance_aa(aa_range, if_then_else((dot(local_pos, (start_plane).sel(X,Y)))>((start_plane).z), distance_to_ellipse_approx((local_pos)-((start_corner).sel(X,Y)), (start_corner).sel(Z,W), 1.f), signed_distance_rect(local_pos, (vTransformBounds).sel(X,Y), (vTransformBounds).sel(Z,W))));
1186 swgl_commitColorR8(mix(alpha, (1.f)-(alpha), (vClipMode).x))do { auto r = pack_pixels_R8(mix(alpha, (1.f)-(alpha), (vClipMode
).x)); if (blend_key) r = blend_span(swgl_OutR8, r); commit_span
(swgl_OutR8, r); swgl_OutR8 += swgl_StepSize; swgl_SpanLength
-= swgl_StepSize; } while (0)
;
1187 local_pos += local_step;
1188 }
1189 }
1190 }
1191 while ((swgl_SpanLength)>(opaque_start_len)) {
1192 Float alpha = distance_aa(aa_range, signed_distance_rect(local_pos, (vTransformBounds).sel(X,Y), (vTransformBounds).sel(Z,W)));
1193 swgl_commitColorR8(mix(alpha, (1.f)-(alpha), (vClipMode).x))do { auto r = pack_pixels_R8(mix(alpha, (1.f)-(alpha), (vClipMode
).x)); if (blend_key) r = blend_span(swgl_OutR8, r); commit_span
(swgl_OutR8, r); swgl_OutR8 += swgl_StepSize; swgl_SpanLength
-= swgl_StepSize; } while (0)
;
1194 local_pos += local_step;
1195 }
1196 if ((swgl_SpanLength)>(opaque_end_len)) {
1197 {
1198 int32_t num_opaque = (swgl_SpanLength)-(opaque_end_len);
1199 swgl_commitPartialSolidR8(num_opaque, (1.f)-((vClipMode).x))do { int len = (min(int(num_opaque), swgl_SpanLength)); if (blend_key
) { if (swgl_ClipFlags & SWGL_CLIP_FLAG_MASK) { commit_masked_solid_span
(swgl_OutR8, packColor(swgl_OutR8, ((1.f)-((vClipMode).x))), len
); } else if (swgl_ClipFlags & SWGL_CLIP_FLAG_AA) { commit_aa_solid_span
(swgl_OutR8, pack_span(swgl_OutR8, ((1.f)-((vClipMode).x))), len
); } else { commit_solid_span<true>(swgl_OutR8, pack_span
(swgl_OutR8, ((1.f)-((vClipMode).x))), len); } } else { commit_solid_span
<false>(swgl_OutR8, pack_span(swgl_OutR8, ((1.f)-((vClipMode
).x))), len); } swgl_OutR8 += len; swgl_SpanLength -= len; } while
(0)
;
1200 local_pos += (make_float((num_opaque)/(swgl_StepSize)))*(local_step);
1201 }
1202 }
1203 if (((end_plane).x)<(100000.f)) {
1204 {
1205 while ((swgl_SpanLength)>(aa_end_len)) {
1206 Float alpha = distance_aa(aa_range, if_then_else((dot(local_pos, (end_plane).sel(X,Y)))>((end_plane).z), distance_to_ellipse_approx((local_pos)-((end_corner).sel(X,Y)), (end_corner).sel(Z,W), 1.f), signed_distance_rect(local_pos, (vTransformBounds).sel(X,Y), (vTransformBounds).sel(Z,W))));
1207 swgl_commitColorR8(mix(alpha, (1.f)-(alpha), (vClipMode).x))do { auto r = pack_pixels_R8(mix(alpha, (1.f)-(alpha), (vClipMode
).x)); if (blend_key) r = blend_span(swgl_OutR8, r); commit_span
(swgl_OutR8, r); swgl_OutR8 += swgl_StepSize; swgl_SpanLength
-= swgl_StepSize; } while (0)
;
1208 local_pos += local_step;
1209 }
1210 }
1211 }
1212 while ((swgl_SpanLength)>(aa_end_len)) {
1213 Float alpha = distance_aa(aa_range, signed_distance_rect(local_pos, (vTransformBounds).sel(X,Y), (vTransformBounds).sel(Z,W)));
1214 swgl_commitColorR8(mix(alpha, (1.f)-(alpha), (vClipMode).x))do { auto r = pack_pixels_R8(mix(alpha, (1.f)-(alpha), (vClipMode
).x)); if (blend_key) r = blend_span(swgl_OutR8, r); commit_span
(swgl_OutR8, r); swgl_OutR8 += swgl_StepSize; swgl_SpanLength
-= swgl_StepSize; } while (0)
;
1215 local_pos += local_step;
1216 }
1217 if ((swgl_SpanLength)>(0)) {
1218 {
1219 swgl_commitPartialSolidR8(swgl_SpanLength, (vClipMode).x)do { int len = (min(int(swgl_SpanLength), swgl_SpanLength)); if
(blend_key) { if (swgl_ClipFlags & SWGL_CLIP_FLAG_MASK) {
commit_masked_solid_span(swgl_OutR8, packColor(swgl_OutR8, (
(vClipMode).x)), len); } else if (swgl_ClipFlags & SWGL_CLIP_FLAG_AA
) { commit_aa_solid_span(swgl_OutR8, pack_span(swgl_OutR8, ((
vClipMode).x)), len); } else { commit_solid_span<true>(
swgl_OutR8, pack_span(swgl_OutR8, ((vClipMode).x)), len); } }
else { commit_solid_span<false>(swgl_OutR8, pack_span(
swgl_OutR8, ((vClipMode).x)), len); } swgl_OutR8 += len; swgl_SpanLength
-= len; } while (0)
;
1220 }
1221 }
1222}
1223typedef ps_quad_mask_SUPERELLIPSE_vert::InterpOutputs InterpInputs;
1224InterpInputs interp_step;
1225struct InterpPerspective {
1226vec4 vClipLocalPos;
1227};
1228InterpPerspective interp_perspective;
1229static 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_;
1230 self->vClipLocalPos = init_interp(init->vClipLocalPos, step->vClipLocalPos);
1231 self->interp_step.vClipLocalPos = step->vClipLocalPos * 4.0f;
1232}
1233static 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_;
1234 Float w = 1.0f / self->gl_FragCoord.w;
1235 self->interp_perspective.vClipLocalPos = init_interp(init->vClipLocalPos, step->vClipLocalPos);
1236 self->vClipLocalPos = self->interp_perspective.vClipLocalPos * w;
1237 self->interp_step.vClipLocalPos = step->vClipLocalPos * 4.0f;
1238}
1239ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
1240 float chunks = steps * 0.25f;
1241 vClipLocalPos += interp_step.vClipLocalPos * chunks;
1242}
1243ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
1244 step_perspective(steps);
1245 float chunks = steps * 0.25f;
1246 Float w = 1.0f / gl_FragCoord.w;
1247 interp_perspective.vClipLocalPos += interp_step.vClipLocalPos * chunks;
1248 vClipLocalPos = w * interp_perspective.vClipLocalPos;
1249}
1250static void run(FragmentShaderImpl* impl) {
1251 Self* self = (Self*)impl;
1252 self->main();
1253 self->step_interp_inputs();
1254}
1255static void skip(FragmentShaderImpl* impl, int steps) {
1256 Self* self = (Self*)impl;
1257 self->step_interp_inputs(steps);
1258}
1259static void run_perspective(FragmentShaderImpl* impl) {
1260 Self* self = (Self*)impl;
1261 self->main();
1262 self->step_perspective_inputs();
1263}
1264static void skip_perspective(FragmentShaderImpl* impl, int steps) {
1265 Self* self = (Self*)impl;
1266 self->step_perspective_inputs(steps);
1267}
1268static int draw_span_R8(FragmentShaderImpl* impl) {
1269 Self* self = (Self*)impl; DISPATCH_DRAW_SPAN(self, R8)do { int total = self->swgl_SpanLength; self->swgl_drawSpanR8
(); int drawn = total - self->swgl_SpanLength; if (drawn) self
->step_interp_inputs(drawn); return drawn; } while (0)
; }
1270public:
1271ps_quad_mask_SUPERELLIPSE_frag() {
1272 init_span_func = &read_interp_inputs;
1273 run_func = &run;
1274 skip_func = &skip;
1275 draw_span_R8_func = &draw_span_R8;
1276 enable_perspective();
1277 init_span_w_func = &read_perspective_inputs;
1278 run_w_func = &run_perspective;
1279 skip_w_func = &skip_perspective;
1280}
1281};
1282
1283struct ps_quad_mask_SUPERELLIPSE_program : ProgramImpl, ps_quad_mask_SUPERELLIPSE_frag {
1284int get_uniform(const char *name) const override {
1285 if (strcmp("sGpuBufferF", name) == 0) { return 3; }
1286 if (strcmp("sGpuBufferI", name) == 0) { return 4; }
1287 if (strcmp("sRenderTasks", name) == 0) { return 2; }
1288 if (strcmp("sTransformPalette", name) == 0) { return 1; }
1289 if (strcmp("uTransform", name) == 0) { return 5; }
1290 return -1;
1291}
1292void bind_attrib(const char* name, int index) override {
1293 attrib_locations.bind_loc(name, index);
1294}
1295int get_attrib(const char* name) const override {
1296 return attrib_locations.get_loc(name);
1297}
1298size_t interpolants_size() const override { return sizeof(InterpOutputs); }
1299VertexShaderImpl* get_vertex_shader() override {
1300 return this;
1301}
1302FragmentShaderImpl* get_fragment_shader() override {
1303 return this;
1304}
1305const char* get_name() const override { return "ps_quad_mask_SUPERELLIPSE"; }
1306static ProgramImpl* loader() { return new ps_quad_mask_SUPERELLIPSE_program; }
1307};
1308