Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out/ps_quad_mix_blend_TEXTURE_2D.h
Warning:line 804, column 3
Value stored to 'ret_mask' 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/15/../../../../include/c++/15 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/x86_64-linux-gnu/c++/15 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/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/15/../../../../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-07-16-093543-1626485-1 -x c++ src/gl.cc
1struct ps_quad_mix_blend_TEXTURE_2D_common {
2struct Samplers {
3 sampler2D_impl sColor0_impl;
4 int sColor0_slot;
5 sampler2D_impl sColor1_impl;
6 int sColor1_slot;
7 sampler2D_impl sGpuBufferF_impl;
8 int sGpuBufferF_slot;
9 isampler2D_impl sGpuBufferI_impl;
10 int sGpuBufferI_slot;
11 sampler2D_impl sRenderTasks_impl;
12 int sRenderTasks_slot;
13 sampler2D_impl sTransformPalette_impl;
14 int sTransformPalette_slot;
15 bool set_slot(int index, int value) {
16 switch (index) {
17 case 6:
18 sColor0_slot = value;
19 return true;
20 case 7:
21 sColor1_slot = value;
22 return true;
23 case 3:
24 sGpuBufferF_slot = value;
25 return true;
26 case 4:
27 sGpuBufferI_slot = value;
28 return true;
29 case 2:
30 sRenderTasks_slot = value;
31 return true;
32 case 1:
33 sTransformPalette_slot = value;
34 return true;
35 }
36 return false;
37 }
38} samplers;
39struct AttribLocations {
40 int aPosition = NULL_ATTRIB16;
41 int aData = NULL_ATTRIB16;
42 void bind_loc(const char* name, int index) {
43 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
44 if (strcmp("aData", name) == 0) { aData = index; return; }
45 }
46 int get_loc(const char* name) const {
47 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
48 if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; }
49 return -1;
50 }
51} attrib_locations;
52vec4_scalar vTransformBounds;
53vec4_scalar v_color;
54ivec4_scalar v_flags;
55vec4_scalar v_backdrop_uv_bounds;
56vec4_scalar v_src_uv_bounds;
57ivec2_scalar v_op;
58sampler2D sColor0;
59sampler2D sColor1;
60sampler2D sGpuBufferF;
61isampler2D sGpuBufferI;
62sampler2D sRenderTasks;
63sampler2D sTransformPalette;
64mat4_scalar uTransform;
65void bind_textures() {
66 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
67 sColor1 = lookup_sampler(&samplers.sColor1_impl, samplers.sColor1_slot);
68 sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot);
69 sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot);
70 sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot);
71 sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot);
72}
73};
74struct ps_quad_mix_blend_TEXTURE_2D_vert : VertexShaderImpl, ps_quad_mix_blend_TEXTURE_2D_common {
75private:
76typedef ps_quad_mix_blend_TEXTURE_2D_vert Self;
77// mat4_scalar uTransform;
78vec2 aPosition;
79// sampler2D sColor0;
80// sampler2D sColor1;
81// sampler2D sColor2;
82struct RectWithSize_scalar {
83vec2_scalar p0;
84vec2_scalar size;
85RectWithSize_scalar() = default;
86RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
87};
88struct RectWithSize {
89vec2 p0;
90vec2 size;
91RectWithSize() = default;
92RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
93RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
94}
95IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
96}
97friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
98if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
99}};
100struct RectWithEndpoint_scalar {
101vec2_scalar p0;
102vec2_scalar p1;
103RectWithEndpoint_scalar() = default;
104RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
105};
106struct RectWithEndpoint {
107vec2 p0;
108vec2 p1;
109RectWithEndpoint() = default;
110RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
111RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
112}
113IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
114}
115friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
116if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
117}};
118// vec4_scalar vTransformBounds;
119// sampler2D sTransformPalette;
120struct Transform_scalar {
121mat4_scalar m;
122mat4_scalar inv_m;
123bool is_axis_aligned;
124Transform_scalar() = default;
125Transform_scalar(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
126};
127struct Transform {
128mat4 m;
129mat4 inv_m;
130Bool is_axis_aligned;
131Transform() = default;
132Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
133Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){
134}
135IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){
136}
137friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform(
138if_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));
139}};
140// sampler2D sRenderTasks;
141struct RenderTaskData_scalar {
142RectWithEndpoint_scalar task_rect;
143vec4_scalar user_data;
144RenderTaskData_scalar() = default;
145RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){}
146};
147struct RenderTaskData {
148RectWithEndpoint task_rect;
149vec4 user_data;
150RenderTaskData() = default;
151RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){}
152RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){
153}
154IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){
155}
156friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData(
157if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data));
158}};
159struct PictureTask_scalar {
160RectWithEndpoint_scalar task_rect;
161float device_pixel_scale;
162vec2_scalar content_origin;
163PictureTask_scalar() = default;
164PictureTask_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){}
165};
166struct PictureTask {
167RectWithEndpoint task_rect;
168Float device_pixel_scale;
169vec2 content_origin;
170PictureTask() = default;
171PictureTask(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
172PictureTask(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){
173}
174IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){
175}
176friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask(
177if_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));
178}};
179struct ClipArea_scalar {
180RectWithEndpoint_scalar task_rect;
181float device_pixel_scale;
182vec2_scalar screen_origin;
183ClipArea_scalar() = default;
184ClipArea_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){}
185};
186struct ClipArea {
187RectWithEndpoint task_rect;
188Float device_pixel_scale;
189vec2 screen_origin;
190ClipArea() = default;
191ClipArea(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
192ClipArea(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){
193}
194IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){
195}
196friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea(
197if_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));
198}};
199// sampler2D sGpuBufferF;
200// isampler2D sGpuBufferI;
201// vec4_scalar v_color;
202// ivec4_scalar v_flags;
203ivec4_scalar aData;
204struct QuadSegment_scalar {
205RectWithEndpoint_scalar rect;
206RectWithEndpoint_scalar uv_rect;
207QuadSegment_scalar() = default;
208QuadSegment_scalar(RectWithEndpoint_scalar rect, RectWithEndpoint_scalar uv_rect) : rect(rect), uv_rect(uv_rect){}
209};
210struct QuadSegment {
211RectWithEndpoint rect;
212RectWithEndpoint uv_rect;
213QuadSegment() = default;
214QuadSegment(RectWithEndpoint rect, RectWithEndpoint uv_rect) : rect(rect), uv_rect(uv_rect){}
215QuadSegment(RectWithEndpoint_scalar rect, RectWithEndpoint_scalar uv_rect):rect(rect),uv_rect(uv_rect){
216}
217IMPLICIT QuadSegment(QuadSegment_scalar s):rect(s.rect),uv_rect(s.uv_rect){
218}
219friend QuadSegment if_then_else(I32 c, QuadSegment t, QuadSegment e) { return QuadSegment(
220if_then_else(c, t.rect, e.rect), if_then_else(c, t.uv_rect, e.uv_rect));
221}};
222struct PrimitiveInfo_scalar {
223vec2_scalar local_pos;
224RectWithEndpoint_scalar local_prim_rect;
225RectWithEndpoint_scalar local_clip_rect;
226QuadSegment_scalar segment;
227int32_t edge_flags;
228int32_t quad_flags;
229ivec2_scalar pattern_input;
230PrimitiveInfo_scalar() = default;
231PrimitiveInfo_scalar(vec2_scalar local_pos, RectWithEndpoint_scalar local_prim_rect, RectWithEndpoint_scalar local_clip_rect, QuadSegment_scalar segment, int32_t edge_flags, int32_t quad_flags, ivec2_scalar pattern_input) : local_pos(local_pos), local_prim_rect(local_prim_rect), local_clip_rect(local_clip_rect), segment(segment), edge_flags(edge_flags), quad_flags(quad_flags), pattern_input(pattern_input){}
232};
233struct PrimitiveInfo {
234vec2 local_pos;
235RectWithEndpoint local_prim_rect;
236RectWithEndpoint local_clip_rect;
237QuadSegment segment;
238I32 edge_flags;
239I32 quad_flags;
240ivec2 pattern_input;
241PrimitiveInfo() = default;
242PrimitiveInfo(vec2 local_pos, RectWithEndpoint local_prim_rect, RectWithEndpoint local_clip_rect, QuadSegment segment, I32 edge_flags, I32 quad_flags, ivec2 pattern_input) : local_pos(local_pos), local_prim_rect(local_prim_rect), local_clip_rect(local_clip_rect), segment(segment), edge_flags(edge_flags), quad_flags(quad_flags), pattern_input(pattern_input){}
243PrimitiveInfo(vec2_scalar local_pos, RectWithEndpoint_scalar local_prim_rect, RectWithEndpoint_scalar local_clip_rect, QuadSegment_scalar segment, int32_t edge_flags, int32_t quad_flags, ivec2_scalar pattern_input):local_pos(local_pos),local_prim_rect(local_prim_rect),local_clip_rect(local_clip_rect),segment(segment),edge_flags(edge_flags),quad_flags(quad_flags),pattern_input(pattern_input){
244}
245IMPLICIT PrimitiveInfo(PrimitiveInfo_scalar s):local_pos(s.local_pos),local_prim_rect(s.local_prim_rect),local_clip_rect(s.local_clip_rect),segment(s.segment),edge_flags(s.edge_flags),quad_flags(s.quad_flags),pattern_input(s.pattern_input){
246}
247friend PrimitiveInfo if_then_else(I32 c, PrimitiveInfo t, PrimitiveInfo e) { return PrimitiveInfo(
248if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.local_prim_rect, e.local_prim_rect), if_then_else(c, t.local_clip_rect, e.local_clip_rect), 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));
249}};
250struct QuadPrimitive_scalar {
251RectWithEndpoint_scalar bounds;
252RectWithEndpoint_scalar pattern_rect;
253RectWithEndpoint_scalar uv_rect;
254vec4_scalar pattern_scale_offset;
255vec4_scalar color;
256QuadPrimitive_scalar() = default;
257QuadPrimitive_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){}
258};
259struct QuadPrimitive {
260RectWithEndpoint bounds;
261RectWithEndpoint pattern_rect;
262RectWithEndpoint uv_rect;
263vec4 pattern_scale_offset;
264vec4 color;
265QuadPrimitive() = default;
266QuadPrimitive(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){}
267QuadPrimitive(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){
268}
269IMPLICIT 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){
270}
271friend QuadPrimitive if_then_else(I32 c, QuadPrimitive t, QuadPrimitive e) { return QuadPrimitive(
272if_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));
273}};
274struct QuadHeader_scalar {
275int32_t transform_id;
276int32_t z_id;
277ivec2_scalar pattern_input;
278QuadHeader_scalar() = default;
279QuadHeader_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){}
280};
281struct QuadHeader {
282I32 transform_id;
283I32 z_id;
284ivec2 pattern_input;
285QuadHeader() = default;
286QuadHeader(I32 transform_id, I32 z_id, ivec2 pattern_input) : transform_id(transform_id), z_id(z_id), pattern_input(pattern_input){}
287QuadHeader(int32_t transform_id, int32_t z_id, ivec2_scalar pattern_input):transform_id(transform_id),z_id(z_id),pattern_input(pattern_input){
288}
289IMPLICIT QuadHeader(QuadHeader_scalar s):transform_id(s.transform_id),z_id(s.z_id),pattern_input(s.pattern_input){
290}
291friend QuadHeader if_then_else(I32 c, QuadHeader t, QuadHeader e) { return QuadHeader(
292if_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));
293}};
294struct QuadInstance_scalar {
295int32_t prim_address_i;
296int32_t prim_address_f;
297int32_t quad_flags;
298int32_t edge_flags;
299int32_t part_index;
300int32_t segment_index;
301int32_t picture_task_address;
302QuadInstance_scalar() = default;
303QuadInstance_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){}
304};
305struct QuadInstance {
306I32 prim_address_i;
307I32 prim_address_f;
308I32 quad_flags;
309I32 edge_flags;
310I32 part_index;
311I32 segment_index;
312I32 picture_task_address;
313QuadInstance() = default;
314QuadInstance(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){}
315QuadInstance(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){
316}
317IMPLICIT 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){
318}
319friend QuadInstance if_then_else(I32 c, QuadInstance t, QuadInstance e) { return QuadInstance(
320if_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));
321}};
322struct VertexInfo_scalar {
323vec2_scalar local_pos;
324VertexInfo_scalar() = default;
325explicit VertexInfo_scalar(vec2_scalar local_pos) : local_pos(local_pos){}
326};
327struct VertexInfo {
328vec2 local_pos;
329VertexInfo() = default;
330explicit VertexInfo(vec2 local_pos) : local_pos(local_pos){}
331explicit VertexInfo(vec2_scalar local_pos):local_pos(local_pos){
332}
333IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos){
334}
335friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo(
336if_then_else(c, t.local_pos, e.local_pos));
337}};
338vec2 v_backdrop_uv;
339// vec4_scalar v_backdrop_uv_bounds;
340vec2 v_src_uv;
341// vec4_scalar v_src_uv_bounds;
342// ivec2_scalar v_op;
343QuadInstance_scalar decode_instance() {
344 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);
345 return qi;
346}
347ivec2_scalar get_gpu_buffer_uv(int32_t address) {
348 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
349}
350ivec4_scalar fetch_from_gpu_buffer_1i(int32_t address) {
351 ivec2_scalar uv = get_gpu_buffer_uv(address);
352 return texelFetch(sGpuBufferI, uv, 0);
353}
354QuadHeader_scalar fetch_header(int32_t address) {
355 ivec4_scalar header = fetch_from_gpu_buffer_1i(address);
356 QuadHeader_scalar qh = QuadHeader_scalar((header).x, (header).y, (header).sel(Z,W));
357 return qh;
358}
359Transform_scalar fetch_transform(int32_t id) {
360 Transform_scalar transform;
361 (transform).is_axis_aligned = ((id)>>(23))==(0);
362 int32_t index = (id)&(4194303);
363 ivec2_scalar uv = make_ivec2(make_int((8u)*((make_uint(index))%((1024u)/(8u)))), make_int((make_uint(index))/((1024u)/(8u))));
364 ivec2_scalar uv0 = make_ivec2(((uv).x)+(0), (uv).y);
365 auto sTransformPalette_uv0_fetch = texelFetchPtr(sTransformPalette, uv0, 0, 7, 0, 0);
366 (transform).m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 0, 0);
367 (transform).m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 1, 0);
368 (transform).m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 2, 0);
369 (transform).m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 3, 0);
370 (transform).inv_m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 4, 0);
371 (transform).inv_m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 5, 0);
372 (transform).inv_m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 6, 0);
373 (transform).inv_m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 7, 0);
374 return transform;
375}
376RenderTaskData_scalar fetch_render_task_data(int32_t index) {
377 ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
378 auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0);
379 vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0);
380 vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0);
381 RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W));
382 RenderTaskData_scalar data = RenderTaskData_scalar(task_rect, texel1);
383 return data;
384}
385PictureTask_scalar fetch_picture_task(int32_t address) {
386 RenderTaskData_scalar task_data = fetch_render_task_data(address);
387 PictureTask_scalar task = PictureTask_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
388 return task;
389}
390Array<vec4_scalar,5> fetch_from_gpu_buffer_5f_direct(ivec2_scalar uv) {
391 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 4, 0, 0);
392 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)}};
393}
394Array<vec4_scalar,5> fetch_from_gpu_buffer_5f(int32_t address) {
395 ivec2_scalar uv = get_gpu_buffer_uv(address);
396 return fetch_from_gpu_buffer_5f_direct(uv);
397}
398QuadPrimitive_scalar fetch_primitive(int32_t index) {
399 QuadPrimitive_scalar prim;
400 Array<vec4_scalar,5> texels = fetch_from_gpu_buffer_5f(index);
401 (prim).bounds = RectWithEndpoint_scalar((texels[0]).sel(X,Y), (texels[0]).sel(Z,W));
402 (prim).pattern_rect = RectWithEndpoint_scalar((texels[1]).sel(X,Y), (texels[1]).sel(Z,W));
403 (prim).uv_rect = RectWithEndpoint_scalar((texels[2]).sel(X,Y), (texels[2]).sel(Z,W));
404 (prim).pattern_scale_offset = texels[3];
405 (prim).color = texels[4];
406 return prim;
407}
408Array<vec4_scalar,2> fetch_from_gpu_buffer_2f_direct(ivec2_scalar uv) {
409 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 1, 0, 0);
410 return Array<vec4_scalar,2>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0)}};
411}
412Array<vec4_scalar,2> fetch_from_gpu_buffer_2f(int32_t address) {
413 ivec2_scalar uv = get_gpu_buffer_uv(address);
414 return fetch_from_gpu_buffer_2f_direct(uv);
415}
416QuadSegment_scalar fetch_segment(int32_t base, int32_t index) {
417 QuadSegment_scalar seg;
418 Array<vec4_scalar,2> texels = fetch_from_gpu_buffer_2f(((base)+(5))+((index)*(2)));
419 (seg).rect = RectWithEndpoint_scalar((texels[0]).sel(X,Y), (texels[0]).sel(Z,W));
420 (seg).uv_rect = RectWithEndpoint_scalar((texels[1]).sel(X,Y), (texels[1]).sel(Z,W));
421 return seg;
422}
423vec2 rect_clamp(RectWithEndpoint_scalar rect, vec2 pt) {
424 return clamp(pt, (rect).p0, (rect).p1);
425}
426VertexInfo write_vertex(vec2 local_pos, float z, Transform_scalar transform, vec2_scalar content_origin, RectWithEndpoint_scalar task_rect, int32_t quad_flags) {
427 VertexInfo vi;
428 vec4 transformed = ((transform).m)*(make_vec4(local_pos, 0.f, 1.f));
429 vec2 device_pos = (transformed).sel(X,Y);
430 Float w = (transformed).w;
431 if (((quad_flags)&(2))!=(0)) {
432 {
433 RectWithEndpoint_scalar device_clip_rect = RectWithEndpoint_scalar(content_origin, ((content_origin)+((task_rect).p1))-((task_rect).p0));
434 device_pos = rect_clamp(device_clip_rect, device_pos);
435 (vi).local_pos = (((transform).inv_m)*(make_vec4(device_pos, 0.f, 1.f))).sel(X,Y);
436 }
437 } else {
438 (vi).local_pos = local_pos;
439 }
440 vec2_scalar final_offset = (-(content_origin))+((task_rect).p0);
441 gl_Position = (uTransform)*(make_vec4((device_pos)+((final_offset)*(w)), (z)*(w), w));
442 return vi;
443}
444vec2_scalar scale_offset_map_point(vec4_scalar scale_offset, vec2_scalar p) {
445 return ((p)*((scale_offset).sel(X,Y)))+((scale_offset).sel(Z,W));
446}
447RectWithEndpoint_scalar scale_offset_map_rect(vec4_scalar scale_offset, RectWithEndpoint_scalar r) {
448 vec2_scalar p0 = scale_offset_map_point(scale_offset, (r).p0);
449 vec2_scalar p1 = scale_offset_map_point(scale_offset, (r).p1);
450 return RectWithEndpoint_scalar(min(p0, p1), max(p0, p1));
451}
452vec2 scale_offset_map_point(vec4_scalar scale_offset, vec2 p) {
453 return ((p)*((scale_offset).sel(X,Y)))+((scale_offset).sel(Z,W));
454}
455PrimitiveInfo quad_primive_info(void) {
456 QuadInstance_scalar qi = decode_instance();
457 QuadHeader_scalar qh = fetch_header((qi).prim_address_i);
458 Transform_scalar transform = fetch_transform((qh).transform_id);
459 PictureTask_scalar task = fetch_picture_task((qi).picture_task_address);
460 QuadPrimitive_scalar prim = fetch_primitive((qi).prim_address_f);
461 float z = make_float((qh).z_id);
462 QuadSegment_scalar seg;
463 if (((qi).segment_index)==(255)) {
464 {
465 (seg).rect = (prim).bounds;
466 (seg).uv_rect = (prim).uv_rect;
467 }
468 } else {
469 seg = fetch_segment((qi).prim_address_f, (qi).segment_index);
470 }
471 RectWithEndpoint_scalar local_coverage_rect = (seg).rect;
472 (local_coverage_rect).p0 = max((local_coverage_rect).p0, ((prim).bounds).p0);
473 (local_coverage_rect).p1 = min((local_coverage_rect).p1, ((prim).bounds).p1);
474 (local_coverage_rect).p1 = max((local_coverage_rect).p0, (local_coverage_rect).p1);
475 float aa_left = (((qi).edge_flags)&(1))!=(0) ? 1.f : 0.f;
476 float aa_top = (((qi).edge_flags)&(2))!=(0) ? 1.f : 0.f;
477 float aa_right = (((qi).edge_flags)&(4))!=(0) ? 1.f : 0.f;
478 float aa_bottom = (((qi).edge_flags)&(8))!=(0) ? 1.f : 0.f;
479 switch ((qi).part_index) {
480 case 1:
481 ((local_coverage_rect).p1).x = (((local_coverage_rect).p0).x)+(2.f);
482 swgl_antiAlias(1)do { swgl_AAEdgeMask = calcAAEdgeMask(1); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
483 break;
484 case 2:
485 ((local_coverage_rect).p0).x += (aa_left)*(2.f);
486 ((local_coverage_rect).p1).x -= (aa_right)*(2.f);
487 ((local_coverage_rect).p1).y = (((local_coverage_rect).p0).y)+(2.f);
488 swgl_antiAlias(2)do { swgl_AAEdgeMask = calcAAEdgeMask(2); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
489 break;
490 case 3:
491 ((local_coverage_rect).p0).x = (((local_coverage_rect).p1).x)-(2.f);
492 swgl_antiAlias(4)do { swgl_AAEdgeMask = calcAAEdgeMask(4); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
493 break;
494 case 4:
495 ((local_coverage_rect).p0).x += (aa_left)*(2.f);
496 ((local_coverage_rect).p1).x -= (aa_right)*(2.f);
497 ((local_coverage_rect).p0).y = (((local_coverage_rect).p1).y)-(2.f);
498 swgl_antiAlias(8)do { swgl_AAEdgeMask = calcAAEdgeMask(8); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
499 break;
500 case 0:
501 ((local_coverage_rect).p0).x += (aa_left)*(2.f);
502 ((local_coverage_rect).p1).x -= (aa_right)*(2.f);
503 ((local_coverage_rect).p0).y += (aa_top)*(2.f);
504 ((local_coverage_rect).p1).y -= (aa_bottom)*(2.f);
505 break;
506 case 5:
507 default:
508 swgl_antiAlias((qi).edge_flags)do { swgl_AAEdgeMask = calcAAEdgeMask((qi).edge_flags); if (swgl_AAEdgeMask
) { swgl_ClipFlags |= SWGL_CLIP_FLAG_AA; } } while (0)
;
509 break;
510 }
511 vec2 local_pos = mix((local_coverage_rect).p0, (local_coverage_rect).p1, aPosition);
512 VertexInfo vi = write_vertex(local_pos, z, transform, (task).content_origin, (task).task_rect, (qi).quad_flags);
513 v_color = (prim).color;
514 vec4_scalar pattern_tx = (prim).pattern_scale_offset;
515 (seg).rect = scale_offset_map_rect(pattern_tx, (seg).rect);
516 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);
517}
518void antialiasing_vertex(PrimitiveInfo prim) {
519}
520ivec2 get_gpu_buffer_uv(I32 address) {
521 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
522}
523vec4 fetch_from_gpu_buffer_1f(I32 address) {
524 ivec2 uv = get_gpu_buffer_uv(address);
525 return texelFetch(sGpuBufferF, uv, 0);
526}
527vec2 rect_size(RectWithEndpoint rect) {
528 return ((rect).p1)-((rect).p0);
529}
530void write_uv(vec2 f, RectWithEndpoint uv_rect, vec2_scalar texture_size, vec2& out_uv, vec4& out_bounds) {
531 vec2 uv = mix((uv_rect).p0, (uv_rect).p1, f);
532 out_uv = (uv)/(texture_size);
533 out_bounds = (make_vec4(((uv_rect).p0)+(make_vec2(0.5f)), ((uv_rect).p1)-(make_vec2(0.5f))))/((texture_size).sel(X,Y,X,Y));
534}
535void pattern_vertex(PrimitiveInfo info) {
536 vec4 src_uv_rect_raw = fetch_from_gpu_buffer_1f(((info).pattern_input).x);
537 RectWithEndpoint src_uv_rect = RectWithEndpoint((src_uv_rect_raw).sel(X,Y), (src_uv_rect_raw).sel(Z,W));
538 (v_op).x = force_scalar(((info).pattern_input).y);
539 RectWithEndpoint rect = (info).local_prim_rect;
540 vec2 f = (((info).local_pos)-((rect).p0))/(rect_size(rect));
541 { vec4 _arg4_ = v_backdrop_uv_bounds; write_uv(f, ((info).segment).uv_rect, make_vec2(textureSize(sColor0, 0)), v_backdrop_uv, _arg4_); v_backdrop_uv_bounds = force_scalar(_arg4_); };
542 { vec4 _arg4_ = v_src_uv_bounds; write_uv(f, src_uv_rect, make_vec2(textureSize(sColor1, 0)), v_src_uv, _arg4_); v_src_uv_bounds = force_scalar(_arg4_); };
543}
544ALWAYS_INLINE__attribute__((always_inline)) inline void main() {
545 PrimitiveInfo prim = quad_primive_info();
546 auto _c2_ = (((prim).quad_flags)&(16))!=(0);
547 {
548 if (_c2_[0]) { (v_flags).z = 1; };
549 }
550 {
551 if (~(_c2_)[0]) { (v_flags).z = 0; };
552 }
553 antialiasing_vertex(prim);
554 pattern_vertex(prim);
555}
556static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
557 Self* self = (Self*)impl;
558 if (self->samplers.set_slot(index, value)) return;
559 switch (index) {
560 case 6:
561 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
562 break;
563 case 7:
564 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
565 break;
566 case 3:
567 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
568 break;
569 case 4:
570 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
571 break;
572 case 2:
573 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
574 break;
575 case 1:
576 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
577 break;
578 case 5:
579 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
580 break;
581 }
582}
583static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
584 Self* self = (Self*)impl;
585 switch (index) {
586 case 6:
587 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
588 break;
589 case 7:
590 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
591 break;
592 case 3:
593 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
594 break;
595 case 4:
596 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
597 break;
598 case 2:
599 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
600 break;
601 case 1:
602 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
603 break;
604 case 5:
605 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
606 break;
607 }
608}
609static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
610 Self* self = (Self*)impl;
611 switch (index) {
612 case 6:
613 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
614 break;
615 case 7:
616 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
617 break;
618 case 3:
619 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
620 break;
621 case 4:
622 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
623 break;
624 case 2:
625 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
626 break;
627 case 1:
628 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
629 break;
630 case 5:
631 self->uTransform = mat4_scalar::load_from_ptr(value);
632 break;
633 }
634}
635static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
636 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
637 load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count);
638}
639public:
640struct InterpOutputs {
641vec2_scalar v_backdrop_uv;
642vec2_scalar v_src_uv;
643};
644private:
645ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
646 for(int n = 0; n < 4; n++) {
647 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
648 dest->v_backdrop_uv = get_nth(v_backdrop_uv, n);
649 dest->v_src_uv = get_nth(v_src_uv, n);
650 dest_ptr += stride;
651 }
652}
653static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
654 Self* self = (Self*)impl;
655 self->main();
656 self->store_interp_outputs(interps, interp_stride);
657}
658static void init_batch(VertexShaderImpl* impl) {
659 Self* self = (Self*)impl; self->bind_textures(); }
660public:
661ps_quad_mix_blend_TEXTURE_2D_vert() {
662 set_uniform_1i_func = &set_uniform_1i;
663 set_uniform_4fv_func = &set_uniform_4fv;
664 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
665 init_batch_func = &init_batch;
666 load_attribs_func = &load_attribs;
667 run_primitive_func = &run;
668}
669};
670
671
672struct ps_quad_mix_blend_TEXTURE_2D_frag : FragmentShaderImpl, ps_quad_mix_blend_TEXTURE_2D_vert {
673private:
674typedef ps_quad_mix_blend_TEXTURE_2D_frag Self;
675#define oFragColorgl_FragColor gl_FragColor
676// vec4 oFragColor;
677// sampler2D sColor0;
678// sampler2D sColor1;
679// sampler2D sColor2;
680struct RectWithSize_scalar {
681vec2_scalar p0;
682vec2_scalar size;
683RectWithSize_scalar() = default;
684RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
685};
686struct RectWithSize {
687vec2 p0;
688vec2 size;
689RectWithSize() = default;
690RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
691RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
692}
693IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
694}
695friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
696if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
697}};
698struct RectWithEndpoint_scalar {
699vec2_scalar p0;
700vec2_scalar p1;
701RectWithEndpoint_scalar() = default;
702RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
703};
704struct RectWithEndpoint {
705vec2 p0;
706vec2 p1;
707RectWithEndpoint() = default;
708RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
709RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
710}
711IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
712}
713friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
714if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
715}};
716// vec4_scalar vTransformBounds;
717// sampler2D sGpuBufferF;
718// isampler2D sGpuBufferI;
719// vec4_scalar v_color;
720// ivec4_scalar v_flags;
721vec2 v_backdrop_uv;
722// vec4_scalar v_backdrop_uv_bounds;
723vec2 v_src_uv;
724// vec4_scalar v_src_uv_bounds;
725// ivec2_scalar v_op;
726int32_t static constexpr MIX_BLEND_MULTIPLY = 1;
727int32_t static constexpr MIX_BLEND_SCREEN = 2;
728int32_t static constexpr MIX_BLEND_OVERLAY = 3;
729int32_t static constexpr MIX_BLEND_DARKEN = 4;
730int32_t static constexpr MIX_BLEND_LIGHTEN = 5;
731int32_t static constexpr MIX_BLEND_COLOR_DODGE = 6;
732int32_t static constexpr MIX_BLEND_COLOR_BURN = 7;
733int32_t static constexpr MIX_BLEND_HARD_LIGHT = 8;
734int32_t static constexpr MIX_BLEND_SOFT_LIGHT = 9;
735int32_t static constexpr MIX_BLEND_DIFFERENCE = 10;
736int32_t static constexpr MIX_BLEND_EXCLUSION = 11;
737int32_t static constexpr MIX_BLEND_HUE = 12;
738int32_t static constexpr MIX_BLEND_SAUTURATION = 13;
739int32_t static constexpr MIX_BLEND_COLOR = 14;
740int32_t static constexpr MIX_BLEND_lumINOSITY = 15;
741int32_t static constexpr MIX_BLEND_PLUS_LIGHTER = 16;
742float antialiasing_fragment() {
743 float alpha = 1.f;
744 return alpha;
745}
746vec3 multiply(vec3 cb, vec3 cs) {
747 return (cb)*(cs);
748}
749vec3 screen(vec3 cb, vec3 cs) {
750 return ((cb)+(cs))-((cb)*(cs));
751}
752vec3 hard_light(vec3 cb, vec3 cs) {
753 vec3 m = multiply(cb, (2.f)*(cs));
754 vec3 s = screen(cb, ((2.f)*(cs))-(1.f));
755 vec3_scalar edge = make_vec3(0.5f, 0.5f, 0.5f);
756 return mix(m, s, step(edge, cs));
757}
758Float color_dodge(Float cb, Float cs) {
759 I32 ret_mask = ~0;
760 Float ret;
761 auto _c8_ = (cb)==(0.f);
762 ret = 0.f;
763 ret_mask = ~I32(_c8_);
764 auto _c9_ = (cs)==(1.f);
765 auto _c10_ = (~(_c8_))&(_c9_);
766 ret = if_then_else(ret_mask & I32(_c10_), 1.f, ret);
767 ret_mask &= ~I32(_c10_);
768 _c9_ = (~(_c8_))&(~(_c9_));
769 ret = if_then_else(ret_mask & I32(_c9_), min(1.f, (cb)/((1.f)-(cs))), ret);
770 ret_mask &= ~I32(_c9_);
771 return ret;
772}
773Float color_burn(Float cb, Float cs) {
774 I32 ret_mask = ~0;
775 Float ret;
776 auto _c14_ = (cb)==(1.f);
777 ret = 1.f;
778 ret_mask = ~I32(_c14_);
779 auto _c15_ = (cs)==(0.f);
780 auto _c16_ = (~(_c14_))&(_c15_);
781 ret = if_then_else(ret_mask & I32(_c16_), 0.f, ret);
782 ret_mask &= ~I32(_c16_);
783 _c15_ = (~(_c14_))&(~(_c15_));
784 ret = if_then_else(ret_mask & I32(_c15_), (1.f)-(min(1.f, ((1.f)-(cb))/(cs))), ret);
785 ret_mask &= ~I32(_c15_);
786 return ret;
787}
788Float soft_light(Float cb, Float cs) {
789 I32 ret_mask = ~0;
790 Float ret;
791 auto _c20_ = (cs)<=(0.5f);
792 {
793 ret = (cb)-((((1.f)-((2.f)*(cs)))*(cb))*((1.f)-(cb)));
794 ret_mask = ~I32(_c20_);
795 }
796 {
797 Float D;
798 auto _c21_ = (cb)<=(0.25f);
799 auto _c22_ = (~(_c20_))&(_c21_);
800 D = if_then_else(_c22_,(((((16.f)*(cb))-(12.f))*(cb))+(4.f))*(cb),D);
801 _c21_ = (~(_c20_))&(~(_c21_));
802 D = if_then_else(_c21_,sqrt__glsl_sqrt(cb),D);
803 ret = if_then_else(ret_mask & I32(~(_c20_)), (cb)+((((2.f)*(cs))-(1.f))*((D)-(cb))), ret);
804 ret_mask &= ~I32(~(_c20_));
Value stored to 'ret_mask' is never read
805 }
806 return ret;
807}
808vec3 difference(vec3 cb, vec3 cs) {
809 return abs__glsl_abs((cb)-(cs));
810}
811Float lum(vec3 c) {
812 vec3_scalar f = make_vec3(0.3f, 0.59f, 0.11f);
813 return dot(c, f);
814}
815vec3 clip_color(vec3 C) {
816 Float L = lum(C);
817 Float n = min((C).x, min((C).y, (C).z));
818 Float x = max((C).x, max((C).y, (C).z));
819 auto _c25_ = ((n)<(0.f))&&((L)!=(n));
820 C = if_then_else(_c25_,(L)+((((C)-(L))*(L))/((L)-(n))),C);
821 auto _c26_ = ((x)>(1.f))&&((x)!=(L));
822 C = if_then_else(_c26_,(L)+((((C)-(L))*((1.f)-(L)))/((x)-(L))),C);
823 return C;
824}
825vec3 set_lum(vec3 C, Float l) {
826 Float d = (l)-(lum(C));
827 return clip_color((C)+(d));
828}
829void set_sat_inner(Float& Cmin, Float& Cmid, Float& Cmax, Float s, I32 _cond_mask_) {
830 auto _c47_ = (Cmax)>(Cmin);
831 auto _c48_ = (_cond_mask_)&(_c47_);
832 {
833 Cmid = if_then_else(_c48_,(((Cmid)-(Cmin))*(s))/((Cmax)-(Cmin)),Cmid);
834 Cmax = if_then_else(_c48_,s,Cmax);
835 }
836 _c47_ = (_cond_mask_)&(~(_c47_));
837 {
838 Cmid = if_then_else(_c47_,0.f,Cmid);
839 Cmax = if_then_else(_c47_,0.f,Cmax);
840 }
841 Cmin = if_then_else(_cond_mask_,0.f,Cmin);
842}
843vec3 set_sat(vec3 C, Float s) {
844 auto _c36_ = ((C).x)<=((C).y);
845 {
846 auto _c37_ = ((C).y)<=((C).z);
847 auto _c38_ = (_c36_)&(_c37_);
848 {
849 set_sat_inner((C).x, (C).y, (C).z, s, _c38_);
850 }
851 _c37_ = (_c36_)&(~(_c37_));
852 {
853 auto _c39_ = ((C).x)<=((C).z);
854 auto _c40_ = (_c37_)&(_c39_);
855 {
856 set_sat_inner((C).x, (C).z, (C).y, s, _c40_);
857 }
858 _c39_ = (_c37_)&(~(_c39_));
859 {
860 set_sat_inner((C).z, (C).x, (C).y, s, _c39_);
861 }
862 }
863 }
864 {
865 auto _c41_ = ((C).x)<=((C).z);
866 auto _c42_ = (~(_c36_))&(_c41_);
867 {
868 set_sat_inner((C).y, (C).x, (C).z, s, _c42_);
869 }
870 _c41_ = (~(_c36_))&(~(_c41_));
871 {
872 auto _c43_ = ((C).y)<=((C).z);
873 auto _c44_ = (_c41_)&(_c43_);
874 {
875 set_sat_inner((C).y, (C).z, (C).x, s, _c44_);
876 }
877 _c43_ = (_c41_)&(~(_c43_));
878 {
879 set_sat_inner((C).z, (C).y, (C).x, s, _c43_);
880 }
881 }
882 }
883 return C;
884}
885Float sat(vec3 c) {
886 return (max((c).x, max((c).y, (c).z)))-(min((c).x, min((c).y, (c).z)));
887}
888vec3 hue(vec3 cb, vec3 cs) {
889 return set_lum(set_sat(cs, sat(cb)), lum(cb));
890}
891vec3 saturation(vec3 cb, vec3 cs) {
892 return set_lum(set_sat(cb, sat(cs)), lum(cb));
893}
894vec3 luminosity(vec3 cb, vec3 cs) {
895 return set_lum(cb, lum(cs));
896}
897vec4 pattern_fragment(vec4_scalar base_color) {
898 vec2 backdrop_uv = clamp(v_backdrop_uv, (v_backdrop_uv_bounds).sel(X,Y), (v_backdrop_uv_bounds).sel(Z,W));
899 vec2 src_uv = clamp(v_src_uv, (v_src_uv_bounds).sel(X,Y), (v_src_uv_bounds).sel(Z,W));
900 vec4 cb = texture(sColor0, backdrop_uv);
901 vec4 cs = texture(sColor1, src_uv);
902 auto _c3_ = ((cb).w)!=(0.f);
903 {
904 (cb).lsel(R,G,B) = if_then_else(_c3_,(cb).sel(R,G,B)/(cb).w,(cb).sel(R,G,B));
905 }
906 auto _c4_ = ((cs).w)!=(0.f);
907 {
908 (cs).lsel(R,G,B) = if_then_else(_c4_,(cs).sel(R,G,B)/(cs).w,(cs).sel(R,G,B));
909 }
910 vec4 result = make_vec4(1.f, 1.f, 0.f, 1.f);
911 switch (((v_op).x)&(255)) {
912 case MIX_BLEND_MULTIPLY:
913 (result).lsel(R,G,B) = multiply((cb).sel(R,G,B), (cs).sel(R,G,B));
914 break;
915 case MIX_BLEND_OVERLAY:
916 (result).lsel(R,G,B) = hard_light((cs).sel(R,G,B), (cb).sel(R,G,B));
917 break;
918 case MIX_BLEND_DARKEN:
919 (result).lsel(R,G,B) = min((cs).sel(R,G,B), (cb).sel(R,G,B));
920 break;
921 case MIX_BLEND_LIGHTEN:
922 (result).lsel(R,G,B) = max((cs).sel(R,G,B), (cb).sel(R,G,B));
923 break;
924 case MIX_BLEND_COLOR_DODGE:
925 (result).x = color_dodge((cb).x, (cs).x);
926 (result).y = color_dodge((cb).y, (cs).y);
927 (result).z = color_dodge((cb).z, (cs).z);
928 break;
929 case MIX_BLEND_COLOR_BURN:
930 (result).x = color_burn((cb).x, (cs).x);
931 (result).y = color_burn((cb).y, (cs).y);
932 (result).z = color_burn((cb).z, (cs).z);
933 break;
934 case MIX_BLEND_HARD_LIGHT:
935 (result).lsel(R,G,B) = hard_light((cb).sel(R,G,B), (cs).sel(R,G,B));
936 break;
937 case MIX_BLEND_SOFT_LIGHT:
938 (result).x = soft_light((cb).x, (cs).x);
939 (result).y = soft_light((cb).y, (cs).y);
940 (result).z = soft_light((cb).z, (cs).z);
941 break;
942 case MIX_BLEND_DIFFERENCE:
943 (result).lsel(R,G,B) = difference((cb).sel(R,G,B), (cs).sel(R,G,B));
944 break;
945 case MIX_BLEND_HUE:
946 (result).lsel(R,G,B) = hue((cb).sel(R,G,B), (cs).sel(R,G,B));
947 break;
948 case MIX_BLEND_SAUTURATION:
949 (result).lsel(R,G,B) = saturation((cb).sel(R,G,B), (cs).sel(R,G,B));
950 break;
951 case MIX_BLEND_COLOR:
952 (result).lsel(R,G,B) = set_lum((cs).sel(R,G,B), lum((cb).sel(R,G,B)));
953 break;
954 case MIX_BLEND_lumINOSITY:
955 (result).lsel(R,G,B) = luminosity((cb).sel(R,G,B), (cs).sel(R,G,B));
956 break;
957 case MIX_BLEND_SCREEN:
958 case MIX_BLEND_EXCLUSION:
959 case MIX_BLEND_PLUS_LIGHTER:
960 break;
961 default:
962 break;
963 }
964 (result).lsel(R,G,B) = (((1.f)-((cb).w))*((cs).sel(R,G,B)))+(((cb).w)*((result).sel(R,G,B)));
965 (result).w = (cs).w;
966 (result).lsel(R,G,B) *= (result).w;
967 return (base_color)*(result);
968}
969ALWAYS_INLINE__attribute__((always_inline)) inline void main() {
970 vec4_scalar base_color = v_color;
971 base_color *= antialiasing_fragment();
972 vec4 output_color = pattern_fragment(base_color);
973 if (((v_flags).z)!=(0)) {
974 {
975 output_color = (output_color).sel(R,R,R,R);
976 }
977 }
978 oFragColorgl_FragColor = output_color;
979}
980typedef ps_quad_mix_blend_TEXTURE_2D_vert::InterpOutputs InterpInputs;
981InterpInputs interp_step;
982struct InterpPerspective {
983vec2 v_backdrop_uv;
984vec2 v_src_uv;
985};
986InterpPerspective interp_perspective;
987static 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_;
988 self->v_backdrop_uv = init_interp(init->v_backdrop_uv, step->v_backdrop_uv);
989 self->interp_step.v_backdrop_uv = step->v_backdrop_uv * 4.0f;
990 self->v_src_uv = init_interp(init->v_src_uv, step->v_src_uv);
991 self->interp_step.v_src_uv = step->v_src_uv * 4.0f;
992}
993static 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_;
994 Float w = 1.0f / self->gl_FragCoord.w;
995 self->interp_perspective.v_backdrop_uv = init_interp(init->v_backdrop_uv, step->v_backdrop_uv);
996 self->v_backdrop_uv = self->interp_perspective.v_backdrop_uv * w;
997 self->interp_step.v_backdrop_uv = step->v_backdrop_uv * 4.0f;
998 self->interp_perspective.v_src_uv = init_interp(init->v_src_uv, step->v_src_uv);
999 self->v_src_uv = self->interp_perspective.v_src_uv * w;
1000 self->interp_step.v_src_uv = step->v_src_uv * 4.0f;
1001}
1002ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
1003 float chunks = steps * 0.25f;
1004 v_backdrop_uv += interp_step.v_backdrop_uv * chunks;
1005 v_src_uv += interp_step.v_src_uv * chunks;
1006}
1007ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
1008 step_perspective(steps);
1009 float chunks = steps * 0.25f;
1010 Float w = 1.0f / gl_FragCoord.w;
1011 interp_perspective.v_backdrop_uv += interp_step.v_backdrop_uv * chunks;
1012 v_backdrop_uv = w * interp_perspective.v_backdrop_uv;
1013 interp_perspective.v_src_uv += interp_step.v_src_uv * chunks;
1014 v_src_uv = w * interp_perspective.v_src_uv;
1015}
1016static void run(FragmentShaderImpl* impl) {
1017 Self* self = (Self*)impl;
1018 self->main();
1019 self->step_interp_inputs();
1020}
1021static void skip(FragmentShaderImpl* impl, int steps) {
1022 Self* self = (Self*)impl;
1023 self->step_interp_inputs(steps);
1024}
1025static void run_perspective(FragmentShaderImpl* impl) {
1026 Self* self = (Self*)impl;
1027 self->main();
1028 self->step_perspective_inputs();
1029}
1030static void skip_perspective(FragmentShaderImpl* impl, int steps) {
1031 Self* self = (Self*)impl;
1032 self->step_perspective_inputs(steps);
1033}
1034public:
1035ps_quad_mix_blend_TEXTURE_2D_frag() {
1036 init_span_func = &read_interp_inputs;
1037 run_func = &run;
1038 skip_func = &skip;
1039 enable_perspective();
1040 init_span_w_func = &read_perspective_inputs;
1041 run_w_func = &run_perspective;
1042 skip_w_func = &skip_perspective;
1043}
1044};
1045
1046struct ps_quad_mix_blend_TEXTURE_2D_program : ProgramImpl, ps_quad_mix_blend_TEXTURE_2D_frag {
1047int get_uniform(const char *name) const override {
1048 if (strcmp("sColor0", name) == 0) { return 6; }
1049 if (strcmp("sColor1", name) == 0) { return 7; }
1050 if (strcmp("sGpuBufferF", name) == 0) { return 3; }
1051 if (strcmp("sGpuBufferI", name) == 0) { return 4; }
1052 if (strcmp("sRenderTasks", name) == 0) { return 2; }
1053 if (strcmp("sTransformPalette", name) == 0) { return 1; }
1054 if (strcmp("uTransform", name) == 0) { return 5; }
1055 return -1;
1056}
1057void bind_attrib(const char* name, int index) override {
1058 attrib_locations.bind_loc(name, index);
1059}
1060int get_attrib(const char* name) const override {
1061 return attrib_locations.get_loc(name);
1062}
1063size_t interpolants_size() const override { return sizeof(InterpOutputs); }
1064VertexShaderImpl* get_vertex_shader() override {
1065 return this;
1066}
1067FragmentShaderImpl* get_fragment_shader() override {
1068 return this;
1069}
1070const char* get_name() const override { return "ps_quad_mix_blend_TEXTURE_2D"; }
1071static ProgramImpl* loader() { return new ps_quad_mix_blend_TEXTURE_2D_program; }
1072};
1073
1074int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_MULTIPLY;
1075int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_SCREEN;
1076int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_OVERLAY;
1077int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_DARKEN;
1078int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_LIGHTEN;
1079int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_COLOR_DODGE;
1080int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_COLOR_BURN;
1081int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_HARD_LIGHT;
1082int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_SOFT_LIGHT;
1083int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_DIFFERENCE;
1084int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_EXCLUSION;
1085int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_HUE;
1086int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_SAUTURATION;
1087int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_COLOR;
1088int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_lumINOSITY;
1089int32_t constexpr ps_quad_mix_blend_TEXTURE_2D_frag::MIX_BLEND_PLUS_LIGHTER;