Bug Summary

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