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