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/cs_svg_filter_node.h
Warning:line 949, column 3
Value stored to 'ret_mask' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -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 cs_svg_filter_node_common {
2struct Samplers {
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 sGpuCache_impl;
10 int sGpuCache_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 7:
22 sClipMask_slot = value;
23 return true;
24 case 8:
25 sColor0_slot = value;
26 return true;
27 case 9:
28 sColor1_slot = value;
29 return true;
30 case 2:
31 sGpuCache_slot = value;
32 return true;
33 case 4:
34 sPrimitiveHeadersF_slot = value;
35 return true;
36 case 5:
37 sPrimitiveHeadersI_slot = value;
38 return true;
39 case 1:
40 sRenderTasks_slot = value;
41 return true;
42 case 3:
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 int aFilterTargetRect = NULL_ATTRIB16;
53 int aFilterInput1ContentScaleAndOffset = NULL_ATTRIB16;
54 int aFilterInput2ContentScaleAndOffset = NULL_ATTRIB16;
55 int aFilterInput1TaskAddress = NULL_ATTRIB16;
56 int aFilterInput2TaskAddress = NULL_ATTRIB16;
57 int aFilterKind = NULL_ATTRIB16;
58 int aFilterInputCount = NULL_ATTRIB16;
59 int aFilterExtraDataAddress = NULL_ATTRIB16;
60 void bind_loc(const char* name, int index) {
61 if (strcmp("aPosition", name) == 0) { aPosition = index; return; }
62 if (strcmp("aData", name) == 0) { aData = index; return; }
63 if (strcmp("aFilterTargetRect", name) == 0) { aFilterTargetRect = index; return; }
64 if (strcmp("aFilterInput1ContentScaleAndOffset", name) == 0) { aFilterInput1ContentScaleAndOffset = index; return; }
65 if (strcmp("aFilterInput2ContentScaleAndOffset", name) == 0) { aFilterInput2ContentScaleAndOffset = index; return; }
66 if (strcmp("aFilterInput1TaskAddress", name) == 0) { aFilterInput1TaskAddress = index; return; }
67 if (strcmp("aFilterInput2TaskAddress", name) == 0) { aFilterInput2TaskAddress = index; return; }
68 if (strcmp("aFilterKind", name) == 0) { aFilterKind = index; return; }
69 if (strcmp("aFilterInputCount", name) == 0) { aFilterInputCount = index; return; }
70 if (strcmp("aFilterExtraDataAddress", name) == 0) { aFilterExtraDataAddress = index; return; }
71 }
72 int get_loc(const char* name) const {
73 if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; }
74 if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; }
75 if (strcmp("aFilterTargetRect", name) == 0) { return aFilterTargetRect != NULL_ATTRIB16 ? aFilterTargetRect : -1; }
76 if (strcmp("aFilterInput1ContentScaleAndOffset", name) == 0) { return aFilterInput1ContentScaleAndOffset != NULL_ATTRIB16 ? aFilterInput1ContentScaleAndOffset : -1; }
77 if (strcmp("aFilterInput2ContentScaleAndOffset", name) == 0) { return aFilterInput2ContentScaleAndOffset != NULL_ATTRIB16 ? aFilterInput2ContentScaleAndOffset : -1; }
78 if (strcmp("aFilterInput1TaskAddress", name) == 0) { return aFilterInput1TaskAddress != NULL_ATTRIB16 ? aFilterInput1TaskAddress : -1; }
79 if (strcmp("aFilterInput2TaskAddress", name) == 0) { return aFilterInput2TaskAddress != NULL_ATTRIB16 ? aFilterInput2TaskAddress : -1; }
80 if (strcmp("aFilterKind", name) == 0) { return aFilterKind != NULL_ATTRIB16 ? aFilterKind : -1; }
81 if (strcmp("aFilterInputCount", name) == 0) { return aFilterInputCount != NULL_ATTRIB16 ? aFilterInputCount : -1; }
82 if (strcmp("aFilterExtraDataAddress", name) == 0) { return aFilterExtraDataAddress != NULL_ATTRIB16 ? aFilterExtraDataAddress : -1; }
83 return -1;
84 }
85} attrib_locations;
86vec4_scalar vTransformBounds;
87vec4_scalar vInput1UvRect;
88vec4_scalar vInput2UvRect;
89ivec4_scalar vData;
90vec4_scalar vFilterData0;
91ivec2_scalar vFilterInputCountFilterKindVec;
92vec2_scalar vFloat0;
93mat4_scalar vColorMat;
94sampler2D sClipMask;
95sampler2D sColor0;
96sampler2D sColor1;
97sampler2D sGpuCache;
98sampler2D sPrimitiveHeadersF;
99isampler2D sPrimitiveHeadersI;
100sampler2D sRenderTasks;
101sampler2D sTransformPalette;
102mat4_scalar uTransform;
103void bind_textures() {
104 sClipMask = lookup_sampler(&samplers.sClipMask_impl, samplers.sClipMask_slot);
105 sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot);
106 sColor1 = lookup_sampler(&samplers.sColor1_impl, samplers.sColor1_slot);
107 sGpuCache = lookup_sampler(&samplers.sGpuCache_impl, samplers.sGpuCache_slot);
108 sPrimitiveHeadersF = lookup_sampler(&samplers.sPrimitiveHeadersF_impl, samplers.sPrimitiveHeadersF_slot);
109 sPrimitiveHeadersI = lookup_isampler(&samplers.sPrimitiveHeadersI_impl, samplers.sPrimitiveHeadersI_slot);
110 sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot);
111 sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot);
112}
113};
114struct cs_svg_filter_node_vert : VertexShaderImpl, cs_svg_filter_node_common {
115private:
116typedef cs_svg_filter_node_vert Self;
117// mat4_scalar uTransform;
118vec2 aPosition;
119// sampler2D sColor0;
120// sampler2D sColor1;
121// sampler2D sColor2;
122struct RectWithSize_scalar {
123vec2_scalar p0;
124vec2_scalar size;
125RectWithSize_scalar() = default;
126RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
127};
128struct RectWithSize {
129vec2 p0;
130vec2 size;
131RectWithSize() = default;
132RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
133RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
134}
135IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
136}
137friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
138if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
139}};
140struct RectWithEndpoint_scalar {
141vec2_scalar p0;
142vec2_scalar p1;
143RectWithEndpoint_scalar() = default;
144RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
145};
146struct RectWithEndpoint {
147vec2 p0;
148vec2 p1;
149RectWithEndpoint() = default;
150RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
151RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
152}
153IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
154}
155friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
156if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
157}};
158// sampler2D sRenderTasks;
159struct RenderTaskData_scalar {
160RectWithEndpoint_scalar task_rect;
161vec4_scalar user_data;
162RenderTaskData_scalar() = default;
163RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){}
164};
165struct RenderTaskData {
166RectWithEndpoint task_rect;
167vec4 user_data;
168RenderTaskData() = default;
169RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){}
170RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){
171}
172IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){
173}
174friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData(
175if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data));
176}};
177struct PictureTask_scalar {
178RectWithEndpoint_scalar task_rect;
179float device_pixel_scale;
180vec2_scalar content_origin;
181PictureTask_scalar() = default;
182PictureTask_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){}
183};
184struct PictureTask {
185RectWithEndpoint task_rect;
186Float device_pixel_scale;
187vec2 content_origin;
188PictureTask() = default;
189PictureTask(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 content_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), content_origin(content_origin){}
190PictureTask(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){
191}
192IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){
193}
194friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask(
195if_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));
196}};
197struct ClipArea_scalar {
198RectWithEndpoint_scalar task_rect;
199float device_pixel_scale;
200vec2_scalar screen_origin;
201ClipArea_scalar() = default;
202ClipArea_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){}
203};
204struct ClipArea {
205RectWithEndpoint task_rect;
206Float device_pixel_scale;
207vec2 screen_origin;
208ClipArea() = default;
209ClipArea(RectWithEndpoint task_rect, Float device_pixel_scale, vec2 screen_origin) : task_rect(task_rect), device_pixel_scale(device_pixel_scale), screen_origin(screen_origin){}
210ClipArea(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){
211}
212IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){
213}
214friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea(
215if_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));
216}};
217// sampler2D sGpuCache;
218struct ImageSource_scalar {
219RectWithEndpoint_scalar uv_rect;
220vec4_scalar user_data;
221ImageSource_scalar() = default;
222ImageSource_scalar(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data) : uv_rect(uv_rect), user_data(user_data){}
223};
224struct ImageSource {
225RectWithEndpoint uv_rect;
226vec4 user_data;
227ImageSource() = default;
228ImageSource(RectWithEndpoint uv_rect, vec4 user_data) : uv_rect(uv_rect), user_data(user_data){}
229ImageSource(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data):uv_rect(uv_rect),user_data(user_data){
230}
231IMPLICIT ImageSource(ImageSource_scalar s):uv_rect(s.uv_rect),user_data(s.user_data){
232}
233friend ImageSource if_then_else(I32 c, ImageSource t, ImageSource e) { return ImageSource(
234if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.user_data, e.user_data));
235}};
236struct ImageSourceExtra_scalar {
237vec4_scalar st_tl;
238vec4_scalar st_tr;
239vec4_scalar st_bl;
240vec4_scalar st_br;
241ImageSourceExtra_scalar() = default;
242ImageSourceExtra_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){}
243};
244struct ImageSourceExtra {
245vec4 st_tl;
246vec4 st_tr;
247vec4 st_bl;
248vec4 st_br;
249ImageSourceExtra() = default;
250ImageSourceExtra(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){}
251ImageSourceExtra(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){
252}
253IMPLICIT ImageSourceExtra(ImageSourceExtra_scalar s):st_tl(s.st_tl),st_tr(s.st_tr),st_bl(s.st_bl),st_br(s.st_br){
254}
255friend ImageSourceExtra if_then_else(I32 c, ImageSourceExtra t, ImageSourceExtra e) { return ImageSourceExtra(
256if_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));
257}};
258// vec4_scalar vTransformBounds;
259// sampler2D sTransformPalette;
260struct Transform_scalar {
261mat4_scalar m;
262mat4_scalar inv_m;
263bool is_axis_aligned;
264Transform_scalar() = default;
265Transform_scalar(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
266};
267struct Transform {
268mat4 m;
269mat4 inv_m;
270Bool is_axis_aligned;
271Transform() = default;
272Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){}
273Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){
274}
275IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){
276}
277friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform(
278if_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));
279}};
280// sampler2D sClipMask;
281// sampler2D sPrimitiveHeadersF;
282// isampler2D sPrimitiveHeadersI;
283ivec4_scalar aData;
284struct Instance_scalar {
285int32_t prim_header_address;
286int32_t clip_address;
287int32_t segment_index;
288int32_t flags;
289int32_t resource_address;
290int32_t brush_kind;
291Instance_scalar() = default;
292Instance_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){}
293};
294struct Instance {
295I32 prim_header_address;
296I32 clip_address;
297I32 segment_index;
298I32 flags;
299I32 resource_address;
300I32 brush_kind;
301Instance() = default;
302Instance(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){}
303Instance(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){
304}
305IMPLICIT 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){
306}
307friend Instance if_then_else(I32 c, Instance t, Instance e) { return Instance(
308if_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));
309}};
310struct PrimitiveHeader_scalar {
311RectWithEndpoint_scalar local_rect;
312RectWithEndpoint_scalar local_clip_rect;
313float z;
314int32_t specific_prim_address;
315int32_t transform_id;
316int32_t picture_task_address;
317ivec4_scalar user_data;
318PrimitiveHeader_scalar() = default;
319PrimitiveHeader_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){}
320};
321struct PrimitiveHeader {
322RectWithEndpoint local_rect;
323RectWithEndpoint local_clip_rect;
324Float z;
325I32 specific_prim_address;
326I32 transform_id;
327I32 picture_task_address;
328ivec4 user_data;
329PrimitiveHeader() = default;
330PrimitiveHeader(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){}
331PrimitiveHeader(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){
332}
333IMPLICIT 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){
334}
335friend PrimitiveHeader if_then_else(I32 c, PrimitiveHeader t, PrimitiveHeader e) { return PrimitiveHeader(
336if_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));
337}};
338struct VertexInfo_scalar {
339vec2_scalar local_pos;
340vec4_scalar world_pos;
341VertexInfo_scalar() = default;
342VertexInfo_scalar(vec2_scalar local_pos, vec4_scalar world_pos) : local_pos(local_pos), world_pos(world_pos){}
343};
344struct VertexInfo {
345vec2 local_pos;
346vec4 world_pos;
347VertexInfo() = default;
348VertexInfo(vec2 local_pos, vec4 world_pos) : local_pos(local_pos), world_pos(world_pos){}
349VertexInfo(vec2_scalar local_pos, vec4_scalar world_pos):local_pos(local_pos),world_pos(world_pos){
350}
351IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos),world_pos(s.world_pos){
352}
353friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo(
354if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.world_pos, e.world_pos));
355}};
356vec2 vInput1Uv;
357vec2 vInput2Uv;
358// vec4_scalar vInput1UvRect;
359// vec4_scalar vInput2UvRect;
360// ivec4_scalar vData;
361// vec4_scalar vFilterData0;
362// vec4_scalar vFilterData1;
363// ivec2_scalar vFilterInputCountFilterKindVec;
364// vec2_scalar vFloat0;
365// mat4_scalar vColorMat;
366// ivec4_scalar vFuncs;
367vec4_scalar aFilterTargetRect;
368vec4_scalar aFilterInput1ContentScaleAndOffset;
369vec4_scalar aFilterInput2ContentScaleAndOffset;
370int32_t aFilterInput1TaskAddress;
371int32_t aFilterInput2TaskAddress;
372int32_t aFilterKind;
373int32_t aFilterInputCount;
374ivec2_scalar aFilterExtraDataAddress;
375RectWithEndpoint_scalar fetch_render_task_rect(int32_t index) {
376 ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u))));
377 auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0);
378 vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0);
379 vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0);
380 RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W));
381 return task_rect;
382}
383vec4_scalar compute_uv_rect(RectWithEndpoint_scalar task_rect, vec2_scalar texture_size) {
384 vec4_scalar uvRect = make_vec4(((task_rect).p0)+(make_vec2(0.5f)), ((task_rect).p1)-(make_vec2(0.5f)));
385 uvRect /= (texture_size).sel(X,Y,X,Y);
386 return uvRect;
387}
388vec2 compute_uv(RectWithEndpoint_scalar task_rect, vec4_scalar scale_and_offset, vec2_scalar target_size, vec2_scalar texture_size) {
389 return ((((task_rect).p0)+((scale_and_offset).sel(Z,W)))+(((scale_and_offset).sel(X,Y))*((aPosition).sel(X,Y))))/((texture_size).sel(X,Y));
390}
391Array<vec4_scalar,4> fetch_from_gpu_cache_4_direct(ivec2_scalar address) {
392 auto sGpuCache_address_fetch = texelFetchPtr(sGpuCache, address, 0, 3, 0, 0);
393 return Array<vec4_scalar,4>{{texelFetchUnchecked(sGpuCache, sGpuCache_address_fetch, 0, 0), texelFetchUnchecked(sGpuCache, sGpuCache_address_fetch, 1, 0), texelFetchUnchecked(sGpuCache, sGpuCache_address_fetch, 2, 0), texelFetchUnchecked(sGpuCache, sGpuCache_address_fetch, 3, 0)}};
394}
395vec4_scalar fetch_from_gpu_cache_1_direct(ivec2_scalar address) {
396 return texelFetch(sGpuCache, address, 0);
397}
398vec3_scalar vertexSrgbToLinear(vec3_scalar color) {
399 vec3_scalar c1 = (color)*(make_vec3((1.f)/(12.92f)));
400 vec3_scalar c2;
401 (c2).x = pow__glsl_pow((((color).x)*((1.f)/(1.055f)))+((0.055f)/(1.055f)), 2.4f);
402 (c2).y = pow__glsl_pow((((color).y)*((1.f)/(1.055f)))+((0.055f)/(1.055f)), 2.4f);
403 (c2).z = pow__glsl_pow((((color).z)*((1.f)/(1.055f)))+((0.055f)/(1.055f)), 2.4f);
404 return mix(c1, c2, step(make_vec3(0.04045f), color));
405}
406ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
407 vec2 pos = mix((aFilterTargetRect).sel(X,Y), (aFilterTargetRect).sel(Z,W), (aPosition).sel(X,Y));
408 RectWithEndpoint_scalar input_1_task;
409 if ((aFilterInputCount)>(0)) {
410 {
411 vec2_scalar texture_size = make_vec2((textureSize(sColor0, 0)).sel(X,Y));
412 input_1_task = fetch_render_task_rect(aFilterInput1TaskAddress);
413 vInput1UvRect = compute_uv_rect(input_1_task, texture_size);
414 vInput1Uv = compute_uv(input_1_task, aFilterInput1ContentScaleAndOffset, ((aFilterTargetRect).sel(Z,W))-((aFilterTargetRect).sel(X,Y)), texture_size);
415 }
416 }
417 RectWithEndpoint_scalar input_2_task;
418 if ((aFilterInputCount)>(1)) {
419 {
420 vec2_scalar texture_size = make_vec2((textureSize(sColor1, 0)).sel(X,Y));
421 input_2_task = fetch_render_task_rect(aFilterInput2TaskAddress);
422 vInput2UvRect = compute_uv_rect(input_2_task, texture_size);
423 vInput2Uv = compute_uv(input_2_task, aFilterInput2ContentScaleAndOffset, ((aFilterTargetRect).sel(Z,W))-((aFilterTargetRect).sel(X,Y)), texture_size);
424 }
425 }
426 (vFilterInputCountFilterKindVec).x = aFilterInputCount;
427 (vFilterInputCountFilterKindVec).y = aFilterKind;
428 switch (aFilterKind) {
429 case 0:
430 case 1:
431 break;
432 case 2:
433 case 3:
434 (vFloat0).x = (aFilterInput2ContentScaleAndOffset).x;
435 break;
436 case 4:
437 case 5:
438 break;
439 case 6:
440 case 7:
441 case 8:
442 case 9:
443 case 10:
444 case 11:
445 case 12:
446 case 13:
447 case 14:
448 case 15:
449 case 16:
450 case 17:
451 case 18:
452 case 19:
453 case 20:
454 case 21:
455 case 22:
456 case 23:
457 case 24:
458 case 25:
459 case 26:
460 case 27:
461 case 28:
462 case 29:
463 case 30:
464 case 31:
465 case 32:
466 case 33:
467 case 34:
468 case 35:
469 case 36:
470 case 37:
471 break;
472 case 38:
473 case 39:
474 {
475 Array<vec4_scalar,4> mat_data = fetch_from_gpu_cache_4_direct(aFilterExtraDataAddress);
476 vColorMat = make_mat4(mat_data[0], mat_data[1], mat_data[2], mat_data[3]);
477 vFilterData0 = fetch_from_gpu_cache_1_direct((aFilterExtraDataAddress)+(make_ivec2(4, 0)));
478 break;
479 }
480 case 40:
481 case 41:
482 vData = make_ivec4(aFilterExtraDataAddress, 0, 0);
483 break;
484 case 42:
485 case 43:
486 vFilterData0 = fetch_from_gpu_cache_1_direct(aFilterExtraDataAddress);
487 break;
488 case 44:
489 case 45:
490 case 46:
491 case 47:
492 case 48:
493 case 49:
494 case 50:
495 case 51:
496 case 52:
497 case 53:
498 case 54:
499 case 55:
500 break;
501 case 56:
502 case 57:
503 break;
504 case 58:
505 case 59:
506 break;
507 case 60:
508 case 61:
509 break;
510 case 62:
511 case 63:
512 break;
513 case 64:
514 case 65:
515 break;
516 case 66:
517 case 67:
518 break;
519 case 68:
520 case 69:
521 break;
522 case 70:
523 vFilterData0 = fetch_from_gpu_cache_1_direct(aFilterExtraDataAddress);
524 (vFilterData0).lsel(R,G,B) = ((vFilterData0).sel(R,G,B))*((vFilterData0).w);
525 break;
526 case 71:
527 vFilterData0 = fetch_from_gpu_cache_1_direct(aFilterExtraDataAddress);
528 (vFilterData0).lsel(R,G,B) = vertexSrgbToLinear((vFilterData0).sel(R,G,B));
529 (vFilterData0).lsel(R,G,B) = ((vFilterData0).sel(R,G,B))*((vFilterData0).w);
530 break;
531 case 72:
532 vFilterData0 = aFilterInput2ContentScaleAndOffset;
533 (vFilterData0).lsel(R,G,B) = ((vFilterData0).sel(R,G,B))*((vFilterData0).w);
534 break;
535 case 73:
536 vFilterData0 = aFilterInput2ContentScaleAndOffset;
537 (vFilterData0).lsel(R,G,B) = vertexSrgbToLinear((vFilterData0).sel(R,G,B));
538 (vFilterData0).lsel(R,G,B) = ((vFilterData0).sel(R,G,B))*((vFilterData0).w);
539 break;
540 case 74:
541 case 75:
542 break;
543 case 76:
544 case 77:
545 break;
546 case 80:
547 case 81:
548 case 82:
549 case 83:
550 vFilterData0 = aFilterInput2ContentScaleAndOffset;
551 break;
552 case 86:
553 case 87:
554 break;
555 case 88:
556 case 89:
557 break;
558 case 90:
559 case 91:
560 break;
561 case 92:
562 case 93:
563 break;
564 case 94:
565 case 95:
566 case 96:
567 case 97:
568 case 98:
569 case 99:
570 case 100:
571 case 101:
572 break;
573 default:
574 break;
575 }
576 gl_Position = (uTransform)*(make_vec4(pos, 0.f, 1.f));
577}
578static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) {
579 Self* self = (Self*)impl;
580 if (self->samplers.set_slot(index, value)) return;
581 switch (index) {
582 case 7:
583 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
584 break;
585 case 8:
586 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
587 break;
588 case 9:
589 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
590 break;
591 case 2:
592 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuCache
593 break;
594 case 4:
595 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
596 break;
597 case 5:
598 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
599 break;
600 case 1:
601 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
602 break;
603 case 3:
604 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
605 break;
606 case 6:
607 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
608 break;
609 }
610}
611static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) {
612 Self* self = (Self*)impl;
613 switch (index) {
614 case 7:
615 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
616 break;
617 case 8:
618 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
619 break;
620 case 9:
621 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
622 break;
623 case 2:
624 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuCache
625 break;
626 case 4:
627 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
628 break;
629 case 5:
630 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
631 break;
632 case 1:
633 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
634 break;
635 case 3:
636 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
637 break;
638 case 6:
639 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // uTransform
640 break;
641 }
642}
643static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) {
644 Self* self = (Self*)impl;
645 switch (index) {
646 case 7:
647 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sClipMask
648 break;
649 case 8:
650 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor0
651 break;
652 case 9:
653 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sColor1
654 break;
655 case 2:
656 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sGpuCache
657 break;
658 case 4:
659 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersF
660 break;
661 case 5:
662 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sPrimitiveHeadersI
663 break;
664 case 1:
665 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sRenderTasks
666 break;
667 case 3:
668 assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0"
, __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__
))
; // sTransformPalette
669 break;
670 case 6:
671 self->uTransform = mat4_scalar::load_from_ptr(value);
672 break;
673 }
674}
675static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl;
676 load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count);
677 load_flat_attrib(self->aFilterTargetRect, attribs[self->attrib_locations.aFilterTargetRect], start, instance, count);
678 load_flat_attrib(self->aFilterInput1ContentScaleAndOffset, attribs[self->attrib_locations.aFilterInput1ContentScaleAndOffset], start, instance, count);
679 load_flat_attrib(self->aFilterInput2ContentScaleAndOffset, attribs[self->attrib_locations.aFilterInput2ContentScaleAndOffset], start, instance, count);
680 load_flat_attrib(self->aFilterInput1TaskAddress, attribs[self->attrib_locations.aFilterInput1TaskAddress], start, instance, count);
681 load_flat_attrib(self->aFilterInput2TaskAddress, attribs[self->attrib_locations.aFilterInput2TaskAddress], start, instance, count);
682 load_flat_attrib(self->aFilterKind, attribs[self->attrib_locations.aFilterKind], start, instance, count);
683 load_flat_attrib(self->aFilterInputCount, attribs[self->attrib_locations.aFilterInputCount], start, instance, count);
684 load_flat_attrib(self->aFilterExtraDataAddress, attribs[self->attrib_locations.aFilterExtraDataAddress], start, instance, count);
685}
686public:
687struct InterpOutputs {
688vec2_scalar vInput1Uv;
689vec2_scalar vInput2Uv;
690};
691private:
692ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) {
693 for(int n = 0; n < 4; n++) {
694 auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr);
695 dest->vInput1Uv = get_nth(vInput1Uv, n);
696 dest->vInput2Uv = get_nth(vInput2Uv, n);
697 dest_ptr += stride;
698 }
699}
700static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) {
701 Self* self = (Self*)impl;
702 self->main();
703 self->store_interp_outputs(interps, interp_stride);
704}
705static void init_batch(VertexShaderImpl* impl) {
706 Self* self = (Self*)impl; self->bind_textures(); }
707public:
708cs_svg_filter_node_vert() {
709 set_uniform_1i_func = &set_uniform_1i;
710 set_uniform_4fv_func = &set_uniform_4fv;
711 set_uniform_matrix4fv_func = &set_uniform_matrix4fv;
712 init_batch_func = &init_batch;
713 load_attribs_func = &load_attribs;
714 run_primitive_func = &run;
715}
716};
717
718
719struct cs_svg_filter_node_frag : FragmentShaderImpl, cs_svg_filter_node_vert {
720private:
721typedef cs_svg_filter_node_frag Self;
722#define oFragColorgl_FragColor gl_FragColor
723// vec4 oFragColor;
724// sampler2D sColor0;
725// sampler2D sColor1;
726// sampler2D sColor2;
727struct RectWithSize_scalar {
728vec2_scalar p0;
729vec2_scalar size;
730RectWithSize_scalar() = default;
731RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){}
732};
733struct RectWithSize {
734vec2 p0;
735vec2 size;
736RectWithSize() = default;
737RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){}
738RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){
739}
740IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){
741}
742friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize(
743if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size));
744}};
745struct RectWithEndpoint_scalar {
746vec2_scalar p0;
747vec2_scalar p1;
748RectWithEndpoint_scalar() = default;
749RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){}
750};
751struct RectWithEndpoint {
752vec2 p0;
753vec2 p1;
754RectWithEndpoint() = default;
755RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){}
756RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){
757}
758IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){
759}
760friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint(
761if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1));
762}};
763// sampler2D sGpuCache;
764// vec4_scalar vTransformBounds;
765// sampler2D sClipMask;
766struct Fragment_scalar {
767vec4_scalar color;
768Fragment_scalar() = default;
769explicit Fragment_scalar(vec4_scalar color) : color(color){}
770};
771struct Fragment {
772vec4 color;
773Fragment() = default;
774explicit Fragment(vec4 color) : color(color){}
775explicit Fragment(vec4_scalar color):color(color){
776}
777IMPLICIT Fragment(Fragment_scalar s):color(s.color){
778}
779friend Fragment if_then_else(I32 c, Fragment t, Fragment e) { return Fragment(
780if_then_else(c, t.color, e.color));
781}};
782vec2 vInput1Uv;
783vec2 vInput2Uv;
784// vec4_scalar vInput1UvRect;
785// vec4_scalar vInput2UvRect;
786// ivec4_scalar vData;
787// vec4_scalar vFilterData0;
788// vec4_scalar vFilterData1;
789// ivec2_scalar vFilterInputCountFilterKindVec;
790// vec2_scalar vFloat0;
791// mat4_scalar vColorMat;
792// ivec4_scalar vFuncs;
793vec4 sampleInUvRect(sampler2D sampler, vec2 uv, vec4_scalar uvRect) {
794 vec2 clamped = clamp((uv).sel(X,Y), (uvRect).sel(X,Y), (uvRect).sel(Z,W));
795 return texture(sampler, clamped);
796}
797vec3 SrgbToLinear(vec3 color) {
798 vec3 c1 = (color)/(12.92f);
799 vec3 c2 = pow__glsl_pow(((color)/(1.055f))+(make_vec3((0.055f)/(1.055f))), make_vec3(2.4f));
800 return mix(c2, c1, lessThanEqual(color, make_vec3(0.04045f)));
801}
802Float Lum(vec3 c) {
803 vec3_scalar f = make_vec3(0.3f, 0.59f, 0.11f);
804 return dot(c, f);
805}
806vec3 ClipColor(vec3 C) {
807 Float L = Lum(C);
808 Float n = min((C).x, min((C).y, (C).z));
809 Float x = max((C).x, max((C).y, (C).z));
810 auto _c3_ = (n)<(0.f);
811 C = if_then_else(_c3_,(L)+((((C)-(L))*(L))/((L)-(n))),C);
812 auto _c4_ = (x)>(1.f);
813 C = if_then_else(_c4_,(L)+((((C)-(L))*((1.f)-(L)))/((x)-(L))),C);
814 return C;
815}
816vec3 SetLum(vec3 C, Float l) {
817 Float d = (l)-(Lum(C));
818 return ClipColor((C)+(d));
819}
820vec3 Color(vec3 Cb, vec3 Cs) {
821 return SetLum(Cs, Lum(Cb));
822}
823Float ColorBurn(Float Cb, Float Cs) {
824 I32 ret_mask = ~0;
825 Float ret;
826 auto _c8_ = (Cb)==(1.f);
827 ret = 1.f;
828 ret_mask = ~I32(_c8_);
829 auto _c9_ = (Cs)==(0.f);
830 auto _c10_ = (~(_c8_))&(_c9_);
831 ret = if_then_else(ret_mask & I32(_c10_), 0.f, ret);
832 ret_mask &= ~I32(_c10_);
833 _c9_ = (~(_c8_))&(~(_c9_));
834 ret = if_then_else(ret_mask & I32(_c9_), (1.f)-(min(1.f, ((1.f)-(Cb))/(Cs))), ret);
835 ret_mask &= ~I32(_c9_);
836 return ret;
837}
838Float ColorDodge(Float Cb, Float Cs) {
839 I32 ret_mask = ~0;
840 Float ret;
841 auto _c14_ = (Cb)==(0.f);
842 ret = 0.f;
843 ret_mask = ~I32(_c14_);
844 auto _c15_ = (Cs)==(1.f);
845 auto _c16_ = (~(_c14_))&(_c15_);
846 ret = if_then_else(ret_mask & I32(_c16_), 1.f, ret);
847 ret_mask &= ~I32(_c16_);
848 _c15_ = (~(_c14_))&(~(_c15_));
849 ret = if_then_else(ret_mask & I32(_c15_), min(1.f, (Cb)/((1.f)-(Cs))), ret);
850 ret_mask &= ~I32(_c15_);
851 return ret;
852}
853vec3 Multiply(vec3 Cb, vec3 Cs) {
854 return (Cb)*(Cs);
855}
856vec3 Screen(vec3 Cb, vec3 Cs) {
857 return ((Cb)+(Cs))-((Cb)*(Cs));
858}
859vec3 HardLight(vec3 Cb, vec3 Cs) {
860 vec3 m = Multiply(Cb, (2.f)*(Cs));
861 vec3 s = Screen(Cb, ((2.f)*(Cs))-(1.f));
862 vec3_scalar edge = make_vec3(0.5f, 0.5f, 0.5f);
863 return mix(m, s, step(edge, Cs));
864}
865void SetSatInner(Float& Cmin, Float& Cmid, Float& Cmax, Float s, I32 _cond_mask_) {
866 auto _c37_ = (Cmax)>(Cmin);
867 auto _c38_ = (_cond_mask_)&(_c37_);
868 {
869 Cmid = if_then_else(_c38_,(((Cmid)-(Cmin))*(s))/((Cmax)-(Cmin)),Cmid);
870 Cmax = if_then_else(_c38_,s,Cmax);
871 }
872 _c37_ = (_cond_mask_)&(~(_c37_));
873 {
874 Cmid = if_then_else(_c37_,0.f,Cmid);
875 Cmax = if_then_else(_c37_,0.f,Cmax);
876 }
877 Cmin = if_then_else(_cond_mask_,0.f,Cmin);
878}
879vec3 SetSat(vec3 C, Float s) {
880 auto _c26_ = ((C).x)<=((C).y);
881 {
882 auto _c27_ = ((C).y)<=((C).z);
883 auto _c28_ = (_c26_)&(_c27_);
884 {
885 SetSatInner((C).x, (C).y, (C).z, s, _c28_);
886 }
887 _c27_ = (_c26_)&(~(_c27_));
888 {
889 auto _c29_ = ((C).x)<=((C).z);
890 auto _c30_ = (_c27_)&(_c29_);
891 {
892 SetSatInner((C).x, (C).z, (C).y, s, _c30_);
893 }
894 _c29_ = (_c27_)&(~(_c29_));
895 {
896 SetSatInner((C).z, (C).x, (C).y, s, _c29_);
897 }
898 }
899 }
900 {
901 auto _c31_ = ((C).x)<=((C).z);
902 auto _c32_ = (~(_c26_))&(_c31_);
903 {
904 SetSatInner((C).y, (C).x, (C).z, s, _c32_);
905 }
906 _c31_ = (~(_c26_))&(~(_c31_));
907 {
908 auto _c33_ = ((C).y)<=((C).z);
909 auto _c34_ = (_c31_)&(_c33_);
910 {
911 SetSatInner((C).y, (C).z, (C).x, s, _c34_);
912 }
913 _c33_ = (_c31_)&(~(_c33_));
914 {
915 SetSatInner((C).z, (C).y, (C).x, s, _c33_);
916 }
917 }
918 }
919 return C;
920}
921Float Sat(vec3 c) {
922 return (max((c).x, max((c).y, (c).z)))-(min((c).x, min((c).y, (c).z)));
923}
924vec3 Hue(vec3 Cb, vec3 Cs) {
925 return SetLum(SetSat(Cs, Sat(Cb)), Lum(Cb));
926}
927vec3 Luminosity(vec3 Cb, vec3 Cs) {
928 return SetLum(Cb, Lum(Cs));
929}
930vec3 Saturation(vec3 Cb, vec3 Cs) {
931 return SetLum(SetSat(Cb, Sat(Cs)), Lum(Cb));
932}
933Float SoftLight(Float Cb, Float Cs) {
934 I32 ret_mask = ~0;
935 Float ret;
936 auto _c42_ = (Cs)<=(0.5f);
937 {
938 ret = (Cb)-((((1.f)-((2.f)*(Cs)))*(Cb))*((1.f)-(Cb)));
939 ret_mask = ~I32(_c42_);
940 }
941 {
942 Float D;
943 auto _c43_ = (Cb)<=(0.25f);
944 auto _c44_ = (~(_c42_))&(_c43_);
945 D = if_then_else(_c44_,(((((16.f)*(Cb))-(12.f))*(Cb))+(4.f))*(Cb),D);
946 _c43_ = (~(_c42_))&(~(_c43_));
947 D = if_then_else(_c43_,sqrt__glsl_sqrt(Cb),D);
948 ret = if_then_else(ret_mask & I32(~(_c42_)), (Cb)+((((2.f)*(Cs))-(1.f))*((D)-(Cb))), ret);
949 ret_mask &= ~I32(~(_c42_));
Value stored to 'ret_mask' is never read
950 }
951 return ret;
952}
953vec4 fetch_from_gpu_cache_1_direct(ivec2 address) {
954 return texelFetch(sGpuCache, address, 0);
955}
956vec2 rect_repeat(vec2 p, vec2_scalar p0, vec2_scalar p1) {
957 vec2 r = (p)-(p0);
958 vec2_scalar s = (p1)-(p0);
959 vec2_scalar is = (1.f)/(max(s, make_vec2(0.000001f)));
960 return (p0)+((s)*(fract((is)*(r))));
961}
962vec3 LinearToSrgb(vec3 color) {
963 vec3 c1 = (color)*(12.92f);
964 vec3 c2 = ((make_vec3(1.055f))*(pow__glsl_pow(color, make_vec3((1.f)/(2.4f)))))-(make_vec3(0.055f));
965 return mix(c2, c1, lessThanEqual(color, make_vec3(0.0031308f)));
966}
967ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) {
968 vec4 Rs = make_vec4(0.f, 0.f, 0.f, 0.f);
969 vec4 Rb = make_vec4(0.f, 0.f, 0.f, 0.f);
970 vec4 Ns = make_vec4(0.f, 0.f, 0.f, 0.f);
971 vec4 Nb = make_vec4(0.f, 0.f, 0.f, 0.f);
972 ivec4 k;
973 if (((vFilterInputCountFilterKindVec).x)>(0)) {
974 {
975 Rs = sampleInUvRect(sColor0, vInput1Uv, vInput1UvRect);
976 (Ns).lsel(R,G,B) = ((Rs).sel(R,G,B))*((1.f)/(max(0.000001f, (Rs).w)));
977 (Ns).w = (Rs).w;
978 if ((((vFilterInputCountFilterKindVec).y)&(1))!=(0)) {
979 {
980 (Ns).lsel(R,G,B) = SrgbToLinear((Ns).sel(R,G,B));
981 (Rs).lsel(R,G,B) = ((Ns).sel(R,G,B))*((Rs).w);
982 }
983 }
984 }
985 }
986 if (((vFilterInputCountFilterKindVec).x)>(1)) {
987 {
988 Rb = sampleInUvRect(sColor1, vInput2Uv, vInput2UvRect);
989 (Nb).lsel(R,G,B) = ((Rb).sel(R,G,B))*((1.f)/(max(0.000001f, (Rb).w)));
990 (Nb).w = (Rb).w;
991 if ((((vFilterInputCountFilterKindVec).y)&(1))!=(0)) {
992 {
993 (Nb).lsel(R,G,B) = SrgbToLinear((Nb).sel(R,G,B));
994 (Rb).lsel(R,G,B) = ((Nb).sel(R,G,B))*((Rb).w);
995 }
996 }
997 }
998 }
999 vec4 result = make_vec4(1.f, 0.f, 0.f, 1.f);
1000 switch ((vFilterInputCountFilterKindVec).y) {
1001 case 0:
1002 case 1:
1003 result = Rs;
1004 break;
1005 case 2:
1006 case 3:
1007 result = (Rs)*((vFloat0).x);
1008 break;
1009 case 4:
1010 case 5:
1011 oFragColorgl_FragColor = make_vec4(0.f, 0.f, 0.f, (Rs).w);
1012 return;
1013 case 6:
1014 case 7:
1015 (result).lsel(R,G,B) = Color((Nb).sel(R,G,B), (Ns).sel(R,G,B));
1016 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1017 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1018 break;
1019 case 8:
1020 case 9:
1021 (result).lsel(R,G,B) = make_vec3(ColorBurn((Nb).x, (Ns).x), ColorBurn((Nb).y, (Ns).y), ColorBurn((Nb).z, (Ns).z));
1022 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1023 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1024 break;
1025 case 10:
1026 case 11:
1027 (result).lsel(R,G,B) = make_vec3(ColorDodge((Nb).x, (Ns).x), ColorDodge((Nb).y, (Ns).y), ColorDodge((Nb).z, (Ns).z));
1028 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1029 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1030 break;
1031 case 12:
1032 case 13:
1033 (result).lsel(R,G,B) = (((Rs).sel(R,G,B))+((Rb).sel(R,G,B)))-(max(((Rs).sel(R,G,B))*((Rb).w), ((Rb).sel(R,G,B))*((Rs).w)));
1034 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1035 break;
1036 case 14:
1037 case 15:
1038 (result).lsel(R,G,B) = (((Rs).sel(R,G,B))+((Rb).sel(R,G,B)))-((2.f)*(min(((Rs).sel(R,G,B))*((Rb).w), ((Rb).sel(R,G,B))*((Rs).w))));
1039 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1040 break;
1041 case 16:
1042 case 17:
1043 (result).lsel(R,G,B) = (((Rs).sel(R,G,B))+((Rb).sel(R,G,B)))-((2.f)*(((Rs).sel(R,G,B))*((Rb).sel(R,G,B))));
1044 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1045 break;
1046 case 18:
1047 case 19:
1048 (result).lsel(R,G,B) = HardLight((Nb).sel(R,G,B), (Ns).sel(R,G,B));
1049 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1050 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1051 break;
1052 case 20:
1053 case 21:
1054 (result).lsel(R,G,B) = Hue((Nb).sel(R,G,B), (Ns).sel(R,G,B));
1055 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1056 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1057 break;
1058 case 22:
1059 case 23:
1060 (result).lsel(R,G,B) = (((Rs).sel(R,G,B))+((Rb).sel(R,G,B)))-(min(((Rs).sel(R,G,B))*((Rb).w), ((Rb).sel(R,G,B))*((Rs).w)));
1061 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1062 break;
1063 case 24:
1064 case 25:
1065 (result).lsel(R,G,B) = Luminosity((Nb).sel(R,G,B), (Ns).sel(R,G,B));
1066 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1067 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1068 break;
1069 case 26:
1070 case 27:
1071 (result).lsel(R,G,B) = ((((Rs).sel(R,G,B))*((1.f)-((Rb).w)))+(((Rb).sel(R,G,B))*((1.f)-((Rs).w))))+(((Rs).sel(R,G,B))*((Rb).sel(R,G,B)));
1072 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1073 break;
1074 case 28:
1075 case 29:
1076 result = ((Rb)*((1.f)-((Rs).w)))+(Rs);
1077 break;
1078 case 30:
1079 case 31:
1080 (result).lsel(R,G,B) = HardLight((Ns).sel(R,G,B), (Nb).sel(R,G,B));
1081 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1082 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1083 break;
1084 case 32:
1085 case 33:
1086 (result).lsel(R,G,B) = Saturation((Nb).sel(R,G,B), (Ns).sel(R,G,B));
1087 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1088 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1089 break;
1090 case 34:
1091 case 35:
1092 (result).lsel(R,G,B) = (((Rs).sel(R,G,B))+((Rb).sel(R,G,B)))-(((Rs).sel(R,G,B))*((Rb).sel(R,G,B)));
1093 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1094 break;
1095 case 36:
1096 case 37:
1097 (result).lsel(R,G,B) = make_vec3(SoftLight((Nb).x, (Ns).x), SoftLight((Nb).y, (Ns).y), SoftLight((Nb).z, (Ns).z));
1098 (result).lsel(R,G,B) = ((((1.f)-((Rb).w))*((Rs).sel(R,G,B)))+(((1.f)-((Rs).w))*((Rb).sel(R,G,B))))+((((Rs).w)*((Rb).w))*((result).sel(R,G,B)));
1099 (result).w = (((Rb).w)*((1.f)-((Rs).w)))+((Rs).w);
1100 break;
1101 case 38:
1102 case 39:
1103 result = ((vColorMat)*(Ns))+(vFilterData0);
1104 result = clamp(result, make_vec4(0.f), make_vec4(1.f));
1105 (result).lsel(R,G,B) = ((result).sel(R,G,B))*((result).w);
1106 break;
1107 case 40:
1108 case 41:
1109 result = floor__glsl_floor(clamp((Ns)*(255.f), make_vec4(0.f), make_vec4(255.f)));
1110 k = make_ivec4(make_int((result).x), make_int((result).y), make_int((result).z), make_int((result).w));
1111 (result).x = (fetch_from_gpu_cache_1_direct(((vData).sel(X,Y))+(make_ivec2((k).x, 0)))).x;
1112 (result).y = (fetch_from_gpu_cache_1_direct(((vData).sel(X,Y))+(make_ivec2((k).y, 0)))).y;
1113 (result).z = (fetch_from_gpu_cache_1_direct(((vData).sel(X,Y))+(make_ivec2((k).z, 0)))).z;
1114 (result).w = (fetch_from_gpu_cache_1_direct(((vData).sel(X,Y))+(make_ivec2((k).w, 0)))).w;
1115 (result).lsel(R,G,B) = ((result).sel(R,G,B))*((result).w);
1116 break;
1117 case 42:
1118 case 43:
1119 result = (((((Rs)*(Rb))*((vFilterData0).x))+((Rs)*((vFilterData0).y)))+((Rb)*((vFilterData0).z)))+(make_vec4((vFilterData0).w));
1120 result = clamp(result, make_vec4(0.f), make_vec4(1.f));
1121 break;
1122 case 44:
1123 case 45:
1124 result = ((Rs)*((Rb).w))+((Rb)*((1.f)-((Rs).w)));
1125 break;
1126 case 46:
1127 case 47:
1128 result = (Rs)*((Rb).w);
1129 break;
1130 case 48:
1131 case 49:
1132 result = (Rs)+(Rb);
1133 result = clamp(result, make_vec4(0.f), make_vec4(1.f));
1134 break;
1135 case 50:
1136 case 51:
1137 result = (Rs)*((1.f)-((Rb).w));
1138 break;
1139 case 52:
1140 case 53:
1141 result = (Rs)+((Rb)*((1.f)-((Rs).w)));
1142 break;
1143 case 54:
1144 case 55:
1145 result = ((Rs)*((1.f)-((Rb).w)))+((Rb)*((1.f)-((Rs).w)));
1146 break;
1147 case 56:
1148 case 57:
1149 break;
1150 case 58:
1151 case 59:
1152 break;
1153 case 60:
1154 case 61:
1155 break;
1156 case 62:
1157 case 63:
1158 break;
1159 case 64:
1160 case 65:
1161 break;
1162 case 66:
1163 case 67:
1164 break;
1165 case 68:
1166 case 69:
1167 break;
1168 case 70:
1169 case 71:
1170 result = (Rs)+((vFilterData0)*(((Rb).w)*((1.f)-((Rs).w))));
1171 break;
1172 case 72:
1173 case 73:
1174 result = vFilterData0;
1175 break;
1176 case 74:
1177 case 75:
1178 break;
1179 case 76:
1180 case 77:
1181 break;
1182 case 80:
1183 case 81:
1184 break;
1185 case 82:
1186 case 83:
1187 break;
1188 case 86:
1189 case 87:
1190 break;
1191 case 88:
1192 case 89:
1193 break;
1194 case 90:
1195 case 91:
1196 break;
1197 case 92:
1198 case 93:
1199 {
1200 vec2 tileUv = rect_repeat(vInput1Uv, (vInput1UvRect).sel(X,Y), (vInput1UvRect).sel(Z,W));
1201 oFragColorgl_FragColor = sampleInUvRect(sColor0, tileUv, vInput1UvRect);
1202 return;
1203 }
1204 case 94:
1205 case 95:
1206 break;
1207 case 96:
1208 case 97:
1209 break;
1210 case 98:
1211 case 99:
1212 break;
1213 case 100:
1214 case 101:
1215 break;
1216 default:
1217 break;
1218 }
1219 if ((((vFilterInputCountFilterKindVec).y)&(1))!=(0)) {
1220 {
1221 (result).lsel(R,G,B) = (LinearToSrgb(((result).sel(R,G,B))*((1.f)/(max(0.000001f, (result).w)))))*((result).w);
1222 }
1223 }
1224 oFragColorgl_FragColor = result;
1225}
1226typedef cs_svg_filter_node_vert::InterpOutputs InterpInputs;
1227InterpInputs interp_step;
1228struct InterpPerspective {
1229vec2 vInput1Uv;
1230vec2 vInput2Uv;
1231};
1232InterpPerspective interp_perspective;
1233static 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_;
1234 self->vInput1Uv = init_interp(init->vInput1Uv, step->vInput1Uv);
1235 self->interp_step.vInput1Uv = step->vInput1Uv * 4.0f;
1236 self->vInput2Uv = init_interp(init->vInput2Uv, step->vInput2Uv);
1237 self->interp_step.vInput2Uv = step->vInput2Uv * 4.0f;
1238}
1239static 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_;
1240 Float w = 1.0f / self->gl_FragCoord.w;
1241 self->interp_perspective.vInput1Uv = init_interp(init->vInput1Uv, step->vInput1Uv);
1242 self->vInput1Uv = self->interp_perspective.vInput1Uv * w;
1243 self->interp_step.vInput1Uv = step->vInput1Uv * 4.0f;
1244 self->interp_perspective.vInput2Uv = init_interp(init->vInput2Uv, step->vInput2Uv);
1245 self->vInput2Uv = self->interp_perspective.vInput2Uv * w;
1246 self->interp_step.vInput2Uv = step->vInput2Uv * 4.0f;
1247}
1248ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) {
1249 float chunks = steps * 0.25f;
1250 vInput1Uv += interp_step.vInput1Uv * chunks;
1251 vInput2Uv += interp_step.vInput2Uv * chunks;
1252}
1253ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) {
1254 step_perspective(steps);
1255 float chunks = steps * 0.25f;
1256 Float w = 1.0f / gl_FragCoord.w;
1257 interp_perspective.vInput1Uv += interp_step.vInput1Uv * chunks;
1258 vInput1Uv = w * interp_perspective.vInput1Uv;
1259 interp_perspective.vInput2Uv += interp_step.vInput2Uv * chunks;
1260 vInput2Uv = w * interp_perspective.vInput2Uv;
1261}
1262static void run(FragmentShaderImpl* impl) {
1263 Self* self = (Self*)impl;
1264 self->main();
1265 self->step_interp_inputs();
1266}
1267static void skip(FragmentShaderImpl* impl, int steps) {
1268 Self* self = (Self*)impl;
1269 self->step_interp_inputs(steps);
1270}
1271static void run_perspective(FragmentShaderImpl* impl) {
1272 Self* self = (Self*)impl;
1273 self->main();
1274 self->step_perspective_inputs();
1275}
1276static void skip_perspective(FragmentShaderImpl* impl, int steps) {
1277 Self* self = (Self*)impl;
1278 self->step_perspective_inputs(steps);
1279}
1280public:
1281cs_svg_filter_node_frag() {
1282 init_span_func = &read_interp_inputs;
1283 run_func = &run;
1284 skip_func = &skip;
1285 enable_perspective();
1286 init_span_w_func = &read_perspective_inputs;
1287 run_w_func = &run_perspective;
1288 skip_w_func = &skip_perspective;
1289}
1290};
1291
1292struct cs_svg_filter_node_program : ProgramImpl, cs_svg_filter_node_frag {
1293int get_uniform(const char *name) const override {
1294 if (strcmp("sClipMask", name) == 0) { return 7; }
1295 if (strcmp("sColor0", name) == 0) { return 8; }
1296 if (strcmp("sColor1", name) == 0) { return 9; }
1297 if (strcmp("sGpuCache", name) == 0) { return 2; }
1298 if (strcmp("sPrimitiveHeadersF", name) == 0) { return 4; }
1299 if (strcmp("sPrimitiveHeadersI", name) == 0) { return 5; }
1300 if (strcmp("sRenderTasks", name) == 0) { return 1; }
1301 if (strcmp("sTransformPalette", name) == 0) { return 3; }
1302 if (strcmp("uTransform", name) == 0) { return 6; }
1303 return -1;
1304}
1305void bind_attrib(const char* name, int index) override {
1306 attrib_locations.bind_loc(name, index);
1307}
1308int get_attrib(const char* name) const override {
1309 return attrib_locations.get_loc(name);
1310}
1311size_t interpolants_size() const override { return sizeof(InterpOutputs); }
1312VertexShaderImpl* get_vertex_shader() override {
1313 return this;
1314}
1315FragmentShaderImpl* get_fragment_shader() override {
1316 return this;
1317}
1318const char* get_name() const override { return "cs_svg_filter_node"; }
1319static ProgramImpl* loader() { return new cs_svg_filter_node_program; }
1320};
1321