File: | var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-6f6517a85091acb7/out/brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV.h |
Warning: | line 2, column 8 Excessive padding in 'struct brush_yuv_image_ALPHA_PASS_TEXTURE_2D_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_2D_YUV_common { |
2 | struct Samplers { |
Excessive padding in 'struct brush_yuv_image_ALPHA_PASS_TEXTURE_2D_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 | sampler2D_impl sColor0_impl; |
6 | int sColor0_slot; |
7 | sampler2D_impl sColor1_impl; |
8 | int sColor1_slot; |
9 | sampler2D_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 | sampler2D sColor0; |
77 | sampler2D sColor1; |
78 | sampler2D 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_2D_YUV_vert : VertexShaderImpl, brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_common { |
98 | private: |
99 | typedef brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert Self; |
100 | // mat4_scalar uTransform; |
101 | vec2 aPosition; |
102 | // sampler2D sColor0; |
103 | // sampler2D sColor1; |
104 | // sampler2D 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 | uv /= texture_size; |
598 | uv_bounds /= (texture_size).sel(X,Y,X,Y); |
599 | } |
600 | 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) { |
601 | vec2 f = (((vi).local_pos)-((local_rect).p0))/(rect_size(local_rect)); |
602 | YuvPrimitive_scalar prim = fetch_yuv_primitive(prim_address); |
603 | vRescaleFactor = 0; |
604 | if ((((prim).channel_bit_depth)>(8))&&(((prim).yuv_format)!=(1))) { |
605 | { |
606 | vRescaleFactor = (16)-((prim).channel_bit_depth); |
607 | } |
608 | } |
609 | YuvColorMatrixInfo_scalar mat_info = get_rgb_from_ycbcr_info(prim); |
610 | vYcbcrBias = (mat_info).ycbcr_bias; |
611 | vRgbFromDebiasedYcbcr = (mat_info).rgb_from_debiased_ycbrc; |
612 | (vFormat).x = (prim).yuv_format; |
613 | if ((((vFormat).x)==(3))||(((vFormat).x)==(99))) { |
614 | { |
615 | ImageSource_scalar res_y = fetch_image_source((prim_user_data).x); |
616 | ImageSource_scalar res_u = fetch_image_source((prim_user_data).y); |
617 | ImageSource_scalar res_v = fetch_image_source((prim_user_data).z); |
618 | write_uv_rect(((res_y).uv_rect).p0, ((res_y).uv_rect).p1, f, make_vec2((textureSize(sColor0, 0)).sel(X,Y)), vUv_Y, vUvBounds_Y); |
619 | write_uv_rect(((res_u).uv_rect).p0, ((res_u).uv_rect).p1, f, make_vec2((textureSize(sColor1, 0)).sel(X,Y)), vUv_U, vUvBounds_U); |
620 | write_uv_rect(((res_v).uv_rect).p0, ((res_v).uv_rect).p1, f, make_vec2((textureSize(sColor2, 0)).sel(X,Y)), vUv_V, vUvBounds_V); |
621 | } |
622 | } else if ((((vFormat).x)==(0))||(((vFormat).x)==(1))) { |
623 | { |
624 | ImageSource_scalar res_y = fetch_image_source((prim_user_data).x); |
625 | ImageSource_scalar res_u = fetch_image_source((prim_user_data).y); |
626 | write_uv_rect(((res_y).uv_rect).p0, ((res_y).uv_rect).p1, f, make_vec2((textureSize(sColor0, 0)).sel(X,Y)), vUv_Y, vUvBounds_Y); |
627 | write_uv_rect(((res_u).uv_rect).p0, ((res_u).uv_rect).p1, f, make_vec2((textureSize(sColor1, 0)).sel(X,Y)), vUv_U, vUvBounds_U); |
628 | } |
629 | } else if (((vFormat).x)==(4)) { |
630 | { |
631 | ImageSource_scalar res_y = fetch_image_source((prim_user_data).x); |
632 | write_uv_rect(((res_y).uv_rect).p0, ((res_y).uv_rect).p1, f, make_vec2((textureSize(sColor0, 0)).sel(X,Y)), vUv_Y, vUvBounds_Y); |
633 | } |
634 | } |
635 | } |
636 | void brush_shader_main_vs(Instance_scalar instance, PrimitiveHeader_scalar ph, Transform_scalar transform, PictureTask_scalar pic_task, ClipArea_scalar clip_area) { |
637 | int32_t edge_flags = (((instance).flags)>>(12))&(15); |
638 | int32_t brush_flags = ((instance).flags)&(4095); |
639 | vec4_scalar segment_data; |
640 | RectWithEndpoint_scalar segment_rect; |
641 | if (((instance).segment_index)==(65535)) { |
642 | { |
643 | segment_rect = (ph).local_rect; |
644 | segment_data = make_vec4(0.f); |
645 | } |
646 | } else { |
647 | int32_t segment_address = (((ph).specific_prim_address)+(1))+(((instance).segment_index)*(2)); |
648 | Array<vec4_scalar,2> segment_info = fetch_from_gpu_cache_2(segment_address); |
649 | segment_rect = RectWithEndpoint_scalar((segment_info[0]).sel(X,Y), (segment_info[0]).sel(Z,W)); |
650 | (segment_rect).p0 += ((ph).local_rect).p0; |
651 | (segment_rect).p1 += ((ph).local_rect).p0; |
652 | segment_data = segment_info[1]; |
653 | } |
654 | RectWithEndpoint_scalar adjusted_segment_rect = segment_rect; |
655 | bool antialiased = (!((transform).is_axis_aligned))||(((brush_flags)&(1024))!=(0)); |
656 | if (antialiased) { |
657 | { |
658 | adjusted_segment_rect = clip_and_init_antialiasing(segment_rect, (ph).local_rect, (ph).local_clip_rect, edge_flags, (ph).z, transform, pic_task); |
659 | ((ph).local_clip_rect).p0 = make_vec2(-(10000000000000000.f)); |
660 | ((ph).local_clip_rect).p1 = make_vec2(10000000000000000.f); |
661 | } |
662 | } else { |
663 | } |
664 | vec2 local_pos = mix((adjusted_segment_rect).p0, (adjusted_segment_rect).p1, (aPosition).sel(X,Y)); |
665 | VertexInfo vi = write_vertex(local_pos, (ph).local_clip_rect, (ph).z, transform, pic_task); |
666 | write_clip((vi).world_pos, clip_area, pic_task); |
667 | 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); |
668 | } |
669 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
670 | Instance_scalar instance = decode_instance_attributes(); |
671 | PrimitiveHeader_scalar ph = fetch_prim_header((instance).prim_header_address); |
672 | Transform_scalar transform = fetch_transform((ph).transform_id); |
673 | PictureTask_scalar task = fetch_picture_task((ph).picture_task_address); |
674 | ClipArea_scalar clip_area = fetch_clip_area((instance).clip_address); |
675 | brush_shader_main_vs(instance, ph, transform, task, clip_area); |
676 | } |
677 | static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) { |
678 | Self* self = (Self*)impl; |
679 | if (self->samplers.set_slot(index, value)) return; |
680 | switch (index) { |
681 | case 7: |
682 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sClipMask |
683 | break; |
684 | case 8: |
685 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
686 | break; |
687 | case 9: |
688 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor1 |
689 | break; |
690 | case 10: |
691 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor2 |
692 | break; |
693 | case 2: |
694 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuCache |
695 | break; |
696 | case 4: |
697 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersF |
698 | break; |
699 | case 5: |
700 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersI |
701 | break; |
702 | case 1: |
703 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
704 | break; |
705 | case 3: |
706 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sTransformPalette |
707 | break; |
708 | case 6: |
709 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
710 | break; |
711 | } |
712 | } |
713 | static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) { |
714 | Self* self = (Self*)impl; |
715 | switch (index) { |
716 | case 7: |
717 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sClipMask |
718 | break; |
719 | case 8: |
720 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
721 | break; |
722 | case 9: |
723 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor1 |
724 | break; |
725 | case 10: |
726 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor2 |
727 | break; |
728 | case 2: |
729 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuCache |
730 | break; |
731 | case 4: |
732 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersF |
733 | break; |
734 | case 5: |
735 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersI |
736 | break; |
737 | case 1: |
738 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
739 | break; |
740 | case 3: |
741 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sTransformPalette |
742 | break; |
743 | case 6: |
744 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
745 | break; |
746 | } |
747 | } |
748 | static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) { |
749 | Self* self = (Self*)impl; |
750 | switch (index) { |
751 | case 7: |
752 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sClipMask |
753 | break; |
754 | case 8: |
755 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
756 | break; |
757 | case 9: |
758 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor1 |
759 | break; |
760 | case 10: |
761 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor2 |
762 | break; |
763 | case 2: |
764 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuCache |
765 | break; |
766 | case 4: |
767 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersF |
768 | break; |
769 | case 5: |
770 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersI |
771 | break; |
772 | case 1: |
773 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
774 | break; |
775 | case 3: |
776 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sTransformPalette |
777 | break; |
778 | case 6: |
779 | self->uTransform = mat4_scalar::load_from_ptr(value); |
780 | break; |
781 | } |
782 | } |
783 | static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl; |
784 | load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count); |
785 | load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count); |
786 | } |
787 | public: |
788 | struct InterpOutputs { |
789 | vec2_scalar vUv_Y; |
790 | vec2_scalar vUv_U; |
791 | vec2_scalar vUv_V; |
792 | }; |
793 | private: |
794 | ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) { |
795 | for(int n = 0; n < 4; n++) { |
796 | auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr); |
797 | dest->vUv_Y = get_nth(vUv_Y, n); |
798 | dest->vUv_U = get_nth(vUv_U, n); |
799 | dest->vUv_V = get_nth(vUv_V, n); |
800 | dest_ptr += stride; |
801 | } |
802 | } |
803 | static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) { |
804 | Self* self = (Self*)impl; |
805 | self->main(); |
806 | self->store_interp_outputs(interps, interp_stride); |
807 | } |
808 | static void init_batch(VertexShaderImpl* impl) { |
809 | Self* self = (Self*)impl; self->bind_textures(); } |
810 | public: |
811 | brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert() { |
812 | set_uniform_1i_func = &set_uniform_1i; |
813 | set_uniform_4fv_func = &set_uniform_4fv; |
814 | set_uniform_matrix4fv_func = &set_uniform_matrix4fv; |
815 | init_batch_func = &init_batch; |
816 | load_attribs_func = &load_attribs; |
817 | run_primitive_func = &run; |
818 | } |
819 | }; |
820 | |
821 | mat3_scalar constexpr brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert::RgbFromYuv_Rec601; |
822 | mat3_scalar constexpr brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert::RgbFromYuv_Rec709; |
823 | mat3_scalar constexpr brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert::RgbFromYuv_Rec2020; |
824 | mat3_scalar constexpr brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert::RgbFromYuv_GbrIdentity; |
825 | |
826 | struct brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_frag : FragmentShaderImpl, brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert { |
827 | private: |
828 | typedef brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_frag Self; |
829 | #define oFragColorgl_FragColor gl_FragColor |
830 | // vec4 oFragColor; |
831 | // sampler2D sColor0; |
832 | // sampler2D sColor1; |
833 | // sampler2D sColor2; |
834 | struct RectWithSize_scalar { |
835 | vec2_scalar p0; |
836 | vec2_scalar size; |
837 | RectWithSize_scalar() = default; |
838 | RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){} |
839 | }; |
840 | struct RectWithSize { |
841 | vec2 p0; |
842 | vec2 size; |
843 | RectWithSize() = default; |
844 | RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){} |
845 | RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){ |
846 | } |
847 | IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){ |
848 | } |
849 | friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize( |
850 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size)); |
851 | }}; |
852 | struct RectWithEndpoint_scalar { |
853 | vec2_scalar p0; |
854 | vec2_scalar p1; |
855 | RectWithEndpoint_scalar() = default; |
856 | RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){} |
857 | }; |
858 | struct RectWithEndpoint { |
859 | vec2 p0; |
860 | vec2 p1; |
861 | RectWithEndpoint() = default; |
862 | RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){} |
863 | RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){ |
864 | } |
865 | IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){ |
866 | } |
867 | friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint( |
868 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1)); |
869 | }}; |
870 | // sampler2D sGpuCache; |
871 | // vec4_scalar vTransformBounds; |
872 | // sampler2D sClipMask; |
873 | struct Fragment_scalar { |
874 | vec4_scalar color; |
875 | Fragment_scalar() = default; |
876 | explicit Fragment_scalar(vec4_scalar color) : color(color){} |
877 | }; |
878 | struct Fragment { |
879 | vec4 color; |
880 | Fragment() = default; |
881 | explicit Fragment(vec4 color) : color(color){} |
882 | explicit Fragment(vec4_scalar color):color(color){ |
883 | } |
884 | IMPLICIT Fragment(Fragment_scalar s):color(s.color){ |
885 | } |
886 | friend Fragment if_then_else(I32 c, Fragment t, Fragment e) { return Fragment( |
887 | if_then_else(c, t.color, e.color)); |
888 | }}; |
889 | vec2 vUv_Y; |
890 | // vec4_scalar vUvBounds_Y; |
891 | vec2 vUv_U; |
892 | // vec4_scalar vUvBounds_U; |
893 | vec2 vUv_V; |
894 | // vec4_scalar vUvBounds_V; |
895 | // vec3_scalar vYcbcrBias; |
896 | // mat3_scalar vRgbFromDebiasedYcbcr; |
897 | // ivec2_scalar vFormat; |
898 | // int32_t vRescaleFactor; |
899 | 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) { |
900 | vec3 ycbcr_sample; |
901 | switch (format) { |
902 | case 3: |
903 | { |
904 | vec2 uv_y = clamp(in_uv_y, (uv_bounds_y).sel(X,Y), (uv_bounds_y).sel(Z,W)); |
905 | vec2 uv_u = clamp(in_uv_u, (uv_bounds_u).sel(X,Y), (uv_bounds_u).sel(Z,W)); |
906 | vec2 uv_v = clamp(in_uv_v, (uv_bounds_v).sel(X,Y), (uv_bounds_v).sel(Z,W)); |
907 | (ycbcr_sample).x = (texture(sColor0, (uv_y).sel(X,Y))).x; |
908 | (ycbcr_sample).y = (texture(sColor1, (uv_u).sel(X,Y))).x; |
909 | (ycbcr_sample).z = (texture(sColor2, (uv_v).sel(X,Y))).x; |
910 | } |
911 | break; |
912 | case 0: |
913 | case 1: |
914 | case 2: |
915 | { |
916 | vec2 uv_y = clamp(in_uv_y, (uv_bounds_y).sel(X,Y), (uv_bounds_y).sel(Z,W)); |
917 | vec2 uv_uv = clamp(in_uv_u, (uv_bounds_u).sel(X,Y), (uv_bounds_u).sel(Z,W)); |
918 | (ycbcr_sample).x = (texture(sColor0, (uv_y).sel(X,Y))).x; |
919 | (ycbcr_sample).lsel(Y,Z) = (texture(sColor1, (uv_uv).sel(X,Y))).sel(R,G); |
920 | } |
921 | break; |
922 | case 4: |
923 | { |
924 | vec2 uv_y = clamp(in_uv_y, (uv_bounds_y).sel(X,Y), (uv_bounds_y).sel(Z,W)); |
925 | ycbcr_sample = (texture(sColor0, (uv_y).sel(X,Y))).sel(G,B,R); |
926 | } |
927 | break; |
928 | default: |
929 | ycbcr_sample = make_vec3(0.f); |
930 | break; |
931 | } |
932 | vec3 rgb = (rgb_from_debiased_ycbrc)*((ycbcr_sample)-(ycbcr_bias)); |
933 | rgb = clamp(rgb, 0.f, 1.f); |
934 | return make_vec4(rgb, 1.f); |
935 | } |
936 | float antialias_brush() { |
937 | return 1.f; |
938 | } |
939 | Fragment brush_fs() { |
940 | vec4 color = sample_yuv((vFormat).x, vYcbcrBias, vRgbFromDebiasedYcbcr, vUv_Y, vUv_U, vUv_V, vUvBounds_Y, vUvBounds_U, vUvBounds_V); |
941 | color *= antialias_brush(); |
942 | return Fragment(color); |
943 | } |
944 | float do_clip() { |
945 | return 1.f; |
946 | } |
947 | void write_output(vec4 color) { |
948 | oFragColorgl_FragColor = color; |
949 | } |
950 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
951 | Fragment frag = brush_fs(); |
952 | float clip_alpha = do_clip(); |
953 | (frag).color *= clip_alpha; |
954 | write_output((frag).color); |
955 | } |
956 | void swgl_drawSpanRGBA8() { |
957 | if (((vFormat).x)==(3)) { |
958 | { |
959 | 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); |
960 | } |
961 | } else if ((((vFormat).x)==(0))||(((vFormat).x)==(1))) { |
962 | { |
963 | 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); |
964 | } |
965 | } else if (((vFormat).x)==(4)) { |
966 | { |
967 | 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); |
968 | } |
969 | } |
970 | } |
971 | typedef brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_vert::InterpOutputs InterpInputs; |
972 | InterpInputs interp_step; |
973 | struct InterpPerspective { |
974 | vec2 vUv_Y; |
975 | vec2 vUv_U; |
976 | vec2 vUv_V; |
977 | }; |
978 | InterpPerspective interp_perspective; |
979 | 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_; |
980 | self->vUv_Y = init_interp(init->vUv_Y, step->vUv_Y); |
981 | self->interp_step.vUv_Y = step->vUv_Y * 4.0f; |
982 | self->vUv_U = init_interp(init->vUv_U, step->vUv_U); |
983 | self->interp_step.vUv_U = step->vUv_U * 4.0f; |
984 | self->vUv_V = init_interp(init->vUv_V, step->vUv_V); |
985 | self->interp_step.vUv_V = step->vUv_V * 4.0f; |
986 | } |
987 | 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_; |
988 | Float w = 1.0f / self->gl_FragCoord.w; |
989 | self->interp_perspective.vUv_Y = init_interp(init->vUv_Y, step->vUv_Y); |
990 | self->vUv_Y = self->interp_perspective.vUv_Y * w; |
991 | self->interp_step.vUv_Y = step->vUv_Y * 4.0f; |
992 | self->interp_perspective.vUv_U = init_interp(init->vUv_U, step->vUv_U); |
993 | self->vUv_U = self->interp_perspective.vUv_U * w; |
994 | self->interp_step.vUv_U = step->vUv_U * 4.0f; |
995 | self->interp_perspective.vUv_V = init_interp(init->vUv_V, step->vUv_V); |
996 | self->vUv_V = self->interp_perspective.vUv_V * w; |
997 | self->interp_step.vUv_V = step->vUv_V * 4.0f; |
998 | } |
999 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) { |
1000 | float chunks = steps * 0.25f; |
1001 | vUv_Y += interp_step.vUv_Y * chunks; |
1002 | vUv_U += interp_step.vUv_U * chunks; |
1003 | vUv_V += interp_step.vUv_V * chunks; |
1004 | } |
1005 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) { |
1006 | step_perspective(steps); |
1007 | float chunks = steps * 0.25f; |
1008 | Float w = 1.0f / gl_FragCoord.w; |
1009 | interp_perspective.vUv_Y += interp_step.vUv_Y * chunks; |
1010 | vUv_Y = w * interp_perspective.vUv_Y; |
1011 | interp_perspective.vUv_U += interp_step.vUv_U * chunks; |
1012 | vUv_U = w * interp_perspective.vUv_U; |
1013 | interp_perspective.vUv_V += interp_step.vUv_V * chunks; |
1014 | vUv_V = w * interp_perspective.vUv_V; |
1015 | } |
1016 | static void run(FragmentShaderImpl* impl) { |
1017 | Self* self = (Self*)impl; |
1018 | self->main(); |
1019 | self->step_interp_inputs(); |
1020 | } |
1021 | static void skip(FragmentShaderImpl* impl, int steps) { |
1022 | Self* self = (Self*)impl; |
1023 | self->step_interp_inputs(steps); |
1024 | } |
1025 | static void run_perspective(FragmentShaderImpl* impl) { |
1026 | Self* self = (Self*)impl; |
1027 | self->main(); |
1028 | self->step_perspective_inputs(); |
1029 | } |
1030 | static void skip_perspective(FragmentShaderImpl* impl, int steps) { |
1031 | Self* self = (Self*)impl; |
1032 | self->step_perspective_inputs(steps); |
1033 | } |
1034 | static int draw_span_RGBA8(FragmentShaderImpl* impl) { |
1035 | 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); } |
1036 | public: |
1037 | brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_frag() { |
1038 | init_span_func = &read_interp_inputs; |
1039 | run_func = &run; |
1040 | skip_func = &skip; |
1041 | draw_span_RGBA8_func = &draw_span_RGBA8; |
1042 | enable_perspective(); |
1043 | init_span_w_func = &read_perspective_inputs; |
1044 | run_w_func = &run_perspective; |
1045 | skip_w_func = &skip_perspective; |
1046 | } |
1047 | }; |
1048 | |
1049 | struct brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_program : ProgramImpl, brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_frag { |
1050 | int get_uniform(const char *name) const override { |
1051 | if (strcmp("sClipMask", name) == 0) { return 7; } |
1052 | if (strcmp("sColor0", name) == 0) { return 8; } |
1053 | if (strcmp("sColor1", name) == 0) { return 9; } |
1054 | if (strcmp("sColor2", name) == 0) { return 10; } |
1055 | if (strcmp("sGpuCache", name) == 0) { return 2; } |
1056 | if (strcmp("sPrimitiveHeadersF", name) == 0) { return 4; } |
1057 | if (strcmp("sPrimitiveHeadersI", name) == 0) { return 5; } |
1058 | if (strcmp("sRenderTasks", name) == 0) { return 1; } |
1059 | if (strcmp("sTransformPalette", name) == 0) { return 3; } |
1060 | if (strcmp("uTransform", name) == 0) { return 6; } |
1061 | return -1; |
1062 | } |
1063 | void bind_attrib(const char* name, int index) override { |
1064 | attrib_locations.bind_loc(name, index); |
1065 | } |
1066 | int get_attrib(const char* name) const override { |
1067 | return attrib_locations.get_loc(name); |
1068 | } |
1069 | size_t interpolants_size() const override { return sizeof(InterpOutputs); } |
1070 | VertexShaderImpl* get_vertex_shader() override { |
1071 | return this; |
1072 | } |
1073 | FragmentShaderImpl* get_fragment_shader() override { |
1074 | return this; |
1075 | } |
1076 | const char* get_name() const override { return "brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV"; } |
1077 | static ProgramImpl* loader() { return new brush_yuv_image_ALPHA_PASS_TEXTURE_2D_YUV_program; } |
1078 | }; |
1079 |