Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-6f6517a85091acb7/out/brush_yuv_image_TEXTURE_2D_YUV.h
Warning:line 2, column 8
Excessive padding in 'struct brush_yuv_image_TEXTURE_2D_YUV_common::Samplers' (36 padding bytes, where 4 is optimal). Optimal fields order: sPrimitiveHeadersI_impl, sClipMask_impl, sColor0_impl, sColor1_impl, sColor2_impl, sGpuCache_impl, sPrimitiveHeadersF_impl, sRenderTasks_impl, sTransformPalette_impl, sClipMask_slot, sColor0_slot, sColor1_slot, sColor2_slot, sGpuCache_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 -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=fast -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=/var/lib/jenkins/workspace/firefox-scan-build/gfx/wr/swgl -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/gfx/wr/swgl -resource-dir /usr/lib/llvm-19/lib/clang/19 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -D MOZILLA_CONFIG_H -I /var/lib/jenkins/workspace/firefox-scan-build/gfx/wr/swgl/../webrender/res -I src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-6f6517a85091acb7/out -U MOZILLA_CONFIG_H -D _GLIBCXX_USE_CXX11_ABI=0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -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-deprecated-this-capture -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 -std=c++17 -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 -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-09-22-115206-3586786-1 -x c++ src/gl.cc
1struct brush_yuv_image_TEXTURE_2D_YUV_common {
2struct Samplers {
Excessive padding in 'struct brush_yuv_image_TEXTURE_2D_YUV_common::Samplers' (36 padding bytes, where 4 is optimal). Optimal fields order: sPrimitiveHeadersI_impl, sClipMask_impl, sColor0_impl, sColor1_impl, sColor2_impl, sGpuCache_impl, sPrimitiveHeadersF_impl, sRenderTasks_impl, sTransformPalette_impl, sClipMask_slot, sColor0_slot, sColor1_slot, sColor2_slot, sGpuCache_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 sColor1_impl;
8 int sColor1_slot;
9 sampler2D_impl sColor2_impl;
10 int sColor2_slot;
11 sampler2D_impl sGpuCache_impl;
12 int sGpuCache_slot;
13 sampler2D_impl sPrimitiveHeadersF_impl;
14 int sPrimitiveHeadersF_slot;
15 isampler2D_impl sPrimitiveHeadersI_impl;
16 int sPrimitiveHeadersI_slot;
17 sampler2D_impl sRenderTasks_impl;
18 int sRenderTasks_slot;
19 sampler2D_impl sTransformPalette_impl;
20 int sTransformPalette_slot;
21 bool set_slot(int index, int value) {
22 switch (index) {
23 case 7:
24 sClipMask_slot = value;
25 return true;
26 case 8:
27 sColor0_slot = value;
28 return true;
29 case 9:
30 sColor1_slot = value;
31 return true;
32 case 10:
33 sColor2_slot = value;
34 return true;
35 case 2:
36 sGpuCache_slot = value;
37 return true;
38 case 4:
39 sPrimitiveHeadersF_slot = value;
40 return true;
41 case 5:
42 sPrimitiveHeadersI_slot = value;
43 return true;
44 case 1:
45 sRenderTasks_slot = value;
46 return true;
47 case 3:
48 sTransformPalette_slot = value;
49 return true;
50 }
51 return false;
52 }
53} samplers;
54struct AttribLocations {
55 int aPosition = NULL_ATTRIB16;
56 int aData = NULL_ATTRIB16;
57 void bind_loc(const char* name, int index) {
58 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
59 if (strcmp("aData", name) == 0) { aData = index; return; }
60 }
61 int get_loc(const char* name) const {
62 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
63 if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; }
64 return -1;
65 }
66} attrib_locations;
67vec4_scalar vTransformBounds;
68vec4_scalar vUvBounds_Y;
69vec4_scalar vUvBounds_U;
70vec4_scalar vUvBounds_V;
71vec3_scalar vYcbcrBias;
72mat3_scalar vRgbFromDebiasedYcbcr;
73ivec2_scalar vFormat;
74int32_t vRescaleFactor;
75sampler2D sClipMask;
76sampler2D sColor0;
77sampler2D sColor1;
78sampler2D sColor2;
79sampler2D sGpuCache;
80sampler2D sPrimitiveHeadersF;
81isampler2D sPrimitiveHeadersI;
82sampler2D sRenderTasks;
83sampler2D sTransformPalette;
84mat4_scalar uTransform;
85void bind_textures() {
86 sClipMask = lookup_sampler(&samplers.sClipMask_impl, samplers.sClipMask_slot);
87 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
88 sColor1 = lookup_sampler(&samplers.sColor1_impl, samplers.sColor1_slot);
89 sColor2 = lookup_sampler(&samplers.sColor2_impl, samplers.sColor2_slot);
90 sGpuCache = lookup_sampler(&samplers.sGpuCache_impl, samplers.sGpuCache_slot);
91 sPrimitiveHeadersF = lookup_sampler(&samplers.sPrimitiveHeadersF_impl, samplers.sPrimitiveHeadersF_slot);
92 sPrimitiveHeadersI = lookup_isampler(&samplers.sPrimitiveHeadersI_impl, samplers.sPrimitiveHeadersI_slot);
93 sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot);
94 sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot);
95}
96};
97struct brush_yuv_image_TEXTURE_2D_YUV_vert : VertexShaderImpl, brush_yuv_image_TEXTURE_2D_YUV_common {
98private:
99typedef brush_yuv_image_TEXTURE_2D_YUV_vert Self;
100// mat4_scalar uTransform;
101vec2 aPosition;
102// sampler2D sColor0;
103// sampler2D sColor1;
104// sampler2D sColor2;
105struct RectWithSize_scalar {
106vec2_scalar p0;
107vec2_scalar size;
108RectWithSize_scalar() = default;
109RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
110};
111struct RectWithSize {
112vec2 p0;
113vec2 size;
114RectWithSize() = default;
115RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
116RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
117}
118IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
119}
120friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
121if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
122}};
123struct RectWithEndpoint_scalar {
124vec2_scalar p0;
125vec2_scalar p1;
126RectWithEndpoint_scalar() = default;
127RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
128};
129struct RectWithEndpoint {
130vec2 p0;
131vec2 p1;
132RectWithEndpoint() = default;
133RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
134RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
135}
136IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
137}
138friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
139if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
140}};
141// sampler2D sRenderTasks;
142struct RenderTaskData_scalar {
143RectWithEndpoint_scalar task_rect;
144vec4_scalar user_data;
145RenderTaskData_scalar() = default;
146RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){}
147};
148struct RenderTaskData {
149RectWithEndpoint task_rect;
150vec4 user_data;
151RenderTaskData() = default;
152RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){}
153RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){
154}
155IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){
156}
157friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData(
158if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data));
159}};
160struct PictureTask_scalar {
161RectWithEndpoint_scalar task_rect;
162float device_pixel_scale;
163vec2_scalar content_origin;
164PictureTask_scalar() = default;
165PictureTask_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){}
166};
167struct PictureTask {
168RectWithEndpoint task_rect;
169Float device_pixel_scale;
170vec2 content_origin;
171PictureTask() = default;
172PictureTask(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
173PictureTask(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){
174}
175IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){
176}
177friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask(
178if_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));
179}};
180struct ClipArea_scalar {
181RectWithEndpoint_scalar task_rect;
182float device_pixel_scale;
183vec2_scalar screen_origin;
184ClipArea_scalar() = default;
185ClipArea_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){}
186};
187struct ClipArea {
188RectWithEndpoint task_rect;
189Float device_pixel_scale;
190vec2 screen_origin;
191ClipArea() = default;
192ClipArea(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
193ClipArea(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){
194}
195IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){
196}
197friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea(
198if_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));
199}};
200// sampler2D sGpuCache;
201struct ImageSource_scalar {
202RectWithEndpoint_scalar uv_rect;
203vec4_scalar user_data;
204ImageSource_scalar() = default;
205ImageSource_scalar(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data) : uv_rect(uv_rect), user_data(user_data){}
206};
207struct ImageSource {
208RectWithEndpoint uv_rect;
209vec4 user_data;
210ImageSource() = default;
211ImageSource(RectWithEndpoint uv_rect, vec4 user_data) : uv_rect(uv_rect), user_data(user_data){}
212ImageSource(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data):uv_rect(uv_rect),user_data(user_data){
213}
214IMPLICIT ImageSource(ImageSource_scalar s):uv_rect(s.uv_rect),user_data(s.user_data){
215}
216friend ImageSource if_then_else(I32 c, ImageSource t, ImageSource e) { return ImageSource(
217if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.user_data, e.user_data));
218}};
219struct ImageSourceExtra_scalar {
220vec4_scalar st_tl;
221vec4_scalar st_tr;
222vec4_scalar st_bl;
223vec4_scalar st_br;
224ImageSourceExtra_scalar() = default;
225ImageSourceExtra_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){}
226};
227struct ImageSourceExtra {
228vec4 st_tl;
229vec4 st_tr;
230vec4 st_bl;
231vec4 st_br;
232ImageSourceExtra() = default;
233ImageSourceExtra(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){}
234ImageSourceExtra(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){
235}
236IMPLICIT ImageSourceExtra(ImageSourceExtra_scalar s):st_tl(s.st_tl),st_tr(s.st_tr),st_bl(s.st_bl),st_br(s.st_br){
237}
238friend ImageSourceExtra if_then_else(I32 c, ImageSourceExtra t, ImageSourceExtra e) { return ImageSourceExtra(
239if_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));
240}};
241// vec4_scalar vTransformBounds;
242// sampler2D sTransformPalette;
243struct Transform_scalar {
244mat4_scalar m;
245mat4_scalar inv_m;
246bool is_axis_aligned;
247Transform_scalar() = default;
248Transform_scalar(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
249};
250struct Transform {
251mat4 m;
252mat4 inv_m;
253Bool is_axis_aligned;
254Transform() = default;
255Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
256Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){
257}
258IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){
259}
260friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform(
261if_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));
262}};
263// sampler2D sClipMask;
264// sampler2D sPrimitiveHeadersF;
265// isampler2D sPrimitiveHeadersI;
266ivec4_scalar aData;
267struct Instance_scalar {
268int32_t prim_header_address;
269int32_t clip_address;
270int32_t segment_index;
271int32_t flags;
272int32_t resource_address;
273int32_t brush_kind;
274Instance_scalar() = default;
275Instance_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){}
276};
277struct Instance {
278I32 prim_header_address;
279I32 clip_address;
280I32 segment_index;
281I32 flags;
282I32 resource_address;
283I32 brush_kind;
284Instance() = default;
285Instance(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){}
286Instance(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){
287}
288IMPLICIT 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){
289}
290friend Instance if_then_else(I32 c, Instance t, Instance e) { return Instance(
291if_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));
292}};
293struct PrimitiveHeader_scalar {
294RectWithEndpoint_scalar local_rect;
295RectWithEndpoint_scalar local_clip_rect;
296float z;
297int32_t specific_prim_address;
298int32_t transform_id;
299int32_t picture_task_address;
300ivec4_scalar user_data;
301PrimitiveHeader_scalar() = default;
302PrimitiveHeader_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){}
303};
304struct PrimitiveHeader {
305RectWithEndpoint local_rect;
306RectWithEndpoint local_clip_rect;
307Float z;
308I32 specific_prim_address;
309I32 transform_id;
310I32 picture_task_address;
311ivec4 user_data;
312PrimitiveHeader() = default;
313PrimitiveHeader(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){}
314PrimitiveHeader(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){
315}
316IMPLICIT 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){
317}
318friend PrimitiveHeader if_then_else(I32 c, PrimitiveHeader t, PrimitiveHeader e) { return PrimitiveHeader(
319if_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));
320}};
321struct VertexInfo_scalar {
322vec2_scalar local_pos;
323vec4_scalar world_pos;
324VertexInfo_scalar() = default;
325VertexInfo_scalar(vec2_scalar local_pos, vec4_scalar world_pos) : local_pos(local_pos), world_pos(world_pos){}
326};
327struct VertexInfo {
328vec2 local_pos;
329vec4 world_pos;
330VertexInfo() = default;
331VertexInfo(vec2 local_pos, vec4 world_pos) : local_pos(local_pos), world_pos(world_pos){}
332VertexInfo(vec2_scalar local_pos, vec4_scalar world_pos):local_pos(local_pos),world_pos(world_pos){
333}
334IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos),world_pos(s.world_pos){
335}
336friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo(
337if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.world_pos, e.world_pos));
338}};
339mat3_scalar static constexpr RgbFromYuv_Rec601 = make_mat3(1.f, 1.f, 1.f, 0.f, -(0.17207f), 0.886f, 0.701f, -(0.35707f), 0.f);
340mat3_scalar static constexpr RgbFromYuv_Rec709 = make_mat3(1.f, 1.f, 1.f, 0.f, -(0.09366f), 0.9278f, 0.7874f, -(0.23406f), 0.f);
341mat3_scalar static constexpr RgbFromYuv_Rec2020 = make_mat3(1.f, 1.f, 1.f, 0.f, -(0.08228f), 0.9407f, 0.7373f, -(0.28568f), 0.f);
342mat3_scalar static constexpr RgbFromYuv_GbrIdentity = make_mat3(0.f, 1.f, 0.f, 0.f, 0.f, 1.f, 1.f, 0.f, 0.f);
343struct YuvPrimitive_scalar {
344int32_t channel_bit_depth;
345int32_t color_space;
346int32_t yuv_format;
347YuvPrimitive_scalar() = default;
348YuvPrimitive_scalar(int32_t channel_bit_depth, int32_t color_space, int32_t yuv_format) : channel_bit_depth(channel_bit_depth), color_space(color_space), yuv_format(yuv_format){}
349};
350struct YuvPrimitive {
351I32 channel_bit_depth;
352I32 color_space;
353I32 yuv_format;
354YuvPrimitive() = default;
355YuvPrimitive(I32 channel_bit_depth, I32 color_space, I32 yuv_format) : channel_bit_depth(channel_bit_depth), color_space(color_space), yuv_format(yuv_format){}
356YuvPrimitive(int32_t channel_bit_depth, int32_t color_space, int32_t yuv_format):channel_bit_depth(channel_bit_depth),color_space(color_space),yuv_format(yuv_format){
357}
358IMPLICIT YuvPrimitive(YuvPrimitive_scalar s):channel_bit_depth(s.channel_bit_depth),color_space(s.color_space),yuv_format(s.yuv_format){
359}
360friend YuvPrimitive if_then_else(I32 c, YuvPrimitive t, YuvPrimitive e) { return YuvPrimitive(
361if_then_else(c, t.channel_bit_depth, e.channel_bit_depth), if_then_else(c, t.color_space, e.color_space), if_then_else(c, t.yuv_format, e.yuv_format));
362}};
363struct YuvColorSamplingInfo_scalar {
364mat3_scalar rgb_from_yuv;
365vec4_scalar packed_zero_one_vals;
366YuvColorSamplingInfo_scalar() = default;
367YuvColorSamplingInfo_scalar(mat3_scalar rgb_from_yuv, vec4_scalar packed_zero_one_vals) : rgb_from_yuv(rgb_from_yuv), packed_zero_one_vals(packed_zero_one_vals){}
368};
369struct YuvColorSamplingInfo {
370mat3 rgb_from_yuv;
371vec4 packed_zero_one_vals;
372YuvColorSamplingInfo() = default;
373YuvColorSamplingInfo(mat3 rgb_from_yuv, vec4 packed_zero_one_vals) : rgb_from_yuv(rgb_from_yuv), packed_zero_one_vals(packed_zero_one_vals){}
374YuvColorSamplingInfo(mat3_scalar rgb_from_yuv, vec4_scalar packed_zero_one_vals):rgb_from_yuv(rgb_from_yuv),packed_zero_one_vals(packed_zero_one_vals){
375}
376IMPLICIT YuvColorSamplingInfo(YuvColorSamplingInfo_scalar s):rgb_from_yuv(s.rgb_from_yuv),packed_zero_one_vals(s.packed_zero_one_vals){
377}
378friend YuvColorSamplingInfo if_then_else(I32 c, YuvColorSamplingInfo t, YuvColorSamplingInfo e) { return YuvColorSamplingInfo(
379if_then_else(c, t.rgb_from_yuv, e.rgb_from_yuv), if_then_else(c, t.packed_zero_one_vals, e.packed_zero_one_vals));
380}};
381struct YuvColorMatrixInfo_scalar {
382vec3_scalar ycbcr_bias;
383mat3_scalar rgb_from_debiased_ycbrc;
384YuvColorMatrixInfo_scalar() = default;
385YuvColorMatrixInfo_scalar(vec3_scalar ycbcr_bias, mat3_scalar rgb_from_debiased_ycbrc) : ycbcr_bias(ycbcr_bias), rgb_from_debiased_ycbrc(rgb_from_debiased_ycbrc){}
386};
387struct YuvColorMatrixInfo {
388vec3 ycbcr_bias;
389mat3 rgb_from_debiased_ycbrc;
390YuvColorMatrixInfo() = default;
391YuvColorMatrixInfo(vec3 ycbcr_bias, mat3 rgb_from_debiased_ycbrc) : ycbcr_bias(ycbcr_bias), rgb_from_debiased_ycbrc(rgb_from_debiased_ycbrc){}
392YuvColorMatrixInfo(vec3_scalar ycbcr_bias, mat3_scalar rgb_from_debiased_ycbrc):ycbcr_bias(ycbcr_bias),rgb_from_debiased_ycbrc(rgb_from_debiased_ycbrc){
393}
394IMPLICIT YuvColorMatrixInfo(YuvColorMatrixInfo_scalar s):ycbcr_bias(s.ycbcr_bias),rgb_from_debiased_ycbrc(s.rgb_from_debiased_ycbrc){
395}
396friend YuvColorMatrixInfo if_then_else(I32 c, YuvColorMatrixInfo t, YuvColorMatrixInfo e) { return YuvColorMatrixInfo(
397if_then_else(c, t.ycbcr_bias, e.ycbcr_bias), if_then_else(c, t.rgb_from_debiased_ycbrc, e.rgb_from_debiased_ycbrc));
398}};
399vec2 vUv_Y;
400// vec4_scalar vUvBounds_Y;
401vec2 vUv_U;
402// vec4_scalar vUvBounds_U;
403vec2 vUv_V;
404// vec4_scalar vUvBounds_V;
405// vec3_scalar vYcbcrBias;
406// mat3_scalar vRgbFromDebiasedYcbcr;
407// ivec2_scalar vFormat;
408// int32_t vRescaleFactor;
409Instance_scalar decode_instance_attributes() {
410 Instance_scalar instance;
411 (instance).prim_header_address = (aData).x;
412 (instance).clip_address = (aData).y;
413 (instance).segment_index = ((aData).z)&(65535);
414 (instance).flags = ((aData).z)>>(16);
415 (instance).resource_address = ((aData).w)&(16777215);
416 (instance).brush_kind = ((aData).w)>>(24);
417 return instance;
418}
419PrimitiveHeader_scalar fetch_prim_header(int32_t index) {
420 PrimitiveHeader_scalar ph;
421 ivec2_scalar uv_f = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
422 auto sPrimitiveHeadersF_uv_f_fetch = texelFetchPtr(sPrimitiveHeadersF, uv_f, 0, 1, 0, 0);
423 vec4_scalar local_rect = texelFetchUnchecked(sPrimitiveHeadersF, sPrimitiveHeadersF_uv_f_fetch, 0, 0);
424 vec4_scalar local_clip_rect = texelFetchUnchecked(sPrimitiveHeadersF, sPrimitiveHeadersF_uv_f_fetch, 1, 0);
425 (ph).local_rect = RectWithEndpoint_scalar((local_rect).sel(X,Y), (local_rect).sel(Z,W));
426 (ph).local_clip_rect = RectWithEndpoint_scalar((local_clip_rect).sel(X,Y), (local_clip_rect).sel(Z,W));
427 ivec2_scalar uv_i = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
428 auto sPrimitiveHeadersI_uv_i_fetch = texelFetchPtr(sPrimitiveHeadersI, uv_i, 0, 1, 0, 0);
429 ivec4_scalar data0 = texelFetchUnchecked(sPrimitiveHeadersI, sPrimitiveHeadersI_uv_i_fetch, 0, 0);
430 ivec4_scalar data1 = texelFetchUnchecked(sPrimitiveHeadersI, sPrimitiveHeadersI_uv_i_fetch, 1, 0);
431 (ph).z = make_float((data0).x);
432 (ph).specific_prim_address = (data0).y;
433 (ph).transform_id = (data0).z;
434 (ph).picture_task_address = (data0).w;
435 (ph).user_data = data1;
436 return ph;
437}
438Transform_scalar fetch_transform(int32_t id) {
439 Transform_scalar transform;
440 (transform).is_axis_aligned = ((id)>>(23))==(0);
441 int32_t index = (id)&(8388607);
442 ivec2_scalar uv = make_ivec2(make_int((8u)*((make_uint(index))%((1024u)/(8u)))), make_int((make_uint(index))/((1024u)/(8u))));
443 ivec2_scalar uv0 = make_ivec2(((uv).x)+(0), (uv).y);
444 auto sTransformPalette_uv0_fetch = texelFetchPtr(sTransformPalette, uv0, 0, 7, 0, 0);
445 (transform).m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 0, 0);
446 (transform).m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 1, 0);
447 (transform).m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 2, 0);
448 (transform).m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 3, 0);
449 (transform).inv_m[0] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 4, 0);
450 (transform).inv_m[1] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 5, 0);
451 (transform).inv_m[2] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 6, 0);
452 (transform).inv_m[3] = texelFetchUnchecked(sTransformPalette, sTransformPalette_uv0_fetch, 7, 0);
453 return transform;
454}
455RenderTaskData_scalar fetch_render_task_data(int32_t index) {
456 ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
457 auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0);
458 vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0);
459 vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0);
460 RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W));
461 RenderTaskData_scalar data = RenderTaskData_scalar(task_rect, texel1);
462 return data;
463}
464PictureTask_scalar fetch_picture_task(int32_t address) {
465 RenderTaskData_scalar task_data = fetch_render_task_data(address);
466 PictureTask_scalar task = PictureTask_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
467 return task;
468}
469ClipArea_scalar fetch_clip_area(int32_t index) {
470 RenderTaskData_scalar task_data;
471 if ((index)>=(2147483647)) {
472 {
473 task_data = RenderTaskData_scalar(RectWithEndpoint_scalar(make_vec2(0.f), make_vec2(0.f)), make_vec4(0.f));
474 }
475 } else {
476 task_data = fetch_render_task_data(index);
477 }
478 return ClipArea_scalar((task_data).task_rect, ((task_data).user_data).x, ((task_data).user_data).sel(Y,Z));
479}
480ivec2_scalar get_gpu_cache_uv(int32_t address) {
481 return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u));
482}
483Array<vec4_scalar,2> fetch_from_gpu_cache_2(int32_t address) {
484 ivec2_scalar uv = get_gpu_cache_uv(address);
485 auto sGpuCache_uv_fetch = texelFetchPtr(sGpuCache, uv, 0, 1, 0, 0);
486 return Array<vec4_scalar,2>{{texelFetchUnchecked(sGpuCache, sGpuCache_uv_fetch, 0, 0), texelFetchUnchecked(sGpuCache, sGpuCache_uv_fetch, 1, 0)}};
487}
488RectWithEndpoint_scalar clip_and_init_antialiasing(RectWithEndpoint_scalar segment_rect, RectWithEndpoint_scalar prim_rect, RectWithEndpoint_scalar clip_rect, int32_t edge_flags, float z, Transform_scalar transform, PictureTask_scalar task) {
489 bvec4_scalar clipped = make_bvec4(greaterThan((clip_rect).p0, (segment_rect).p0), lessThan((clip_rect).p1, (segment_rect).p1));
490 swgl_antiAlias((edge_flags)|(((clipped).x ? 1 : 0)|(((clipped).y ? 2 : 0)|(((clipped).z ? 4 : 0)|((clipped).w ? 8 : 0)))))do { swgl_AAEdgeMask = calcAAEdgeMask((edge_flags)|(((clipped
).x ? 1 : 0)|(((clipped).y ? 2 : 0)|(((clipped).z ? 4 : 0)|((
clipped).w ? 8 : 0))))); if (swgl_AAEdgeMask) { swgl_ClipFlags
|= SWGL_CLIP_FLAG_AA; } } while (0)
;
491 (segment_rect).p0 = clamp((segment_rect).p0, (clip_rect).p0, (clip_rect).p1);
492 (segment_rect).p1 = clamp((segment_rect).p1, (clip_rect).p0, (clip_rect).p1);
493 return segment_rect;
494}
495vec2 rect_clamp(RectWithEndpoint_scalar rect, vec2 pt) {
496 return clamp(pt, (rect).p0, (rect).p1);
497}
498VertexInfo write_vertex(vec2 local_pos, RectWithEndpoint_scalar local_clip_rect, float z, Transform_scalar transform, PictureTask_scalar task) {
499 vec2 clamped_local_pos = rect_clamp(local_clip_rect, local_pos);
500 vec4 world_pos = ((transform).m)*(make_vec4(clamped_local_pos, 0.f, 1.f));
501 vec2 device_pos = ((world_pos).sel(X,Y))*((task).device_pixel_scale);
502 vec2_scalar final_offset = (-((task).content_origin))+(((task).task_rect).p0);
503 gl_Position = (uTransform)*(make_vec4((device_pos)+((final_offset)*((world_pos).w)), (z)*((world_pos).w), (world_pos).w));
504 VertexInfo vi = VertexInfo(clamped_local_pos, world_pos);
505 return vi;
506}
507vec2_scalar rect_size(RectWithEndpoint_scalar rect) {
508 return ((rect).p1)-((rect).p0);
509}
510void write_clip(vec4 world_pos, ClipArea_scalar area, PictureTask_scalar task) {
511 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
)
;
512}
513vec4_scalar fetch_from_gpu_cache_1(int32_t address) {
514 ivec2_scalar uv = get_gpu_cache_uv(address);
515 return texelFetch(sGpuCache, uv, 0);
516}
517YuvPrimitive_scalar fetch_yuv_primitive(int32_t address) {
518 vec4_scalar data = fetch_from_gpu_cache_1(address);
519 int32_t channel_bit_depth = make_int((data).x);
520 int32_t color_space = make_int((data).y);
521 int32_t yuv_format = make_int((data).z);
522 return YuvPrimitive_scalar(channel_bit_depth, color_space, yuv_format);
523}
524vec4_scalar yuv_channel_zero_one_narrow_range(int32_t bit_depth, float channel_max) {
525 ivec4_scalar zero_one_ints = (make_ivec4(16, 128, 235, 240))<<((bit_depth)-(8));
526 return (make_vec4(zero_one_ints))/(channel_max);
527}
528vec4_scalar yuv_channel_zero_one_identity(int32_t bit_depth, float channel_max) {
529 float all_ones_normalized = (make_float(((1)<<(bit_depth))-(1)))/(channel_max);
530 return make_vec4(0.f, 0.f, all_ones_normalized, all_ones_normalized);
531}
532vec4_scalar yuv_channel_zero_one_full_range(int32_t bit_depth, float channel_max) {
533 vec4_scalar narrow = yuv_channel_zero_one_narrow_range(bit_depth, channel_max);
534 vec4_scalar identity = yuv_channel_zero_one_identity(bit_depth, channel_max);
535 return make_vec4(0.f, (narrow).y, (identity).z, (identity).w);
536}
537YuvColorSamplingInfo_scalar get_yuv_color_info(YuvPrimitive_scalar prim) {
538 float channel_max = 255.f;
539 if (((prim).channel_bit_depth)>(8)) {
540 {
541 if (((prim).yuv_format)==(1)) {
542 {
543 channel_max = make_float(((1)<<((prim).channel_bit_depth))-(1));
544 }
545 } else {
546 channel_max = 65535.f;
547 }
548 }
549 }
550 if (((prim).color_space)==(0)) {
551 {
552 return YuvColorSamplingInfo_scalar(RgbFromYuv_Rec601, yuv_channel_zero_one_narrow_range((prim).channel_bit_depth, channel_max));
553 }
554 } else if (((prim).color_space)==(1)) {
555 {
556 return YuvColorSamplingInfo_scalar(RgbFromYuv_Rec601, yuv_channel_zero_one_full_range((prim).channel_bit_depth, channel_max));
557 }
558 } else if (((prim).color_space)==(2)) {
559 {
560 return YuvColorSamplingInfo_scalar(RgbFromYuv_Rec709, yuv_channel_zero_one_narrow_range((prim).channel_bit_depth, channel_max));
561 }
562 } else if (((prim).color_space)==(3)) {
563 {
564 return YuvColorSamplingInfo_scalar(RgbFromYuv_Rec709, yuv_channel_zero_one_full_range((prim).channel_bit_depth, channel_max));
565 }
566 } else if (((prim).color_space)==(4)) {
567 {
568 return YuvColorSamplingInfo_scalar(RgbFromYuv_Rec2020, yuv_channel_zero_one_narrow_range((prim).channel_bit_depth, channel_max));
569 }
570 } else if (((prim).color_space)==(5)) {
571 {
572 return YuvColorSamplingInfo_scalar(RgbFromYuv_Rec2020, yuv_channel_zero_one_full_range((prim).channel_bit_depth, channel_max));
573 }
574 } else {
575 return YuvColorSamplingInfo_scalar(RgbFromYuv_GbrIdentity, yuv_channel_zero_one_identity((prim).channel_bit_depth, channel_max));
576 }
577}
578YuvColorMatrixInfo_scalar get_rgb_from_ycbcr_info(YuvPrimitive_scalar prim) {
579 YuvColorSamplingInfo_scalar info = get_yuv_color_info(prim);
580 vec2_scalar zero = ((info).packed_zero_one_vals).sel(X,Y);
581 vec2_scalar one = ((info).packed_zero_one_vals).sel(Z,W);
582 vec2_scalar scale = (1.f)/((one)-(zero));
583 YuvColorMatrixInfo_scalar mat_info;
584 (mat_info).ycbcr_bias = (zero).sel(X,Y,Y);
585 mat3_scalar yuv_from_debiased_ycbcr = make_mat3((scale).x, 0.f, 0.f, 0.f, (scale).y, 0.f, 0.f, 0.f, (scale).y);
586 (mat_info).rgb_from_debiased_ycbrc = ((info).rgb_from_yuv)*(yuv_from_debiased_ycbcr);
587 return mat_info;
588}
589ImageSource_scalar fetch_image_source(int32_t address) {
590 Array<vec4_scalar,2> data = fetch_from_gpu_cache_2(address);
591 RectWithEndpoint_scalar uv_rect = RectWithEndpoint_scalar((data[0]).sel(X,Y), (data[0]).sel(Z,W));
592 return ImageSource_scalar(uv_rect, data[1]);
593}
594void write_uv_rect(vec2_scalar uv0, vec2_scalar uv1, vec2 f, vec2_scalar texture_size, vec2& uv, vec4_scalar& uv_bounds) {
595 uv = mix(uv0, uv1, f);
596 uv_bounds = make_vec4((uv0)+(make_vec2(0.5f)), (uv1)-(make_vec2(0.5f)));
597 uv /= texture_size;
598 uv_bounds /= (texture_size).sel(X,Y,X,Y);
599}
600void brush_vs(VertexInfo vi, int32_t prim_address, RectWithEndpoint_scalar local_rect, RectWithEndpoint_scalar segment_rect, ivec4_scalar prim_user_data, int32_t specific_resource_address, mat4_scalar transform, PictureTask_scalar pic_task, int32_t brush_flags, vec4_scalar unused) {
601 vec2 f = (((vi).local_pos)-((local_rect).p0))/(rect_size(local_rect));
602 YuvPrimitive_scalar prim = fetch_yuv_primitive(prim_address);
603 vRescaleFactor = 0;
604 if ((((prim).channel_bit_depth)>(8))&&(((prim).yuv_format)!=(1))) {
605 {
606 vRescaleFactor = (16)-((prim).channel_bit_depth);
607 }
608 }
609 YuvColorMatrixInfo_scalar mat_info = get_rgb_from_ycbcr_info(prim);
610 vYcbcrBias = (mat_info).ycbcr_bias;
611 vRgbFromDebiasedYcbcr = (mat_info).rgb_from_debiased_ycbrc;
612 (vFormat).x = (prim).yuv_format;
613 if ((((vFormat).x)==(3))||(((vFormat).x)==(99))) {
614 {
615 ImageSource_scalar res_y = fetch_image_source((prim_user_data).x);
616 ImageSource_scalar res_u = fetch_image_source((prim_user_data).y);
617 ImageSource_scalar res_v = fetch_image_source((prim_user_data).z);
618 write_uv_rect(((res_y).uv_rect).p0, ((res_y).uv_rect).p1, f, make_vec2((textureSize(sColor0, 0)).sel(X,Y)), vUv_Y, vUvBounds_Y);
619 write_uv_rect(((res_u).uv_rect).p0, ((res_u).uv_rect).p1, f, make_vec2((textureSize(sColor1, 0)).sel(X,Y)), vUv_U, vUvBounds_U);
620 write_uv_rect(((res_v).uv_rect).p0, ((res_v).uv_rect).p1, f, make_vec2((textureSize(sColor2, 0)).sel(X,Y)), vUv_V, vUvBounds_V);
621 }
622 } else if ((((vFormat).x)==(0))||(((vFormat).x)==(1))) {
623 {
624 ImageSource_scalar res_y = fetch_image_source((prim_user_data).x);
625 ImageSource_scalar res_u = fetch_image_source((prim_user_data).y);
626 write_uv_rect(((res_y).uv_rect).p0, ((res_y).uv_rect).p1, f, make_vec2((textureSize(sColor0, 0)).sel(X,Y)), vUv_Y, vUvBounds_Y);
627 write_uv_rect(((res_u).uv_rect).p0, ((res_u).uv_rect).p1, f, make_vec2((textureSize(sColor1, 0)).sel(X,Y)), vUv_U, vUvBounds_U);
628 }
629 } else if (((vFormat).x)==(4)) {
630 {
631 ImageSource_scalar res_y = fetch_image_source((prim_user_data).x);
632 write_uv_rect(((res_y).uv_rect).p0, ((res_y).uv_rect).p1, f, make_vec2((textureSize(sColor0, 0)).sel(X,Y)), vUv_Y, vUvBounds_Y);
633 }
634 }
635}
636void brush_shader_main_vs(Instance_scalar instance, PrimitiveHeader_scalar ph, Transform_scalar transform, PictureTask_scalar pic_task, ClipArea_scalar clip_area) {
637 int32_t edge_flags = (((instance).flags)>>(12))&(15);
638 int32_t brush_flags = ((instance).flags)&(4095);
639 vec4_scalar segment_data;
640 RectWithEndpoint_scalar segment_rect;
641 if (((instance).segment_index)==(65535)) {
642 {
643 segment_rect = (ph).local_rect;
644 segment_data = make_vec4(0.f);
645 }
646 } else {
647 int32_t segment_address = (((ph).specific_prim_address)+(1))+(((instance).segment_index)*(2));
648 Array<vec4_scalar,2> segment_info = fetch_from_gpu_cache_2(segment_address);
649 segment_rect = RectWithEndpoint_scalar((segment_info[0]).sel(X,Y), (segment_info[0]).sel(Z,W));
650 (segment_rect).p0 += ((ph).local_rect).p0;
651 (segment_rect).p1 += ((ph).local_rect).p0;
652 segment_data = segment_info[1];
653 }
654 RectWithEndpoint_scalar adjusted_segment_rect = segment_rect;
655 bool antialiased = (!((transform).is_axis_aligned))||(((brush_flags)&(1024))!=(0));
656 if (antialiased) {
657 {
658 adjusted_segment_rect = clip_and_init_antialiasing(segment_rect, (ph).local_rect, (ph).local_clip_rect, edge_flags, (ph).z, transform, pic_task);
659 ((ph).local_clip_rect).p0 = make_vec2(-(10000000000000000.f));
660 ((ph).local_clip_rect).p1 = make_vec2(10000000000000000.f);
661 }
662 } else {
663 }
664 vec2 local_pos = mix((adjusted_segment_rect).p0, (adjusted_segment_rect).p1, (aPosition).sel(X,Y));
665 VertexInfo vi = write_vertex(local_pos, (ph).local_clip_rect, (ph).z, transform, pic_task);
666 write_clip((vi).world_pos, clip_area, pic_task);
667 brush_vs(vi, (ph).specific_prim_address, (ph).local_rect, segment_rect, (ph).user_data, (instance).resource_address, (transform).m, pic_task, brush_flags, segment_data);
668}
669ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
670 Instance_scalar instance = decode_instance_attributes();
671 PrimitiveHeader_scalar ph = fetch_prim_header((instance).prim_header_address);
672 Transform_scalar transform = fetch_transform((ph).transform_id);
673 PictureTask_scalar task = fetch_picture_task((ph).picture_task_address);
674 ClipArea_scalar clip_area = fetch_clip_area((instance).clip_address);
675 brush_shader_main_vs(instance, ph, transform, task, clip_area);
676}
677static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
678 Self* self = (Self*)impl;
679 if (self->samplers.set_slot(index, value)) return;
680 switch (index) {
681 case 7:
682 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
683 break;
684 case 8:
685 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
686 break;
687 case 9:
688 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
689 break;
690 case 10:
691 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor2
692 break;
693 case 2:
694 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuCache
695 break;
696 case 4:
697 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
698 break;
699 case 5:
700 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
701 break;
702 case 1:
703 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
704 break;
705 case 3:
706 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
707 break;
708 case 6:
709 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
710 break;
711 }
712}
713static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
714 Self* self = (Self*)impl;
715 switch (index) {
716 case 7:
717 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
718 break;
719 case 8:
720 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
721 break;
722 case 9:
723 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
724 break;
725 case 10:
726 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor2
727 break;
728 case 2:
729 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuCache
730 break;
731 case 4:
732 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
733 break;
734 case 5:
735 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
736 break;
737 case 1:
738 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
739 break;
740 case 3:
741 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
742 break;
743 case 6:
744 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
745 break;
746 }
747}
748static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
749 Self* self = (Self*)impl;
750 switch (index) {
751 case 7:
752 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
753 break;
754 case 8:
755 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
756 break;
757 case 9:
758 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
759 break;
760 case 10:
761 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor2
762 break;
763 case 2:
764 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuCache
765 break;
766 case 4:
767 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
768 break;
769 case 5:
770 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
771 break;
772 case 1:
773 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
774 break;
775 case 3:
776 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
777 break;
778 case 6:
779 self->uTransform = mat4_scalar::load_from_ptr(value);
780 break;
781 }
782}
783static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
784 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
785 load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count);
786}
787public:
788struct InterpOutputs {
789vec2_scalar vUv_Y;
790vec2_scalar vUv_U;
791vec2_scalar vUv_V;
792};
793private:
794ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
795 for(int n = 0; n < 4; n++) {
796 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
797 dest->vUv_Y = get_nth(vUv_Y, n);
798 dest->vUv_U = get_nth(vUv_U, n);
799 dest->vUv_V = get_nth(vUv_V, n);
800 dest_ptr += stride;
801 }
802}
803static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
804 Self* self = (Self*)impl;
805 self->main();
806 self->store_interp_outputs(interps, interp_stride);
807}
808static void init_batch(VertexShaderImpl* impl) {
809 Self* self = (Self*)impl; self->bind_textures(); }
810public:
811brush_yuv_image_TEXTURE_2D_YUV_vert() {
812 set_uniform_1i_func = &set_uniform_1i;
813 set_uniform_4fv_func = &set_uniform_4fv;
814 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
815 init_batch_func = &init_batch;
816 load_attribs_func = &load_attribs;
817 run_primitive_func = &run;
818}
819};
820
821mat3_scalar constexpr brush_yuv_image_TEXTURE_2D_YUV_vert::RgbFromYuv_Rec601;
822mat3_scalar constexpr brush_yuv_image_TEXTURE_2D_YUV_vert::RgbFromYuv_Rec709;
823mat3_scalar constexpr brush_yuv_image_TEXTURE_2D_YUV_vert::RgbFromYuv_Rec2020;
824mat3_scalar constexpr brush_yuv_image_TEXTURE_2D_YUV_vert::RgbFromYuv_GbrIdentity;
825
826struct brush_yuv_image_TEXTURE_2D_YUV_frag : FragmentShaderImpl, brush_yuv_image_TEXTURE_2D_YUV_vert {
827private:
828typedef brush_yuv_image_TEXTURE_2D_YUV_frag Self;
829#define oFragColorgl_FragColor gl_FragColor
830// vec4 oFragColor;
831// sampler2D sColor0;
832// sampler2D sColor1;
833// sampler2D sColor2;
834struct RectWithSize_scalar {
835vec2_scalar p0;
836vec2_scalar size;
837RectWithSize_scalar() = default;
838RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
839};
840struct RectWithSize {
841vec2 p0;
842vec2 size;
843RectWithSize() = default;
844RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
845RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
846}
847IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
848}
849friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
850if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
851}};
852struct RectWithEndpoint_scalar {
853vec2_scalar p0;
854vec2_scalar p1;
855RectWithEndpoint_scalar() = default;
856RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
857};
858struct RectWithEndpoint {
859vec2 p0;
860vec2 p1;
861RectWithEndpoint() = default;
862RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
863RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
864}
865IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
866}
867friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
868if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
869}};
870// sampler2D sGpuCache;
871// vec4_scalar vTransformBounds;
872// sampler2D sClipMask;
873struct Fragment_scalar {
874vec4_scalar color;
875Fragment_scalar() = default;
876explicit Fragment_scalar(vec4_scalar color) : color(color){}
877};
878struct Fragment {
879vec4 color;
880Fragment() = default;
881explicit Fragment(vec4 color) : color(color){}
882explicit Fragment(vec4_scalar color):color(color){
883}
884IMPLICIT Fragment(Fragment_scalar s):color(s.color){
885}
886friend Fragment if_then_else(I32 c, Fragment t, Fragment e) { return Fragment(
887if_then_else(c, t.color, e.color));
888}};
889vec2 vUv_Y;
890// vec4_scalar vUvBounds_Y;
891vec2 vUv_U;
892// vec4_scalar vUvBounds_U;
893vec2 vUv_V;
894// vec4_scalar vUvBounds_V;
895// vec3_scalar vYcbcrBias;
896// mat3_scalar vRgbFromDebiasedYcbcr;
897// ivec2_scalar vFormat;
898// int32_t vRescaleFactor;
899vec4 sample_yuv(int32_t format, vec3_scalar ycbcr_bias, mat3_scalar rgb_from_debiased_ycbrc, vec2 in_uv_y, vec2 in_uv_u, vec2 in_uv_v, vec4_scalar uv_bounds_y, vec4_scalar uv_bounds_u, vec4_scalar uv_bounds_v) {
900 vec3 ycbcr_sample;
901 switch (format) {
902 case 3:
903 {
904 vec2 uv_y = clamp(in_uv_y, (uv_bounds_y).sel(X,Y), (uv_bounds_y).sel(Z,W));
905 vec2 uv_u = clamp(in_uv_u, (uv_bounds_u).sel(X,Y), (uv_bounds_u).sel(Z,W));
906 vec2 uv_v = clamp(in_uv_v, (uv_bounds_v).sel(X,Y), (uv_bounds_v).sel(Z,W));
907 (ycbcr_sample).x = (texture(sColor0, (uv_y).sel(X,Y))).x;
908 (ycbcr_sample).y = (texture(sColor1, (uv_u).sel(X,Y))).x;
909 (ycbcr_sample).z = (texture(sColor2, (uv_v).sel(X,Y))).x;
910 }
911 break;
912 case 0:
913 case 1:
914 case 2:
915 {
916 vec2 uv_y = clamp(in_uv_y, (uv_bounds_y).sel(X,Y), (uv_bounds_y).sel(Z,W));
917 vec2 uv_uv = clamp(in_uv_u, (uv_bounds_u).sel(X,Y), (uv_bounds_u).sel(Z,W));
918 (ycbcr_sample).x = (texture(sColor0, (uv_y).sel(X,Y))).x;
919 (ycbcr_sample).lsel(Y,Z) = (texture(sColor1, (uv_uv).sel(X,Y))).sel(R,G);
920 }
921 break;
922 case 4:
923 {
924 vec2 uv_y = clamp(in_uv_y, (uv_bounds_y).sel(X,Y), (uv_bounds_y).sel(Z,W));
925 ycbcr_sample = (texture(sColor0, (uv_y).sel(X,Y))).sel(G,B,R);
926 }
927 break;
928 default:
929 ycbcr_sample = make_vec3(0.f);
930 break;
931 }
932 vec3 rgb = (rgb_from_debiased_ycbrc)*((ycbcr_sample)-(ycbcr_bias));
933 return make_vec4(rgb, 1.f);
934}
935Fragment brush_fs() {
936 vec4 color = sample_yuv((vFormat).x, vYcbcrBias, vRgbFromDebiasedYcbcr, vUv_Y, vUv_U, vUv_V, vUvBounds_Y, vUvBounds_U, vUvBounds_V);
937 return Fragment(color);
938}
939void write_output(vec4 color) {
940 oFragColorgl_FragColor = color;
941}
942ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
943 Fragment frag = brush_fs();
944 write_output((frag).color);
945}
946void swgl_drawSpanRGBA8() {
947 if (((vFormat).x)==(3)) {
948 {
949 swgl_commitTextureLinearYUV(sColor0, vUv_Y, vUvBounds_Y, sColor1, vUv_U, vUvBounds_U, sColor2, vUv_V, vUvBounds_V, vYcbcrBias, vRgbFromDebiasedYcbcr, vRescaleFactor)do { int drawn = 0; if (blend_key) { drawn = blendYUV<true
>(swgl_OutRGBA8, swgl_SpanLength, sColor0, vUv_Y, vUvBounds_Y
, sColor1, vUv_U, vUvBounds_U, sColor2, vUv_V, vUvBounds_V, vYcbcrBias
, vRgbFromDebiasedYcbcr, vRescaleFactor); } else { drawn = blendYUV
<false>(swgl_OutRGBA8, swgl_SpanLength, sColor0, vUv_Y,
vUvBounds_Y, sColor1, vUv_U, vUvBounds_U, sColor2, vUv_V, vUvBounds_V
, vYcbcrBias, vRgbFromDebiasedYcbcr, vRescaleFactor); } swgl_OutRGBA8
+= drawn; swgl_SpanLength -= drawn; } while (0)
;
950 }
951 } else if ((((vFormat).x)==(0))||(((vFormat).x)==(1))) {
952 {
953 swgl_commitTextureLinearYUV(sColor0, vUv_Y, vUvBounds_Y, sColor1, vUv_U, vUvBounds_U, vYcbcrBias, vRgbFromDebiasedYcbcr, vRescaleFactor)do { int drawn = 0; if (blend_key) { drawn = blendYUV<true
>(swgl_OutRGBA8, swgl_SpanLength, sColor0, vUv_Y, vUvBounds_Y
, sColor1, vUv_U, vUvBounds_U, vYcbcrBias, vRgbFromDebiasedYcbcr
, vRescaleFactor); } else { drawn = blendYUV<false>(swgl_OutRGBA8
, swgl_SpanLength, sColor0, vUv_Y, vUvBounds_Y, sColor1, vUv_U
, vUvBounds_U, vYcbcrBias, vRgbFromDebiasedYcbcr, vRescaleFactor
); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while
(0)
;
954 }
955 } else if (((vFormat).x)==(4)) {
956 {
957 swgl_commitTextureLinearYUV(sColor0, vUv_Y, vUvBounds_Y, vYcbcrBias, vRgbFromDebiasedYcbcr, vRescaleFactor)do { int drawn = 0; if (blend_key) { drawn = blendYUV<true
>(swgl_OutRGBA8, swgl_SpanLength, sColor0, vUv_Y, vUvBounds_Y
, vYcbcrBias, vRgbFromDebiasedYcbcr, vRescaleFactor); } else {
drawn = blendYUV<false>(swgl_OutRGBA8, swgl_SpanLength
, sColor0, vUv_Y, vUvBounds_Y, vYcbcrBias, vRgbFromDebiasedYcbcr
, vRescaleFactor); } swgl_OutRGBA8 += drawn; swgl_SpanLength -=
drawn; } while (0)
;
958 }
959 }
960}
961typedef brush_yuv_image_TEXTURE_2D_YUV_vert::InterpOutputs InterpInputs;
962InterpInputs interp_step;
963struct InterpPerspective {
964vec2 vUv_Y;
965vec2 vUv_U;
966vec2 vUv_V;
967};
968InterpPerspective interp_perspective;
969static 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_;
970 self->vUv_Y = init_interp(init->vUv_Y, step->vUv_Y);
971 self->interp_step.vUv_Y = step->vUv_Y * 4.0f;
972 self->vUv_U = init_interp(init->vUv_U, step->vUv_U);
973 self->interp_step.vUv_U = step->vUv_U * 4.0f;
974 self->vUv_V = init_interp(init->vUv_V, step->vUv_V);
975 self->interp_step.vUv_V = step->vUv_V * 4.0f;
976}
977static 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_;
978 Float w = 1.0f / self->gl_FragCoord.w;
979 self->interp_perspective.vUv_Y = init_interp(init->vUv_Y, step->vUv_Y);
980 self->vUv_Y = self->interp_perspective.vUv_Y * w;
981 self->interp_step.vUv_Y = step->vUv_Y * 4.0f;
982 self->interp_perspective.vUv_U = init_interp(init->vUv_U, step->vUv_U);
983 self->vUv_U = self->interp_perspective.vUv_U * w;
984 self->interp_step.vUv_U = step->vUv_U * 4.0f;
985 self->interp_perspective.vUv_V = init_interp(init->vUv_V, step->vUv_V);
986 self->vUv_V = self->interp_perspective.vUv_V * w;
987 self->interp_step.vUv_V = step->vUv_V * 4.0f;
988}
989ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
990 float chunks = steps * 0.25f;
991 vUv_Y += interp_step.vUv_Y * chunks;
992 vUv_U += interp_step.vUv_U * chunks;
993 vUv_V += interp_step.vUv_V * chunks;
994}
995ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
996 step_perspective(steps);
997 float chunks = steps * 0.25f;
998 Float w = 1.0f / gl_FragCoord.w;
999 interp_perspective.vUv_Y += interp_step.vUv_Y * chunks;
1000 vUv_Y = w * interp_perspective.vUv_Y;
1001 interp_perspective.vUv_U += interp_step.vUv_U * chunks;
1002 vUv_U = w * interp_perspective.vUv_U;
1003 interp_perspective.vUv_V += interp_step.vUv_V * chunks;
1004 vUv_V = w * interp_perspective.vUv_V;
1005}
1006static void run(FragmentShaderImpl* impl) {
1007 Self* self = (Self*)impl;
1008 self->main();
1009 self->step_interp_inputs();
1010}
1011static void skip(FragmentShaderImpl* impl, int steps) {
1012 Self* self = (Self*)impl;
1013 self->step_interp_inputs(steps);
1014}
1015static void run_perspective(FragmentShaderImpl* impl) {
1016 Self* self = (Self*)impl;
1017 self->main();
1018 self->step_perspective_inputs();
1019}
1020static void skip_perspective(FragmentShaderImpl* impl, int steps) {
1021 Self* self = (Self*)impl;
1022 self->step_perspective_inputs(steps);
1023}
1024static int draw_span_RGBA8(FragmentShaderImpl* impl) {
1025 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)
; }
1026public:
1027brush_yuv_image_TEXTURE_2D_YUV_frag() {
1028 init_span_func = &read_interp_inputs;
1029 run_func = &run;
1030 skip_func = &skip;
1031 draw_span_RGBA8_func = &draw_span_RGBA8;
1032 enable_perspective();
1033 init_span_w_func = &read_perspective_inputs;
1034 run_w_func = &run_perspective;
1035 skip_w_func = &skip_perspective;
1036}
1037};
1038
1039struct brush_yuv_image_TEXTURE_2D_YUV_program : ProgramImpl, brush_yuv_image_TEXTURE_2D_YUV_frag {
1040int get_uniform(const char *name) const override {
1041 if (strcmp("sClipMask", name) == 0) { return 7; }
1042 if (strcmp("sColor0", name) == 0) { return 8; }
1043 if (strcmp("sColor1", name) == 0) { return 9; }
1044 if (strcmp("sColor2", name) == 0) { return 10; }
1045 if (strcmp("sGpuCache", name) == 0) { return 2; }
1046 if (strcmp("sPrimitiveHeadersF", name) == 0) { return 4; }
1047 if (strcmp("sPrimitiveHeadersI", name) == 0) { return 5; }
1048 if (strcmp("sRenderTasks", name) == 0) { return 1; }
1049 if (strcmp("sTransformPalette", name) == 0) { return 3; }
1050 if (strcmp("uTransform", name) == 0) { return 6; }
1051 return -1;
1052}
1053void bind_attrib(const char* name, int index) override {
1054 attrib_locations.bind_loc(name, index);
1055}
1056int get_attrib(const char* name) const override {
1057 return attrib_locations.get_loc(name);
1058}
1059size_t interpolants_size() const override { return sizeof(InterpOutputs); }
1060VertexShaderImpl* get_vertex_shader() override {
1061 return this;
1062}
1063FragmentShaderImpl* get_fragment_shader() override {
1064 return this;
1065}
1066const char* get_name() const override { return "brush_yuv_image_TEXTURE_2D_YUV"; }
1067static ProgramImpl* loader() { return new brush_yuv_image_TEXTURE_2D_YUV_program; }
1068};
1069