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