Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out/ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D.h
Warning:line 2, column 8
Excessive padding in 'struct ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_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_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_common {
2struct Samplers {
Excessive padding in 'struct ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_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;
63vec4_scalar v_color;
64vec3_scalar v_mask_swizzle;
65vec4_scalar v_uv_bounds;
66sampler2D sClipMask;
67sampler2D sColor0;
68sampler2D sGpuBufferF;
69isampler2D sGpuBufferI;
70sampler2D sPrimitiveHeadersF;
71isampler2D sPrimitiveHeadersI;
72sampler2D sRenderTasks;
73sampler2D sTransformPalette;
74mat4_scalar uTransform;
75void bind_textures() {
76 sClipMask = lookup_sampler(&samplers.sClipMask_impl, samplers.sClipMask_slot);
77 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
78 sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot);
79 sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot);
80 sPrimitiveHeadersF = lookup_sampler(&samplers.sPrimitiveHeadersF_impl, samplers.sPrimitiveHeadersF_slot);
81 sPrimitiveHeadersI = lookup_isampler(&samplers.sPrimitiveHeadersI_impl, samplers.sPrimitiveHeadersI_slot);
82 sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot);
83 sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot);
84}
85};
86struct ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_vert : VertexShaderImpl, ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_common {
87private:
88typedef ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_vert Self;
89// mat4_scalar uTransform;
90vec2 aPosition;
91// sampler2D sColor0;
92// sampler2D sColor1;
93// sampler2D sColor2;
94struct RectWithSize_scalar {
95vec2_scalar p0;
96vec2_scalar size;
97RectWithSize_scalar() = default;
98RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
99};
100struct RectWithSize {
101vec2 p0;
102vec2 size;
103RectWithSize() = default;
104RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
105RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
106}
107IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
108}
109friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
110if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
111}};
112struct RectWithEndpoint_scalar {
113vec2_scalar p0;
114vec2_scalar p1;
115RectWithEndpoint_scalar() = default;
116RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
117};
118struct RectWithEndpoint {
119vec2 p0;
120vec2 p1;
121RectWithEndpoint() = default;
122RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
123RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
124}
125IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
126}
127friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
128if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
129}};
130// sampler2D sRenderTasks;
131struct RenderTaskData_scalar {
132RectWithEndpoint_scalar task_rect;
133vec4_scalar user_data;
134RenderTaskData_scalar() = default;
135RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){}
136};
137struct RenderTaskData {
138RectWithEndpoint task_rect;
139vec4 user_data;
140RenderTaskData() = default;
141RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){}
142RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){
143}
144IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){
145}
146friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData(
147if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data));
148}};
149struct PictureTask_scalar {
150RectWithEndpoint_scalar task_rect;
151float device_pixel_scale;
152vec2_scalar content_origin;
153PictureTask_scalar() = default;
154PictureTask_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){}
155};
156struct PictureTask {
157RectWithEndpoint task_rect;
158Float device_pixel_scale;
159vec2 content_origin;
160PictureTask() = default;
161PictureTask(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
162PictureTask(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){
163}
164IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){
165}
166friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask(
167if_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));
168}};
169struct ClipArea_scalar {
170RectWithEndpoint_scalar task_rect;
171float device_pixel_scale;
172vec2_scalar screen_origin;
173ClipArea_scalar() = default;
174ClipArea_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){}
175};
176struct ClipArea {
177RectWithEndpoint task_rect;
178Float device_pixel_scale;
179vec2 screen_origin;
180ClipArea() = default;
181ClipArea(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
182ClipArea(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){
183}
184IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){
185}
186friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea(
187if_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));
188}};
189// vec4_scalar vTransformBounds;
190// sampler2D sTransformPalette;
191struct Transform_scalar {
192mat4_scalar m;
193mat4_scalar inv_m;
194bool is_axis_aligned;
195Transform_scalar() = default;
196Transform_scalar(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
197};
198struct Transform {
199mat4 m;
200mat4 inv_m;
201Bool is_axis_aligned;
202Transform() = default;
203Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
204Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){
205}
206IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){
207}
208friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform(
209if_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));
210}};
211// sampler2D sGpuBufferF;
212// isampler2D sGpuBufferI;
213struct ImageSource_scalar {
214RectWithEndpoint_scalar uv_rect;
215vec4_scalar user_data;
216ImageSource_scalar() = default;
217ImageSource_scalar(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data) : uv_rect(uv_rect), user_data(user_data){}
218};
219struct ImageSource {
220RectWithEndpoint uv_rect;
221vec4 user_data;
222ImageSource() = default;
223ImageSource(RectWithEndpoint uv_rect, vec4 user_data) : uv_rect(uv_rect), user_data(user_data){}
224ImageSource(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data):uv_rect(uv_rect),user_data(user_data){
225}
226IMPLICIT ImageSource(ImageSource_scalar s):uv_rect(s.uv_rect),user_data(s.user_data){
227}
228friend ImageSource if_then_else(I32 c, ImageSource t, ImageSource e) { return ImageSource(
229if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.user_data, e.user_data));
230}};
231struct ImageSourceExtra_scalar {
232vec4_scalar st_tl;
233vec4_scalar st_tr;
234vec4_scalar st_bl;
235vec4_scalar st_br;
236ImageSourceExtra_scalar() = default;
237ImageSourceExtra_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){}
238};
239struct ImageSourceExtra {
240vec4 st_tl;
241vec4 st_tr;
242vec4 st_bl;
243vec4 st_br;
244ImageSourceExtra() = default;
245ImageSourceExtra(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){}
246ImageSourceExtra(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){
247}
248IMPLICIT ImageSourceExtra(ImageSourceExtra_scalar s):st_tl(s.st_tl),st_tr(s.st_tr),st_bl(s.st_bl),st_br(s.st_br){
249}
250friend ImageSourceExtra if_then_else(I32 c, ImageSourceExtra t, ImageSourceExtra e) { return ImageSourceExtra(
251if_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));
252}};
253// sampler2D sClipMask;
254// sampler2D sPrimitiveHeadersF;
255// isampler2D sPrimitiveHeadersI;
256ivec4_scalar aData;
257struct Instance_scalar {
258int32_t prim_header_address;
259int32_t clip_address;
260int32_t segment_index;
261int32_t flags;
262int32_t resource_address;
263int32_t brush_kind;
264Instance_scalar() = default;
265Instance_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){}
266};
267struct Instance {
268I32 prim_header_address;
269I32 clip_address;
270I32 segment_index;
271I32 flags;
272I32 resource_address;
273I32 brush_kind;
274Instance() = default;
275Instance(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){}
276Instance(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){
277}
278IMPLICIT 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){
279}
280friend Instance if_then_else(I32 c, Instance t, Instance e) { return Instance(
281if_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));
282}};
283struct PrimitiveHeader_scalar {
284RectWithEndpoint_scalar local_rect;
285RectWithEndpoint_scalar local_clip_rect;
286float z;
287int32_t specific_prim_address;
288int32_t transform_id;
289int32_t picture_task_address;
290ivec4_scalar user_data;
291PrimitiveHeader_scalar() = default;
292PrimitiveHeader_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){}
293};
294struct PrimitiveHeader {
295RectWithEndpoint local_rect;
296RectWithEndpoint local_clip_rect;
297Float z;
298I32 specific_prim_address;
299I32 transform_id;
300I32 picture_task_address;
301ivec4 user_data;
302PrimitiveHeader() = default;
303PrimitiveHeader(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){}
304PrimitiveHeader(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){
305}
306IMPLICIT 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){
307}
308friend PrimitiveHeader if_then_else(I32 c, PrimitiveHeader t, PrimitiveHeader e) { return PrimitiveHeader(
309if_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));
310}};
311struct VertexInfo_scalar {
312vec2_scalar local_pos;
313vec4_scalar world_pos;
314VertexInfo_scalar() = default;
315VertexInfo_scalar(vec2_scalar local_pos, vec4_scalar world_pos) : local_pos(local_pos), world_pos(world_pos){}
316};
317struct VertexInfo {
318vec2 local_pos;
319vec4 world_pos;
320VertexInfo() = default;
321VertexInfo(vec2 local_pos, vec4 world_pos) : local_pos(local_pos), world_pos(world_pos){}
322VertexInfo(vec2_scalar local_pos, vec4_scalar world_pos):local_pos(local_pos),world_pos(world_pos){
323}
324IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos),world_pos(s.world_pos){
325}
326friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo(
327if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.world_pos, e.world_pos));
328}};
329// vec4_scalar v_color;
330// vec3_scalar v_mask_swizzle;
331// vec4_scalar v_uv_bounds;
332vec2 v_uv;
333struct Glyph_scalar {
334vec2_scalar offset;
335Glyph_scalar() = default;
336explicit Glyph_scalar(vec2_scalar offset) : offset(offset){}
337};
338struct Glyph {
339vec2 offset;
340Glyph() = default;
341explicit Glyph(vec2 offset) : offset(offset){}
342explicit Glyph(vec2_scalar offset):offset(offset){
343}
344IMPLICIT Glyph(Glyph_scalar s):offset(s.offset){
345}
346friend Glyph if_then_else(I32 c, Glyph t, Glyph e) { return Glyph(
347if_then_else(c, t.offset, e.offset));
348}};
349struct GlyphResource_scalar {
350vec4_scalar uv_rect;
351vec2_scalar offset;
352float scale;
353GlyphResource_scalar() = default;
354GlyphResource_scalar(vec4_scalar uv_rect, vec2_scalar offset, float scale) : uv_rect(uv_rect), offset(offset), scale(scale){}
355};
356struct GlyphResource {
357vec4 uv_rect;
358vec2 offset;
359Float scale;
360GlyphResource() = default;
361GlyphResource(vec4 uv_rect, vec2 offset, Float scale) : uv_rect(uv_rect), offset(offset), scale(scale){}
362GlyphResource(vec4_scalar uv_rect, vec2_scalar offset, float scale):uv_rect(uv_rect),offset(offset),scale(scale){
363}
364IMPLICIT GlyphResource(GlyphResource_scalar s):uv_rect(s.uv_rect),offset(s.offset),scale(s.scale){
365}
366friend GlyphResource if_then_else(I32 c, GlyphResource t, GlyphResource e) { return GlyphResource(
367if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.offset, e.offset), if_then_else(c, t.scale, e.scale));
368}};
369struct TextRun_scalar {
370vec4_scalar color;
371TextRun_scalar() = default;
372explicit TextRun_scalar(vec4_scalar color) : color(color){}
373};
374struct TextRun {
375vec4 color;
376TextRun() = default;
377explicit TextRun(vec4 color) : color(color){}
378explicit TextRun(vec4_scalar color):color(color){
379}
380IMPLICIT TextRun(TextRun_scalar s):color(s.color){
381}
382friend TextRun if_then_else(I32 c, TextRun t, TextRun e) { return TextRun(
383if_then_else(c, t.color, e.color));
384}};
385Instance_scalar decode_instance_attributes() {
386 Instance_scalar instance;
387 (instance).prim_header_address = (aData).x;
388 (instance).clip_address = (aData).y;
389 (instance).segment_index = ((aData).z)&(65535);
390 (instance).flags = ((aData).z)>>(16);
391 (instance).resource_address = ((aData).w)&(16777215);
392 (instance).brush_kind = ((aData).w)>>(24);
393 return instance;
394}
395PrimitiveHeader_scalar fetch_prim_header(int32_t index) {
396 PrimitiveHeader_scalar ph;
397 ivec2_scalar uv_f = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
398 auto sPrimitiveHeadersF_uv_f_fetch = texelFetchPtr(sPrimitiveHeadersF, uv_f, 0, 1, 0, 0);
399 vec4_scalar local_rect = texelFetchUnchecked(sPrimitiveHeadersF, sPrimitiveHeadersF_uv_f_fetch, 0, 0);
400 vec4_scalar local_clip_rect = texelFetchUnchecked(sPrimitiveHeadersF, sPrimitiveHeadersF_uv_f_fetch, 1, 0);
401 (ph).local_rect = RectWithEndpoint_scalar((local_rect).sel(X,Y), (local_rect).sel(Z,W));
402 (ph).local_clip_rect = RectWithEndpoint_scalar((local_clip_rect).sel(X,Y), (local_clip_rect).sel(Z,W));
403 ivec2_scalar uv_i = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
404 auto sPrimitiveHeadersI_uv_i_fetch = texelFetchPtr(sPrimitiveHeadersI, uv_i, 0, 1, 0, 0);
405 ivec4_scalar data0 = texelFetchUnchecked(sPrimitiveHeadersI, sPrimitiveHeadersI_uv_i_fetch, 0, 0);
406 ivec4_scalar data1 = texelFetchUnchecked(sPrimitiveHeadersI, sPrimitiveHeadersI_uv_i_fetch, 1, 0);
407 (ph).z = make_float((data0).x);
408 (ph).specific_prim_address = (data0).y;
409 (ph).transform_id = (data0).z;
410 (ph).picture_task_address = (data0).w;
411 (ph).user_data = data1;
412 return ph;
413}
414Transform_scalar fetch_transform(int32_t id) {
415 Transform_scalar transform;
416 (transform).is_axis_aligned = ((id)>>(23))==(0);
417 int32_t index = (id)&(4194303);
418 ivec2_scalar uv = make_ivec2(make_int((8u)*((make_uint(index))%((1024u)/(8u)))), make_int((make_uint(index))/((1024u)/(8u))));
419 ivec2_scalar uv0 = make_ivec2(((uv).x)+(0), (uv).y);
420 auto sTransformPalette_uv0_fetch = texelFetchPtr(sTransformPalette, uv0, 0, 7, 0, 0);
421 (transform).m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 0, 0);
422 (transform).m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 1, 0);
423 (transform).m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 2, 0);
424 (transform).m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 3, 0);
425 (transform).inv_m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 4, 0);
426 (transform).inv_m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 5, 0);
427 (transform).inv_m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 6, 0);
428 (transform).inv_m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 7, 0);
429 return transform;
430}
431RenderTaskData_scalar fetch_render_task_data(int32_t index) {
432 ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
433 auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0);
434 vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0);
435 vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0);
436 RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W));
437 RenderTaskData_scalar data = RenderTaskData_scalar(task_rect, texel1);
438 return data;
439}
440ClipArea_scalar fetch_clip_area(int32_t index) {
441 RenderTaskData_scalar task_data;
442 if ((index)>=(2147483647)) {
443 {
444 task_data = RenderTaskData_scalar(RectWithEndpoint_scalar(make_vec2(0.f), make_vec2(0.f)), make_vec4(0.f));
445 }
446 } else {
447 task_data = fetch_render_task_data(index);
448 }
449 return ClipArea_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
450}
451PictureTask_scalar fetch_picture_task(int32_t address) {
452 RenderTaskData_scalar task_data = fetch_render_task_data(address);
453 PictureTask_scalar task = PictureTask_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
454 return task;
455}
456ivec2_scalar get_gpu_buffer_uv(int32_t address) {
457 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
458}
459vec4_scalar fetch_from_gpu_buffer_1f(int32_t address) {
460 ivec2_scalar uv = get_gpu_buffer_uv(address);
461 return texelFetch(sGpuBufferF, uv, 0);
462}
463TextRun_scalar fetch_text_run(int32_t address) {
464 vec4_scalar data = fetch_from_gpu_buffer_1f(address);
465 return TextRun_scalar(data);
466}
467Glyph_scalar fetch_glyph(int32_t specific_prim_address, int32_t glyph_index) {
468 int32_t glyph_address = ((specific_prim_address)+(1))+(make_int((make_uint(glyph_index))/(2u)));
469 vec4_scalar data = fetch_from_gpu_buffer_1f(glyph_address);
470 vec2_scalar glyph = mix((data).sel(X,Y), (data).sel(Z,W), make_bvec2(((make_uint(glyph_index))%(2u))==(1u)));
471 return Glyph_scalar(glyph);
472}
473Array<vec4_scalar,2> fetch_from_gpu_buffer_2f_direct(ivec2_scalar uv) {
474 auto sGpuBufferF_uv_fetch = texelFetchPtr(sGpuBufferF, uv, 0, 1, 0, 0);
475 return Array<vec4_scalar,2>{{texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 0, 0), texelFetchUnchecked(sGpuBufferF, sGpuBufferF_uv_fetch, 1, 0)}};
476}
477Array<vec4_scalar,2> fetch_from_gpu_buffer_2f(int32_t address) {
478 ivec2_scalar uv = get_gpu_buffer_uv(address);
479 return fetch_from_gpu_buffer_2f_direct(uv);
480}
481GlyphResource_scalar fetch_glyph_resource(int32_t address) {
482 Array<vec4_scalar,2> data = fetch_from_gpu_buffer_2f(address);
483 return GlyphResource_scalar(data[0], (data[1]).sel(X,Y), (data[1]).z);
484}
485bool rect_inside_rect(RectWithEndpoint_scalar little, RectWithEndpoint_scalar big) {
486 return all(lessThanEqual(make_vec4((big).p0, (little).p1), make_vec4((little).p0, (big).p1)));
487}
488vec2 rect_clamp(RectWithEndpoint_scalar rect, vec2 pt) {
489 return clamp(pt, (rect).p0, (rect).p1);
490}
491VertexInfo write_vertex(vec2 local_pos, RectWithEndpoint_scalar local_clip_rect, float z, Transform_scalar transform, PictureTask_scalar task) {
492 vec2 clamped_local_pos = rect_clamp(local_clip_rect, local_pos);
493 vec4 world_pos = ((transform).m)*(make_vec4(clamped_local_pos, 0.f, 1.f));
494 vec2 device_pos = ((world_pos).sel(X,Y))*((task).device_pixel_scale);
495 vec2_scalar final_offset = (-((task).content_origin))+(((task).task_rect).p0);
496 gl_Position = (uTransform)*(make_vec4((device_pos)+((final_offset)*((world_pos).w)), (z)*((world_pos).w), (world_pos).w));
497 VertexInfo vi = VertexInfo(clamped_local_pos, world_pos);
498 return vi;
499}
500vec2_scalar rect_size(RectWithEndpoint_scalar rect) {
501 return ((rect).p1)-((rect).p0);
502}
503void write_clip(vec4 world_pos, ClipArea_scalar area, PictureTask_scalar task) {
504 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
)
;
505}
506ALWAYS_INLINE__attribute__((always_inline)) inline void main() {
507 Instance_scalar instance = decode_instance_attributes();
508 PrimitiveHeader_scalar ph = fetch_prim_header((instance).prim_header_address);
509 Transform_scalar transform = fetch_transform((ph).transform_id);
510 ClipArea_scalar clip_area = fetch_clip_area((instance).clip_address);
511 PictureTask_scalar task = fetch_picture_task((ph).picture_task_address);
512 int32_t glyph_index = (instance).segment_index;
513 int32_t color_mode = ((instance).flags)&(15);
514 int32_t subpx_offset_x = (((instance).flags)>>(4))&(3);
515 int32_t subpx_offset_y = (((instance).flags)>>(6))&(3);
516 int32_t subpx_dir = (((instance).flags)>>(8))&(3);
517 int32_t is_packed_glyph = (((instance).flags)>>(10))&(1);
518 TextRun_scalar text = fetch_text_run((ph).specific_prim_address);
519 Glyph_scalar glyph = fetch_glyph((ph).specific_prim_address, glyph_index);
520 GlyphResource_scalar res = fetch_glyph_resource((instance).resource_address);
521 if ((is_packed_glyph)!=(0)) {
522 {
523 int32_t variant_index = (subpx_dir)==(1) ? subpx_offset_x : subpx_offset_y;
524 float quarter_width = ((((res).uv_rect).z)-(((res).uv_rect).x))*(0.25f);
525 ((res).uv_rect).x = (((res).uv_rect).x)+((make_float(variant_index))*(quarter_width));
526 ((res).uv_rect).z = (((res).uv_rect).x)+(quarter_width);
527 }
528 }
529 vec2_scalar device_anchor = ((((transform).m)*(make_vec4(((ph).local_rect).p0, 0.f, 1.f))).sel(X,Y))*((task).device_pixel_scale);
530 float inv_dps = (1.f)/((task).device_pixel_scale);
531 VertexInfo vi;
532 vec2 f;
533 vec2_scalar device_origin = ((device_anchor)+((glyph).offset))+(((res).scale)*((res).offset));
534 vec2_scalar device_size = ((res).scale)*((((res).uv_rect).sel(Z,W))-(((res).uv_rect).sel(X,Y)));
535 vec2_scalar c0 = (((transform).inv_m)*(make_vec4((device_origin)*(inv_dps), 0.f, 1.f))).sel(X,Y);
536 vec2_scalar c1 = (((transform).inv_m)*(make_vec4((make_vec2(((device_origin).x)+((device_size).x), (device_origin).y))*(inv_dps), 0.f, 1.f))).sel(X,Y);
537 vec2_scalar c2 = (((transform).inv_m)*(make_vec4((make_vec2((device_origin).x, ((device_origin).y)+((device_size).y)))*(inv_dps), 0.f, 1.f))).sel(X,Y);
538 vec2_scalar c3 = (((transform).inv_m)*(make_vec4(((device_origin)+(device_size))*(inv_dps), 0.f, 1.f))).sel(X,Y);
539 RectWithEndpoint_scalar local_aabb = RectWithEndpoint_scalar(min(min(c0, c1), min(c2, c3)), max(max(c0, c1), max(c2, c3)));
540 vec2 local_pos = mix((local_aabb).p0, (local_aabb).p1, (aPosition).sel(X,Y));
541 if (rect_inside_rect(local_aabb, (ph).local_clip_rect)) {
542 {
543 vec2 device_corner = mix(device_origin, (device_origin)+(device_size), (aPosition).sel(X,Y));
544 local_pos = (((transform).inv_m)*(make_vec4((device_corner)*(inv_dps), 0.f, 1.f))).sel(X,Y);
545 }
546 }
547 vi = write_vertex(local_pos, (ph).local_clip_rect, (ph).z, transform, task);
548 vec2 device_clamped = ((((transform).m)*(make_vec4((vi).local_pos, 0.f, 1.f))).sel(X,Y))*((task).device_pixel_scale);
549 f = ((device_clamped)-(device_origin))/(device_size);
550 gl_ClipDistance[0] = (f).x;
551 gl_ClipDistance[1] = (f).y;
552 gl_ClipDistance[2] = (1.f)-((f).x);
553 gl_ClipDistance[3] = (1.f)-((f).y);
554 write_clip((vi).world_pos, clip_area, task);
555 switch (color_mode) {
556 case 0:
557 v_mask_swizzle = make_vec3(0.f, 1.f, 1.f);
558 v_color = (text).color;
559 break;
560 case 2:
561 swgl_blendDropShadow((text).color)do { swgl_ClipFlags |= SWGL_CLIP_FLAG_BLEND_OVERRIDE; swgl_BlendOverride
= BLEND_0xB001000; swgl_BlendColorRGBA8 = packColor<uint32_t
>((text).color); } while (0)
;
562 v_mask_swizzle = make_vec3(1.f, 0.f, 0.f);
563 v_color = make_vec4(1.f);
564 break;
565 case 3:
566 v_mask_swizzle = make_vec3(1.f, 0.f, 0.f);
567 v_color = make_vec4(((text).color).w);
568 break;
569 case 1:
570 swgl_blendSubpixelText((text).color)do { swgl_ClipFlags |= SWGL_CLIP_FLAG_BLEND_OVERRIDE; swgl_BlendOverride
= BLEND_0xB002000; swgl_BlendColorRGBA8 = packColor<uint32_t
>((text).color); swgl_BlendAlphaRGBA8 = alphas(swgl_BlendColorRGBA8
); } while (0)
;
571 v_mask_swizzle = make_vec3(1.f, 0.f, 0.f);
572 v_color = make_vec4(1.f);
573 break;
574 default:
575 v_mask_swizzle = make_vec3(0.f, 0.f, 0.f);
576 v_color = make_vec4(1.f);
577 }
578 vec2_scalar texture_size = make_vec2(textureSize(sColor0, 0));
579 vec2_scalar st0 = (((res).uv_rect).sel(X,Y))/(texture_size);
580 vec2_scalar st1 = (((res).uv_rect).sel(Z,W))/(texture_size);
581 v_uv = mix(st0, st1, f);
582 v_uv_bounds = (((res).uv_rect)+(make_vec4(0.5f, 0.5f, -(0.5f), -(0.5f))))/((texture_size).sel(X,Y,X,Y));
583}
584static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
585 Self* self = (Self*)impl;
586 if (self->samplers.set_slot(index, value)) return;
587 switch (index) {
588 case 8:
589 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
590 break;
591 case 9:
592 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
593 break;
594 case 3:
595 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
596 break;
597 case 4:
598 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
599 break;
600 case 5:
601 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
602 break;
603 case 6:
604 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
605 break;
606 case 1:
607 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
608 break;
609 case 2:
610 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
611 break;
612 case 7:
613 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
614 break;
615 }
616}
617static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
618 Self* self = (Self*)impl;
619 switch (index) {
620 case 8:
621 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
622 break;
623 case 9:
624 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
625 break;
626 case 3:
627 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
628 break;
629 case 4:
630 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
631 break;
632 case 5:
633 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
634 break;
635 case 6:
636 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
637 break;
638 case 1:
639 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
640 break;
641 case 2:
642 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
643 break;
644 case 7:
645 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
646 break;
647 }
648}
649static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
650 Self* self = (Self*)impl;
651 switch (index) {
652 case 8:
653 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
654 break;
655 case 9:
656 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
657 break;
658 case 3:
659 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferF
660 break;
661 case 4:
662 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuBufferI
663 break;
664 case 5:
665 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
666 break;
667 case 6:
668 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
669 break;
670 case 1:
671 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
672 break;
673 case 2:
674 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
675 break;
676 case 7:
677 self->uTransform = mat4_scalar::load_from_ptr(value);
678 break;
679 }
680}
681static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
682 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
683 load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count);
684}
685public:
686struct InterpOutputs {
687 Float swgl_ClipDistance;
688vec2_scalar v_uv;
689};
690private:
691ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
692 for(int n = 0; n < 4; n++) {
693 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
694 dest->swgl_ClipDistance.x = get_nth(gl_ClipDistance[0], n);
695 dest->swgl_ClipDistance.y = get_nth(gl_ClipDistance[1], n);
696 dest->swgl_ClipDistance.z = get_nth(gl_ClipDistance[2], n);
697 dest->swgl_ClipDistance.w = get_nth(gl_ClipDistance[3], n);
698 dest->v_uv = get_nth(v_uv, n);
699 dest_ptr += stride;
700 }
701}
702static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
703 Self* self = (Self*)impl;
704 self->main();
705 self->store_interp_outputs(interps, interp_stride);
706}
707static void init_batch(VertexShaderImpl* impl) {
708 Self* self = (Self*)impl; self->bind_textures(); }
709public:
710ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_vert() {
711 set_uniform_1i_func = &set_uniform_1i;
712 set_uniform_4fv_func = &set_uniform_4fv;
713 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
714 init_batch_func = &init_batch;
715 load_attribs_func = &load_attribs;
716 run_primitive_func = &run;
717 enable_clip_distance();
718}
719};
720
721
722struct ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_frag : FragmentShaderImpl, ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_vert {
723private:
724typedef ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_frag Self;
725#define oFragColorgl_FragColor gl_FragColor
726// vec4 oFragColor;
727// sampler2D sColor0;
728// sampler2D sColor1;
729// sampler2D sColor2;
730struct RectWithSize_scalar {
731vec2_scalar p0;
732vec2_scalar size;
733RectWithSize_scalar() = default;
734RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
735};
736struct RectWithSize {
737vec2 p0;
738vec2 size;
739RectWithSize() = default;
740RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
741RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
742}
743IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
744}
745friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
746if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
747}};
748struct RectWithEndpoint_scalar {
749vec2_scalar p0;
750vec2_scalar p1;
751RectWithEndpoint_scalar() = default;
752RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
753};
754struct RectWithEndpoint {
755vec2 p0;
756vec2 p1;
757RectWithEndpoint() = default;
758RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
759RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
760}
761IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
762}
763friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
764if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
765}};
766// vec4_scalar vTransformBounds;
767// sampler2D sGpuBufferF;
768// isampler2D sGpuBufferI;
769// sampler2D sClipMask;
770struct Fragment_scalar {
771vec4_scalar color;
772Fragment_scalar() = default;
773explicit Fragment_scalar(vec4_scalar color) : color(color){}
774};
775struct Fragment {
776vec4 color;
777Fragment() = default;
778explicit Fragment(vec4 color) : color(color){}
779explicit Fragment(vec4_scalar color):color(color){
780}
781IMPLICIT Fragment(Fragment_scalar s):color(s.color){
782}
783friend Fragment if_then_else(I32 c, Fragment t, Fragment e) { return Fragment(
784if_then_else(c, t.color, e.color));
785}};
786// vec4_scalar v_color;
787// vec3_scalar v_mask_swizzle;
788// vec4_scalar v_uv_bounds;
789vec2 v_uv;
790Fragment text_fs(void) {
791 Fragment frag;
792 vec2 tc = clamp(v_uv, (v_uv_bounds).sel(X,Y), (v_uv_bounds).sel(Z,W));
793 vec4 mask = texture(sColor0, tc);
794 mask = mix(mask, (mask).sel(R,R,R,R), make_bvec4(((v_mask_swizzle).z)!=(0.f)));
795 (mask).lsel(R,G,B) = (((mask).sel(R,G,B))*((v_mask_swizzle).x))+(((mask).sel(A,A,A))*((v_mask_swizzle).y));
796 (frag).color = (v_color)*(mask);
797 return frag;
798}
799float do_clip() {
800 return 1.f;
801}
802void write_output(vec4 color) {
803 oFragColorgl_FragColor = color;
804}
805ALWAYS_INLINE__attribute__((always_inline)) inline void main() {
806 Fragment frag = text_fs();
807 float clip_mask = do_clip();
808 (frag).color *= clip_mask;
809 write_output((frag).color);
810}
811void swgl_drawSpanRGBA8() {
812 if ((((v_mask_swizzle).x)!=(0.f))&&(((v_mask_swizzle).x)!=(1.f))) {
813 {
814 return;
815 }
816 }
817 if (swgl_isTextureR8(sColor0)) {
818 {
819 swgl_commitTextureLinearColorR8ToRGBA8(sColor0, v_uv, v_uv_bounds, v_color)do { auto packed_color = packColor(swgl_OutRGBA8, v_color); int
drawn = 0; if (blend_key) { drawn = blendTextureLinearR8<
true>(sColor0, v_uv, swgl_SpanLength, v_uv_bounds, packed_color
, swgl_OutRGBA8); } else { drawn = blendTextureLinearR8<false
>(sColor0, v_uv, swgl_SpanLength, v_uv_bounds, packed_color
, swgl_OutRGBA8); } swgl_OutRGBA8 += drawn; swgl_SpanLength -=
drawn; } while (0)
;
820 }
821 } else {
822 swgl_commitTextureLinearColorRGBA8(sColor0, v_uv, v_uv_bounds, v_color)do { auto packed_color = packColor(swgl_OutRGBA8, v_color); int
len = (swgl_SpanLength); int drawn = 0; if (LinearFilter filter
= needsTextureLinear(sColor0, v_uv, len)) { if (blend_key) {
drawn = blendTextureLinear<true>(sColor0, v_uv, len, v_uv_bounds
, packed_color, swgl_OutRGBA8, filter); } else { drawn = blendTextureLinear
<false>(sColor0, v_uv, len, v_uv_bounds, packed_color, swgl_OutRGBA8
, filter); } } else if (blend_key) { drawn = blendTextureNearestFast
<true>(sColor0, v_uv, len, v_uv_bounds, packed_color, swgl_OutRGBA8
); } else { drawn = blendTextureNearestFast<false>(sColor0
, v_uv, len, v_uv_bounds, packed_color, swgl_OutRGBA8); } swgl_OutRGBA8
+= drawn; swgl_SpanLength -= drawn; } while (0)
;
823 }
824}
825typedef ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_vert::InterpOutputs InterpInputs;
826InterpInputs interp_step;
827struct InterpPerspective {
828vec2 v_uv;
829};
830InterpPerspective interp_perspective;
831static 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_;
832 self->v_uv = init_interp(init->v_uv, step->v_uv);
833 self->interp_step.v_uv = step->v_uv * 4.0f;
834}
835static 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_;
836 Float w = 1.0f / self->gl_FragCoord.w;
837 self->interp_perspective.v_uv = init_interp(init->v_uv, step->v_uv);
838 self->v_uv = self->interp_perspective.v_uv * w;
839 self->interp_step.v_uv = step->v_uv * 4.0f;
840}
841ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
842 float chunks = steps * 0.25f;
843 v_uv += interp_step.v_uv * chunks;
844}
845ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
846 step_perspective(steps);
847 float chunks = steps * 0.25f;
848 Float w = 1.0f / gl_FragCoord.w;
849 interp_perspective.v_uv += interp_step.v_uv * chunks;
850 v_uv = w * interp_perspective.v_uv;
851}
852static void run(FragmentShaderImpl* impl) {
853 Self* self = (Self*)impl;
854 self->main();
855 self->step_interp_inputs();
856}
857static void skip(FragmentShaderImpl* impl, int steps) {
858 Self* self = (Self*)impl;
859 self->step_interp_inputs(steps);
860}
861static void run_perspective(FragmentShaderImpl* impl) {
862 Self* self = (Self*)impl;
863 self->main();
864 self->step_perspective_inputs();
865}
866static void skip_perspective(FragmentShaderImpl* impl, int steps) {
867 Self* self = (Self*)impl;
868 self->step_perspective_inputs(steps);
869}
870static int draw_span_RGBA8(FragmentShaderImpl* impl) {
871 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)
; }
872public:
873ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_frag() {
874 init_span_func = &read_interp_inputs;
875 run_func = &run;
876 skip_func = &skip;
877 draw_span_RGBA8_func = &draw_span_RGBA8;
878 enable_perspective();
879 init_span_w_func = &read_perspective_inputs;
880 run_w_func = &run_perspective;
881 skip_w_func = &skip_perspective;
882}
883};
884
885struct ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_program : ProgramImpl, ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_frag {
886int get_uniform(const char *name) const override {
887 if (strcmp("sClipMask", name) == 0) { return 8; }
888 if (strcmp("sColor0", name) == 0) { return 9; }
889 if (strcmp("sGpuBufferF", name) == 0) { return 3; }
890 if (strcmp("sGpuBufferI", name) == 0) { return 4; }
891 if (strcmp("sPrimitiveHeadersF", name) == 0) { return 5; }
892 if (strcmp("sPrimitiveHeadersI", name) == 0) { return 6; }
893 if (strcmp("sRenderTasks", name) == 0) { return 1; }
894 if (strcmp("sTransformPalette", name) == 0) { return 2; }
895 if (strcmp("uTransform", name) == 0) { return 7; }
896 return -1;
897}
898void bind_attrib(const char* name, int index) override {
899 attrib_locations.bind_loc(name, index);
900}
901int get_attrib(const char* name) const override {
902 return attrib_locations.get_loc(name);
903}
904size_t interpolants_size() const override { return sizeof(InterpOutputs); }
905VertexShaderImpl* get_vertex_shader() override {
906 return this;
907}
908FragmentShaderImpl* get_fragment_shader() override {
909 return this;
910}
911const char* get_name() const override { return "ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D"; }
912static ProgramImpl* loader() { return new ps_text_run_ALPHA_PASS_GLYPH_TRANSFORM_TEXTURE_2D_program; }
913};
914