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