Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out/ps_split_composite.h
Warning:line 2, column 8
Excessive padding in 'struct ps_split_composite_common::Samplers' (32 padding bytes, where 0 is optimal). Optimal fields order: sGpuBufferI_impl, sPrimitiveHeadersI_impl, sClipMask_impl, sColor0_impl, sGpuBufferF_impl, sPrimitiveHeadersF_impl, sRenderTasks_impl, sTransformPalette_impl, sClipMask_slot, sColor0_slot, sGpuBufferF_slot, sGpuBufferI_slot, sPrimitiveHeadersF_slot, sPrimitiveHeadersI_slot, sRenderTasks_slot, sTransformPalette_slot, consider reordering the fields or adding explicit padding members

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_split_composite_common {
2struct Samplers {
Excessive padding in 'struct ps_split_composite_common::Samplers' (32 padding bytes, where 0 is optimal). Optimal fields order: sGpuBufferI_impl, sPrimitiveHeadersI_impl, sClipMask_impl, sColor0_impl, sGpuBufferF_impl, sPrimitiveHeadersF_impl, sRenderTasks_impl, sTransformPalette_impl, sClipMask_slot, sColor0_slot, sGpuBufferF_slot, sGpuBufferI_slot, sPrimitiveHeadersF_slot, sPrimitiveHeadersI_slot, sRenderTasks_slot, sTransformPalette_slot, consider reordering the fields or adding explicit padding members
3 sampler2D_impl sClipMask_impl;
4 int sClipMask_slot;
5 sampler2D_impl sColor0_impl;
6 int sColor0_slot;
7 sampler2D_impl sGpuBufferF_impl;
8 int sGpuBufferF_slot;
9 isampler2D_impl sGpuBufferI_impl;
10 int sGpuBufferI_slot;
11 sampler2D_impl sPrimitiveHeadersF_impl;
12 int sPrimitiveHeadersF_slot;
13 isampler2D_impl sPrimitiveHeadersI_impl;
14 int sPrimitiveHeadersI_slot;
15 sampler2D_impl sRenderTasks_impl;
16 int sRenderTasks_slot;
17 sampler2D_impl sTransformPalette_impl;
18 int sTransformPalette_slot;
19 bool set_slot(int index, int value) {
20 switch (index) {
21 case 8:
22 sClipMask_slot = value;
23 return true;
24 case 9:
25 sColor0_slot = value;
26 return true;
27 case 3:
28 sGpuBufferF_slot = value;
29 return true;
30 case 4:
31 sGpuBufferI_slot = value;
32 return true;
33 case 5:
34 sPrimitiveHeadersF_slot = value;
35 return true;
36 case 6:
37 sPrimitiveHeadersI_slot = value;
38 return true;
39 case 1:
40 sRenderTasks_slot = value;
41 return true;
42 case 2:
43 sTransformPalette_slot = value;
44 return true;
45 }
46 return false;
47 }
48} samplers;
49struct AttribLocations {
50 int aPosition = NULL_ATTRIB16;
51 int aData = NULL_ATTRIB16;
52 void bind_loc(const char* name, int index) {
53 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
54 if (strcmp("aData", name) == 0) { aData = index; return; }
55 }
56 int get_loc(const char* name) const {
57 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
58 if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; }
59 return -1;
60 }
61} attrib_locations;
62vec4_scalar vTransformBounds;
63vec2_scalar vPerspective;
64vec4_scalar vUvSampleBounds;
65sampler2D sClipMask;
66sampler2D sColor0;
67sampler2D sGpuBufferF;
68isampler2D sGpuBufferI;
69sampler2D sPrimitiveHeadersF;
70isampler2D sPrimitiveHeadersI;
71sampler2D sRenderTasks;
72sampler2D sTransformPalette;
73mat4_scalar uTransform;
74void bind_textures() {
75 sClipMask = lookup_sampler(&samplers.sClipMask_impl, samplers.sClipMask_slot);
76 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
77 sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot);
78 sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot);
79 sPrimitiveHeadersF = lookup_sampler(&samplers.sPrimitiveHeadersF_impl, samplers.sPrimitiveHeadersF_slot);
80 sPrimitiveHeadersI = lookup_isampler(&samplers.sPrimitiveHeadersI_impl, samplers.sPrimitiveHeadersI_slot);
81 sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot);
82 sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot);
83}
84};
85struct ps_split_composite_vert : VertexShaderImpl, ps_split_composite_common {
86private:
87typedef ps_split_composite_vert Self;
88// mat4_scalar uTransform;
89vec2 aPosition;
90// sampler2D sColor0;
91// sampler2D sColor1;
92// sampler2D sColor2;
93struct RectWithSize_scalar {
94vec2_scalar p0;
95vec2_scalar size;
96RectWithSize_scalar() = default;
97RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
98};
99struct RectWithSize {
100vec2 p0;
101vec2 size;
102RectWithSize() = default;
103RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
104RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
105}
106IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
107}
108friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
109if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
110}};
111struct RectWithEndpoint_scalar {
112vec2_scalar p0;
113vec2_scalar p1;
114RectWithEndpoint_scalar() = default;
115RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
116};
117struct RectWithEndpoint {
118vec2 p0;
119vec2 p1;
120RectWithEndpoint() = default;
121RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
122RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
123}
124IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
125}
126friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
127if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
128}};
129// sampler2D sRenderTasks;
130struct RenderTaskData_scalar {
131RectWithEndpoint_scalar task_rect;
132vec4_scalar user_data;
133RenderTaskData_scalar() = default;
134RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){}
135};
136struct RenderTaskData {
137RectWithEndpoint task_rect;
138vec4 user_data;
139RenderTaskData() = default;
140RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){}
141RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){
142}
143IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){
144}
145friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData(
146if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data));
147}};
148struct PictureTask_scalar {
149RectWithEndpoint_scalar task_rect;
150float device_pixel_scale;
151vec2_scalar content_origin;
152PictureTask_scalar() = default;
153PictureTask_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){}
154};
155struct PictureTask {
156RectWithEndpoint task_rect;
157Float device_pixel_scale;
158vec2 content_origin;
159PictureTask() = default;
160PictureTask(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
161PictureTask(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){
162}
163IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){
164}
165friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask(
166if_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));
167}};
168struct ClipArea_scalar {
169RectWithEndpoint_scalar task_rect;
170float device_pixel_scale;
171vec2_scalar screen_origin;
172ClipArea_scalar() = default;
173ClipArea_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){}
174};
175struct ClipArea {
176RectWithEndpoint task_rect;
177Float device_pixel_scale;
178vec2 screen_origin;
179ClipArea() = default;
180ClipArea(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
181ClipArea(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){
182}
183IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){
184}
185friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea(
186if_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));
187}};
188// vec4_scalar vTransformBounds;
189// sampler2D sTransformPalette;
190struct Transform_scalar {
191mat4_scalar m;
192mat4_scalar inv_m;
193bool is_axis_aligned;
194Transform_scalar() = default;
195Transform_scalar(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
196};
197struct Transform {
198mat4 m;
199mat4 inv_m;
200Bool is_axis_aligned;
201Transform() = default;
202Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
203Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){
204}
205IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){
206}
207friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform(
208if_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));
209}};
210// sampler2D sGpuBufferF;
211// isampler2D sGpuBufferI;
212struct ImageSource_scalar {
213RectWithEndpoint_scalar uv_rect;
214vec4_scalar user_data;
215ImageSource_scalar() = default;
216ImageSource_scalar(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data) : uv_rect(uv_rect), user_data(user_data){}
217};
218struct ImageSource {
219RectWithEndpoint uv_rect;
220vec4 user_data;
221ImageSource() = default;
222ImageSource(RectWithEndpoint uv_rect, vec4 user_data) : uv_rect(uv_rect), user_data(user_data){}
223ImageSource(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data):uv_rect(uv_rect),user_data(user_data){
224}
225IMPLICIT ImageSource(ImageSource_scalar s):uv_rect(s.uv_rect),user_data(s.user_data){
226}
227friend ImageSource if_then_else(I32 c, ImageSource t, ImageSource e) { return ImageSource(
228if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.user_data, e.user_data));
229}};
230struct ImageSourceExtra_scalar {
231vec4_scalar st_tl;
232vec4_scalar st_tr;
233vec4_scalar st_bl;
234vec4_scalar st_br;
235ImageSourceExtra_scalar() = default;
236ImageSourceExtra_scalar(vec4_scalar st_tl, vec4_scalar st_tr, vec4_scalar st_bl, vec4_scalar st_br) : st_tl(st_tl), st_tr(st_tr), st_bl(st_bl), st_br(st_br){}
237};
238struct ImageSourceExtra {
239vec4 st_tl;
240vec4 st_tr;
241vec4 st_bl;
242vec4 st_br;
243ImageSourceExtra() = default;
244ImageSourceExtra(vec4 st_tl, vec4 st_tr, vec4 st_bl, vec4 st_br) : st_tl(st_tl), st_tr(st_tr), st_bl(st_bl), st_br(st_br){}
245ImageSourceExtra(vec4_scalar st_tl, vec4_scalar st_tr, vec4_scalar st_bl, vec4_scalar st_br):st_tl(st_tl),st_tr(st_tr),st_bl(st_bl),st_br(st_br){
246}
247IMPLICIT ImageSourceExtra(ImageSourceExtra_scalar s):st_tl(s.st_tl),st_tr(s.st_tr),st_bl(s.st_bl),st_br(s.st_br){
248}
249friend ImageSourceExtra if_then_else(I32 c, ImageSourceExtra t, ImageSourceExtra e) { return ImageSourceExtra(
250if_then_else(c, t.st_tl, e.st_tl), if_then_else(c, t.st_tr, e.st_tr), if_then_else(c, t.st_bl, e.st_bl), if_then_else(c, t.st_br, e.st_br));
251}};
252// sampler2D sClipMask;
253// sampler2D sPrimitiveHeadersF;
254// isampler2D sPrimitiveHeadersI;
255ivec4_scalar aData;
256struct Instance_scalar {
257int32_t prim_header_address;
258int32_t clip_address;
259int32_t segment_index;
260int32_t flags;
261int32_t resource_address;
262int32_t brush_kind;
263Instance_scalar() = default;
264Instance_scalar(int32_t prim_header_address, int32_t clip_address, int32_t segment_index, int32_t flags, int32_t resource_address, int32_t brush_kind) : prim_header_address(prim_header_address), clip_address(clip_address), segment_index(segment_index), flags(flags), resource_address(resource_address), brush_kind(brush_kind){}
265};
266struct Instance {
267I32 prim_header_address;
268I32 clip_address;
269I32 segment_index;
270I32 flags;
271I32 resource_address;
272I32 brush_kind;
273Instance() = default;
274Instance(I32 prim_header_address, I32 clip_address, I32 segment_index, I32 flags, I32 resource_address, I32 brush_kind) : prim_header_address(prim_header_address), clip_address(clip_address), segment_index(segment_index), flags(flags), resource_address(resource_address), brush_kind(brush_kind){}
275Instance(int32_t prim_header_address, int32_t clip_address, int32_t segment_index, int32_t flags, int32_t resource_address, int32_t brush_kind):prim_header_address(prim_header_address),clip_address(clip_address),segment_index(segment_index),flags(flags),resource_address(resource_address),brush_kind(brush_kind){
276}
277IMPLICIT Instance(Instance_scalar s):prim_header_address(s.prim_header_address),clip_address(s.clip_address),segment_index(s.segment_index),flags(s.flags),resource_address(s.resource_address),brush_kind(s.brush_kind){
278}
279friend Instance if_then_else(I32 c, Instance t, Instance e) { return Instance(
280if_then_else(c, t.prim_header_address, e.prim_header_address), if_then_else(c, t.clip_address, e.clip_address), if_then_else(c, t.segment_index, e.segment_index), if_then_else(c, t.flags, e.flags), if_then_else(c, t.resource_address, e.resource_address), if_then_else(c, t.brush_kind, e.brush_kind));
281}};
282struct PrimitiveHeader_scalar {
283RectWithEndpoint_scalar local_rect;
284RectWithEndpoint_scalar local_clip_rect;
285float z;
286int32_t specific_prim_address;
287int32_t transform_id;
288int32_t picture_task_address;
289ivec4_scalar user_data;
290PrimitiveHeader_scalar() = default;
291PrimitiveHeader_scalar(RectWithEndpoint_scalar local_rect, RectWithEndpoint_scalar local_clip_rect, float z, int32_t specific_prim_address, int32_t transform_id, int32_t picture_task_address, ivec4_scalar user_data) : local_rect(local_rect), local_clip_rect(local_clip_rect), z(z), specific_prim_address(specific_prim_address), transform_id(transform_id), picture_task_address(picture_task_address), user_data(user_data){}
292};
293struct PrimitiveHeader {
294RectWithEndpoint local_rect;
295RectWithEndpoint local_clip_rect;
296Float z;
297I32 specific_prim_address;
298I32 transform_id;
299I32 picture_task_address;
300ivec4 user_data;
301PrimitiveHeader() = default;
302PrimitiveHeader(RectWithEndpoint local_rect, RectWithEndpoint local_clip_rect, Float z, I32 specific_prim_address, I32 transform_id, I32 picture_task_address, ivec4 user_data) : local_rect(local_rect), local_clip_rect(local_clip_rect), z(z), specific_prim_address(specific_prim_address), transform_id(transform_id), picture_task_address(picture_task_address), user_data(user_data){}
303PrimitiveHeader(RectWithEndpoint_scalar local_rect, RectWithEndpoint_scalar local_clip_rect, float z, int32_t specific_prim_address, int32_t transform_id, int32_t picture_task_address, ivec4_scalar user_data):local_rect(local_rect),local_clip_rect(local_clip_rect),z(z),specific_prim_address(specific_prim_address),transform_id(transform_id),picture_task_address(picture_task_address),user_data(user_data){
304}
305IMPLICIT PrimitiveHeader(PrimitiveHeader_scalar s):local_rect(s.local_rect),local_clip_rect(s.local_clip_rect),z(s.z),specific_prim_address(s.specific_prim_address),transform_id(s.transform_id),picture_task_address(s.picture_task_address),user_data(s.user_data){
306}
307friend PrimitiveHeader if_then_else(I32 c, PrimitiveHeader t, PrimitiveHeader e) { return PrimitiveHeader(
308if_then_else(c, t.local_rect, e.local_rect), if_then_else(c, t.local_clip_rect, e.local_clip_rect), if_then_else(c, t.z, e.z), if_then_else(c, t.specific_prim_address, e.specific_prim_address), if_then_else(c, t.transform_id, e.transform_id), if_then_else(c, t.picture_task_address, e.picture_task_address), if_then_else(c, t.user_data, e.user_data));
309}};
310struct VertexInfo_scalar {
311vec2_scalar local_pos;
312vec4_scalar world_pos;
313VertexInfo_scalar() = default;
314VertexInfo_scalar(vec2_scalar local_pos, vec4_scalar world_pos) : local_pos(local_pos), world_pos(world_pos){}
315};
316struct VertexInfo {
317vec2 local_pos;
318vec4 world_pos;
319VertexInfo() = default;
320VertexInfo(vec2 local_pos, vec4 world_pos) : local_pos(local_pos), world_pos(world_pos){}
321VertexInfo(vec2_scalar local_pos, vec4_scalar world_pos):local_pos(local_pos),world_pos(world_pos){
322}
323IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos),world_pos(s.world_pos){
324}
325friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo(
326if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.world_pos, e.world_pos));
327}};
328vec2 vUv;
329// vec2_scalar vPerspective;
330// vec4_scalar vUvSampleBounds;
331struct SplitGeometry_scalar {
332Array<vec2_scalar,4> local;
333SplitGeometry_scalar() = default;
334explicit SplitGeometry_scalar(Array<vec2_scalar,4> local) : local(local){}
335};
336struct SplitGeometry {
337Array<vec2,4> local;
338SplitGeometry() = default;
339explicit SplitGeometry(Array<vec2,4> local) : local(local){}
340explicit SplitGeometry(Array<vec2_scalar,4> local){
341this->local.convert(local);
342}
343IMPLICIT SplitGeometry(SplitGeometry_scalar s){
344local.convert(s.local);
345}
346friend SplitGeometry if_then_else(I32 c, SplitGeometry t, SplitGeometry e) { return SplitGeometry(
347if_then_else(c, t.local, e.local));
348}};
349struct SplitCompositeInstance_scalar {
350int32_t prim_header_index;
351int32_t polygons_address;
352float z;
353int32_t render_task_index;
354SplitCompositeInstance_scalar() = default;
355SplitCompositeInstance_scalar(int32_t prim_header_index, int32_t polygons_address, float z, int32_t render_task_index) : prim_header_index(prim_header_index), polygons_address(polygons_address), z(z), render_task_index(render_task_index){}
356};
357struct SplitCompositeInstance {
358I32 prim_header_index;
359I32 polygons_address;
360Float z;
361I32 render_task_index;
362SplitCompositeInstance() = default;
363SplitCompositeInstance(I32 prim_header_index, I32 polygons_address, Float z, I32 render_task_index) : prim_header_index(prim_header_index), polygons_address(polygons_address), z(z), render_task_index(render_task_index){}
364SplitCompositeInstance(int32_t prim_header_index, int32_t polygons_address, float z, int32_t render_task_index):prim_header_index(prim_header_index),polygons_address(polygons_address),z(z),render_task_index(render_task_index){
365}
366IMPLICIT SplitCompositeInstance(SplitCompositeInstance_scalar s):prim_header_index(s.prim_header_index),polygons_address(s.polygons_address),z(s.z),render_task_index(s.render_task_index){
367}
368friend SplitCompositeInstance if_then_else(I32 c, SplitCompositeInstance t, SplitCompositeInstance e) { return SplitCompositeInstance(
369if_then_else(c, t.prim_header_index, e.prim_header_index), if_then_else(c, t.polygons_address, e.polygons_address), if_then_else(c, t.z, e.z), if_then_else(c, t.render_task_index, e.render_task_index));
370}};
371SplitCompositeInstance_scalar fetch_composite_instance() {
372 SplitCompositeInstance_scalar ci;
373 (ci).prim_header_index = (aData).x;
374 (ci).polygons_address = (aData).y;
375 (ci).z = make_float((aData).z);
376 (ci).render_task_index = (aData).w;
377 return ci;
378}
379ivec2_scalar get_gpu_buffer_uv(int32_t address) {
380 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
381}
382Array<vec4_scalar,2> fetch_from_gpu_buffer_2f_direct(ivec2_scalar uv) {
383 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 1, 0, 0);
384 return Array<vec4_scalar,2>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0)}};
385}
386Array<vec4_scalar,2> fetch_from_gpu_buffer_2f(int32_t address) {
387 ivec2_scalar uv = get_gpu_buffer_uv(address);
388 return fetch_from_gpu_buffer_2f_direct(uv);
389}
390SplitGeometry_scalar fetch_split_geometry(int32_t address) {
391 Array<vec4_scalar,2> data = fetch_from_gpu_buffer_2f(address);
392 SplitGeometry_scalar geo;
393 (geo).local = Array<vec2_scalar,4>{{(data[0]).sel(X,Y), (data[0]).sel(Z,W), (data[1]).sel(X,Y), (data[1]).sel(Z,W)}};
394 return geo;
395}
396PrimitiveHeader_scalar fetch_prim_header(int32_t index) {
397 PrimitiveHeader_scalar ph;
398 ivec2_scalar uv_f = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
399 auto sPrimitiveHeadersF_uv_f_fetch = texelFetchPtr(sPrimitiveHeadersF, uv_f, 0, 1, 0, 0);
400 vec4_scalar local_rect = texelFetchUnchecked(sPrimitiveHeadersF, sPrimitiveHeadersF_uv_f_fetch, 0, 0);
401 vec4_scalar local_clip_rect = texelFetchUnchecked(sPrimitiveHeadersF, sPrimitiveHeadersF_uv_f_fetch, 1, 0);
402 (ph).local_rect = RectWithEndpoint_scalar((local_rect).sel(X,Y), (local_rect).sel(Z,W));
403 (ph).local_clip_rect = RectWithEndpoint_scalar((local_clip_rect).sel(X,Y), (local_clip_rect).sel(Z,W));
404 ivec2_scalar uv_i = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
405 auto sPrimitiveHeadersI_uv_i_fetch = texelFetchPtr(sPrimitiveHeadersI, uv_i, 0, 1, 0, 0);
406 ivec4_scalar data0 = texelFetchUnchecked(sPrimitiveHeadersI, sPrimitiveHeadersI_uv_i_fetch, 0, 0);
407 ivec4_scalar data1 = texelFetchUnchecked(sPrimitiveHeadersI, sPrimitiveHeadersI_uv_i_fetch, 1, 0);
408 (ph).z = make_float((data0).x);
409 (ph).specific_prim_address = (data0).y;
410 (ph).transform_id = (data0).z;
411 (ph).picture_task_address = (data0).w;
412 (ph).user_data = data1;
413 return ph;
414}
415RenderTaskData_scalar fetch_render_task_data(int32_t index) {
416 ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
417 auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0);
418 vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0);
419 vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0);
420 RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W));
421 RenderTaskData_scalar data = RenderTaskData_scalar(task_rect, texel1);
422 return data;
423}
424PictureTask_scalar fetch_picture_task(int32_t address) {
425 RenderTaskData_scalar task_data = fetch_render_task_data(address);
426 PictureTask_scalar task = PictureTask_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
427 return task;
428}
429Transform_scalar fetch_transform(int32_t id) {
430 Transform_scalar transform;
431 (transform).is_axis_aligned = ((id)>>(23))==(0);
432 int32_t index = (id)&(4194303);
433 ivec2_scalar uv = make_ivec2(make_int((8u)*((make_uint(index))%((1024u)/(8u)))), make_int((make_uint(index))/((1024u)/(8u))));
434 ivec2_scalar uv0 = make_ivec2(((uv).x)+(0), (uv).y);
435 auto sTransformPalette_uv0_fetch = texelFetchPtr(sTransformPalette, uv0, 0, 7, 0, 0);
436 (transform).m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 0, 0);
437 (transform).m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 1, 0);
438 (transform).m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 2, 0);
439 (transform).m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 3, 0);
440 (transform).inv_m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 4, 0);
441 (transform).inv_m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 5, 0);
442 (transform).inv_m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 6, 0);
443 (transform).inv_m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 7, 0);
444 return transform;
445}
446ImageSource_scalar fetch_image_source(int32_t address) {
447 Array<vec4_scalar,2> data = fetch_from_gpu_buffer_2f(address);
448 RectWithEndpoint_scalar uv_rect = RectWithEndpoint_scalar((data[0]).sel(X,Y), (data[0]).sel(Z,W));
449 return ImageSource_scalar(uv_rect, data[1]);
450}
451ClipArea_scalar fetch_clip_area(int32_t index) {
452 RenderTaskData_scalar task_data;
453 if ((index)>=(2147483647)) {
454 {
455 task_data = RenderTaskData_scalar(RectWithEndpoint_scalar(make_vec2(0.f), make_vec2(0.f)), make_vec4(0.f));
456 }
457 } else {
458 task_data = fetch_render_task_data(index);
459 }
460 return ClipArea_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
461}
462vec2 bilerp(vec2_scalar a, vec2_scalar b, vec2_scalar c, vec2_scalar d, Float s, Float t) {
463 vec2 x = mix(a, b, t);
464 vec2 y = mix(c, d, t);
465 return mix(x, y, s);
466}
467vec2_scalar rect_size(RectWithEndpoint_scalar rect) {
468 return ((rect).p1)-((rect).p0);
469}
470void write_clip(vec4 world_pos, ClipArea_scalar area, PictureTask_scalar task) {
471 swgl_clipMask(sClipMask, ((((task).task_rect).p0)-((task).content_origin))-((((area).task_rect).p0)-((area).screen_origin)), ((area).task_rect).p0, rect_size((area).task_rect))do { if (rect_size((area).task_rect) != vec2_scalar(0.0f, 0.0f
)) { swgl_ClipFlags |= SWGL_CLIP_FLAG_MASK; swgl_ClipMask = sClipMask
; swgl_ClipMaskOffset = make_ivec2(((((task).task_rect).p0)-(
(task).content_origin))-((((area).task_rect).p0)-((area).screen_origin
))); swgl_ClipMaskBounds = IntRect(make_ivec2(((area).task_rect
).p0), make_ivec2(rect_size((area).task_rect))); } } while (0
)
;
472}
473Array<vec4_scalar,4> fetch_from_gpu_buffer_4f_direct(ivec2_scalar uv) {
474 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 3, 0, 0);
475 return Array<vec4_scalar,4>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 2, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 3, 0)}};
476}
477Array<vec4_scalar,4> fetch_from_gpu_buffer_4f(int32_t address) {
478 ivec2_scalar uv = get_gpu_buffer_uv(address);
479 return fetch_from_gpu_buffer_4f_direct(uv);
480}
481ImageSourceExtra_scalar fetch_image_source_extra(int32_t address) {
482 Array<vec4_scalar,4> data = fetch_from_gpu_buffer_4f((address)+(2));
483 return ImageSourceExtra_scalar(data[0], data[1], data[2], data[3]);
484}
485vec2 get_image_quad_uv(int32_t address, vec2 f) {
486 ImageSourceExtra_scalar extra_data = fetch_image_source_extra(address);
487 vec4 x = mix((extra_data).st_tl, (extra_data).st_tr, (f).x);
488 vec4 y = mix((extra_data).st_bl, (extra_data).st_br, (f).x);
489 vec4 z = mix(x, y, (f).y);
490 return ((z).sel(X,Y))/((z).w);
491}
492ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
493 SplitCompositeInstance_scalar ci = fetch_composite_instance();
494 SplitGeometry_scalar geometry = fetch_split_geometry((ci).polygons_address);
495 PrimitiveHeader_scalar ph = fetch_prim_header((ci).prim_header_index);
496 PictureTask_scalar dest_task = fetch_picture_task((ci).render_task_index);
497 Transform_scalar transform = fetch_transform((ph).transform_id);
498 ImageSource_scalar res = fetch_image_source(((ph).user_data).x);
499 ClipArea_scalar clip_area = fetch_clip_area(((ph).user_data).w);
500 vec2_scalar dest_origin = (((dest_task).task_rect).p0)-((dest_task).content_origin);
501 vec2 local_pos = bilerp((geometry).local[0], (geometry).local[1], (geometry).local[3], (geometry).local[2], (aPosition).y, (aPosition).x);
502 vec4 world_pos = ((transform).m)*(make_vec4(local_pos, 0.f, 1.f));
503 vec4 final_pos = make_vec4(((dest_origin)*((world_pos).w))+(((world_pos).sel(X,Y))*((dest_task).device_pixel_scale)), ((world_pos).w)*((ci).z), (world_pos).w);
504 write_clip(world_pos, clip_area, dest_task);
505 gl_Position = (uTransform)*(final_pos);
506 vec2_scalar texture_size = make_vec2(textureSize(sColor0, 0));
507 vec2_scalar uv0 = ((res).uv_rect).p0;
508 vec2_scalar uv1 = ((res).uv_rect).p1;
509 vec2_scalar min_uv = min(uv0, uv1);
510 vec2_scalar max_uv = max(uv0, uv1);
511 vUvSampleBounds = (make_vec4((min_uv)+(make_vec2(0.5f)), (max_uv)-(make_vec2(0.5f))))/((texture_size).sel(X,Y,X,Y));
512 vec2 f = ((local_pos)-(((ph).local_rect).p0))/(rect_size((ph).local_rect));
513 f = get_image_quad_uv(((ph).user_data).x, f);
514 vec2 uv = mix(uv0, uv1, f);
515 float perspective_interpolate = make_float(((ph).user_data).y);
516 vUv = ((uv)/(texture_size))*(mix((gl_Position).w, 1.f, perspective_interpolate));
517 (vPerspective).x = perspective_interpolate;
518}
519static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
520 Self* self = (Self*)impl;
521 if (self->samplers.set_slot(index, value)) return;
522 switch (index) {
523 case 8:
524 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
525 break;
526 case 9:
527 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
528 break;
529 case 3:
530 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
531 break;
532 case 4:
533 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
534 break;
535 case 5:
536 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
537 break;
538 case 6:
539 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
540 break;
541 case 1:
542 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
543 break;
544 case 2:
545 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
546 break;
547 case 7:
548 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
549 break;
550 }
551}
552static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
553 Self* self = (Self*)impl;
554 switch (index) {
555 case 8:
556 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
557 break;
558 case 9:
559 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
560 break;
561 case 3:
562 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
563 break;
564 case 4:
565 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
566 break;
567 case 5:
568 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
569 break;
570 case 6:
571 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
572 break;
573 case 1:
574 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
575 break;
576 case 2:
577 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
578 break;
579 case 7:
580 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
581 break;
582 }
583}
584static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
585 Self* self = (Self*)impl;
586 switch (index) {
587 case 8:
588 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
589 break;
590 case 9:
591 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
592 break;
593 case 3:
594 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
595 break;
596 case 4:
597 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
598 break;
599 case 5:
600 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
601 break;
602 case 6:
603 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
604 break;
605 case 1:
606 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
607 break;
608 case 2:
609 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
610 break;
611 case 7:
612 self->uTransform = mat4_scalar::load_from_ptr(value);
613 break;
614 }
615}
616static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
617 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
618 load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count);
619}
620public:
621struct InterpOutputs {
622vec2_scalar vUv;
623};
624private:
625ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
626 for(int n = 0; n < 4; n++) {
627 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
628 dest->vUv = get_nth(vUv, n);
629 dest_ptr += stride;
630 }
631}
632static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
633 Self* self = (Self*)impl;
634 self->main();
635 self->store_interp_outputs(interps, interp_stride);
636}
637static void init_batch(VertexShaderImpl* impl) {
638 Self* self = (Self*)impl; self->bind_textures(); }
639public:
640ps_split_composite_vert() {
641 set_uniform_1i_func = &set_uniform_1i;
642 set_uniform_4fv_func = &set_uniform_4fv;
643 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
644 init_batch_func = &init_batch;
645 load_attribs_func = &load_attribs;
646 run_primitive_func = &run;
647}
648};
649
650
651struct ps_split_composite_frag : FragmentShaderImpl, ps_split_composite_vert {
652private:
653typedef ps_split_composite_frag Self;
654#define oFragColorgl_FragColor gl_FragColor
655// vec4 oFragColor;
656// sampler2D sColor0;
657// sampler2D sColor1;
658// sampler2D sColor2;
659struct RectWithSize_scalar {
660vec2_scalar p0;
661vec2_scalar size;
662RectWithSize_scalar() = default;
663RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
664};
665struct RectWithSize {
666vec2 p0;
667vec2 size;
668RectWithSize() = default;
669RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
670RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
671}
672IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
673}
674friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
675if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
676}};
677struct RectWithEndpoint_scalar {
678vec2_scalar p0;
679vec2_scalar p1;
680RectWithEndpoint_scalar() = default;
681RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
682};
683struct RectWithEndpoint {
684vec2 p0;
685vec2 p1;
686RectWithEndpoint() = default;
687RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
688RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
689}
690IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
691}
692friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
693if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
694}};
695// vec4_scalar vTransformBounds;
696// sampler2D sGpuBufferF;
697// isampler2D sGpuBufferI;
698// sampler2D sClipMask;
699struct Fragment_scalar {
700vec4_scalar color;
701Fragment_scalar() = default;
702explicit Fragment_scalar(vec4_scalar color) : color(color){}
703};
704struct Fragment {
705vec4 color;
706Fragment() = default;
707explicit Fragment(vec4 color) : color(color){}
708explicit Fragment(vec4_scalar color):color(color){
709}
710IMPLICIT Fragment(Fragment_scalar s):color(s.color){
711}
712friend Fragment if_then_else(I32 c, Fragment t, Fragment e) { return Fragment(
713if_then_else(c, t.color, e.color));
714}};
715vec2 vUv;
716// vec2_scalar vPerspective;
717// vec4_scalar vUvSampleBounds;
718float do_clip() {
719 return 1.f;
720}
721void write_output(vec4 color) {
722 oFragColorgl_FragColor = color;
723}
724ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
725 float alpha = do_clip();
726 Float perspective_divisor = mix((gl_FragCoord).w, 1.f, (vPerspective).x);
727 vec2 uv = clamp((vUv)*(perspective_divisor), (vUvSampleBounds).sel(X,Y), (vUvSampleBounds).sel(Z,W));
728 write_output((alpha)*(texture(sColor0, uv)));
729}
730void swgl_drawSpanRGBA8() {
731 float perspective_divisor = mix(swgl_forceScalar((gl_FragCoord).w), 1.f, (vPerspective).x);
732 vec2 uv = (vUv)*(perspective_divisor);
733 swgl_commitTextureRGBA8(sColor0, uv, vUvSampleBounds)do { if (sColor0->filter == TextureFilter::LINEAR) { do { auto
packed_color = packColor(swgl_OutRGBA8, NoColor()); int len =
(swgl_SpanLength); int drawn = 0; if (LinearFilter filter = needsTextureLinear
(sColor0, uv, len)) { if (blend_key) { drawn = blendTextureLinear
<true>(sColor0, uv, len, vUvSampleBounds, packed_color,
swgl_OutRGBA8, filter); } else { drawn = blendTextureLinear<
false>(sColor0, uv, len, vUvSampleBounds, packed_color, swgl_OutRGBA8
, filter); } } else if (blend_key) { drawn = blendTextureNearestFast
<true>(sColor0, uv, len, vUvSampleBounds, packed_color,
swgl_OutRGBA8); } else { drawn = blendTextureNearestFast<
false>(sColor0, uv, len, vUvSampleBounds, packed_color, swgl_OutRGBA8
); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while
(0); } else { do { auto packed_color = packColor(swgl_OutRGBA8
, NoColor()); int drawn = 0; if (needsNearestFallback(sColor0
, uv, swgl_SpanLength)) { if (blend_key) { drawn = blendTextureNearestRepeat
<true, false>( sColor0, uv, swgl_SpanLength, 0.0f, vUvSampleBounds
, packed_color, swgl_OutRGBA8); } else { drawn = blendTextureNearestRepeat
<false, false>( sColor0, uv, swgl_SpanLength, 0.0f, vUvSampleBounds
, packed_color, swgl_OutRGBA8); } } else if (blend_key) { drawn
= blendTextureNearestFast<true>(sColor0, uv, swgl_SpanLength
, vUvSampleBounds, packed_color, swgl_OutRGBA8); } else { drawn
= blendTextureNearestFast<false>(sColor0, uv, swgl_SpanLength
, vUvSampleBounds, packed_color, swgl_OutRGBA8); } swgl_OutRGBA8
+= drawn; swgl_SpanLength -= drawn; } while (0); } } while (
0)
;
734}
735typedef ps_split_composite_vert::InterpOutputs InterpInputs;
736InterpInputs interp_step;
737struct InterpPerspective {
738vec2 vUv;
739};
740InterpPerspective interp_perspective;
741static 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_;
742 self->vUv = init_interp(init->vUv, step->vUv);
743 self->interp_step.vUv = step->vUv * 4.0f;
744}
745static 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_;
746 Float w = 1.0f / self->gl_FragCoord.w;
747 self->interp_perspective.vUv = init_interp(init->vUv, step->vUv);
748 self->vUv = self->interp_perspective.vUv * w;
749 self->interp_step.vUv = step->vUv * 4.0f;
750}
751ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
752 float chunks = steps * 0.25f;
753 vUv += interp_step.vUv * chunks;
754}
755ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
756 step_perspective(steps);
757 float chunks = steps * 0.25f;
758 Float w = 1.0f / gl_FragCoord.w;
759 interp_perspective.vUv += interp_step.vUv * chunks;
760 vUv = w * interp_perspective.vUv;
761}
762static void run(FragmentShaderImpl* impl) {
763 Self* self = (Self*)impl;
764 self->main();
765 self->step_interp_inputs();
766}
767static void skip(FragmentShaderImpl* impl, int steps) {
768 Self* self = (Self*)impl;
769 self->step_interp_inputs(steps);
770}
771static void run_perspective(FragmentShaderImpl* impl) {
772 Self* self = (Self*)impl;
773 self->main();
774 self->step_perspective_inputs();
775}
776static void skip_perspective(FragmentShaderImpl* impl, int steps) {
777 Self* self = (Self*)impl;
778 self->step_perspective_inputs(steps);
779}
780static int draw_span_RGBA8(FragmentShaderImpl* impl) {
781 Self* self = (Self*)impl; DISPATCH_DRAW_SPAN(self, RGBA8)do { int total = self->swgl_SpanLength; self->swgl_drawSpanRGBA8
(); int drawn = total - self->swgl_SpanLength; if (drawn) self
->step_interp_inputs(drawn); return drawn; } while (0)
; }
782public:
783ps_split_composite_frag() {
784 init_span_func = &read_interp_inputs;
785 run_func = &run;
786 skip_func = &skip;
787 draw_span_RGBA8_func = &draw_span_RGBA8;
788 enable_perspective();
789 init_span_w_func = &read_perspective_inputs;
790 run_w_func = &run_perspective;
791 skip_w_func = &skip_perspective;
792}
793};
794
795struct ps_split_composite_program : ProgramImpl, ps_split_composite_frag {
796int get_uniform(const char *name) const override {
797 if (strcmp("sClipMask", name) == 0) { return 8; }
798 if (strcmp("sColor0", name) == 0) { return 9; }
799 if (strcmp("sGpuBufferF", name) == 0) { return 3; }
800 if (strcmp("sGpuBufferI", name) == 0) { return 4; }
801 if (strcmp("sPrimitiveHeadersF", name) == 0) { return 5; }
802 if (strcmp("sPrimitiveHeadersI", name) == 0) { return 6; }
803 if (strcmp("sRenderTasks", name) == 0) { return 1; }
804 if (strcmp("sTransformPalette", name) == 0) { return 2; }
805 if (strcmp("uTransform", name) == 0) { return 7; }
806 return -1;
807}
808void bind_attrib(const char* name, int index) override {
809 attrib_locations.bind_loc(name, index);
810}
811int get_attrib(const char* name) const override {
812 return attrib_locations.get_loc(name);
813}
814size_t interpolants_size() const override { return sizeof(InterpOutputs); }
815VertexShaderImpl* get_vertex_shader() override {
816 return this;
817}
818FragmentShaderImpl* get_fragment_shader() override {
819 return this;
820}
821const char* get_name() const override { return "ps_split_composite"; }
822static ProgramImpl* loader() { return new ps_split_composite_program; }
823};
824