| File: | root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-250521f66641ef82/out/cs_blur_COLOR_TARGET.h |
| Warning: | line 2, column 8 Excessive padding in 'struct cs_blur_COLOR_TARGET_common::Samplers' (32 padding bytes, where 0 is optimal). Optimal fields order: sGpuBufferI_impl, sPrimitiveHeadersI_impl, sClipMask_impl, sColor0_impl, sGpuBufferF_impl, sPrimitiveHeadersF_impl, sRenderTasks_impl, sTransformPalette_impl, sClipMask_slot, sColor0_slot, sGpuBufferF_slot, sGpuBufferI_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 cs_blur_COLOR_TARGET_common { |
| 2 | struct Samplers { |
Excessive padding in 'struct cs_blur_COLOR_TARGET_common::Samplers' (32 padding bytes, where 0 is optimal). Optimal fields order: sGpuBufferI_impl, sPrimitiveHeadersI_impl, sClipMask_impl, sColor0_impl, sGpuBufferF_impl, sPrimitiveHeadersF_impl, sRenderTasks_impl, sTransformPalette_impl, sClipMask_slot, sColor0_slot, sGpuBufferF_slot, sGpuBufferI_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 sGpuBufferF_impl; |
| 8 | int sGpuBufferF_slot; |
| 9 | isampler2D_impl sGpuBufferI_impl; |
| 10 | int sGpuBufferI_slot; |
| 11 | sampler2D_impl sPrimitiveHeadersF_impl; |
| 12 | int sPrimitiveHeadersF_slot; |
| 13 | isampler2D_impl sPrimitiveHeadersI_impl; |
| 14 | int sPrimitiveHeadersI_slot; |
| 15 | sampler2D_impl sRenderTasks_impl; |
| 16 | int sRenderTasks_slot; |
| 17 | sampler2D_impl sTransformPalette_impl; |
| 18 | int sTransformPalette_slot; |
| 19 | bool set_slot(int index, int value) { |
| 20 | switch (index) { |
| 21 | case 8: |
| 22 | sClipMask_slot = value; |
| 23 | return true; |
| 24 | case 9: |
| 25 | sColor0_slot = value; |
| 26 | return true; |
| 27 | case 3: |
| 28 | sGpuBufferF_slot = value; |
| 29 | return true; |
| 30 | case 4: |
| 31 | sGpuBufferI_slot = value; |
| 32 | return true; |
| 33 | case 5: |
| 34 | sPrimitiveHeadersF_slot = value; |
| 35 | return true; |
| 36 | case 6: |
| 37 | sPrimitiveHeadersI_slot = value; |
| 38 | return true; |
| 39 | case 1: |
| 40 | sRenderTasks_slot = value; |
| 41 | return true; |
| 42 | case 2: |
| 43 | sTransformPalette_slot = value; |
| 44 | return true; |
| 45 | } |
| 46 | return false; |
| 47 | } |
| 48 | } samplers; |
| 49 | struct AttribLocations { |
| 50 | int aPosition = NULL_ATTRIB16; |
| 51 | int aData = NULL_ATTRIB16; |
| 52 | int aBlurRenderTaskAddress = NULL_ATTRIB16; |
| 53 | int aBlurSourceTaskAddress = NULL_ATTRIB16; |
| 54 | int aBlurDirection = NULL_ATTRIB16; |
| 55 | int aBlurEdgeMode = NULL_ATTRIB16; |
| 56 | int aBlurParams = 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 | if (strcmp("aBlurRenderTaskAddress", name) == 0) { aBlurRenderTaskAddress = index; return; } |
| 61 | if (strcmp("aBlurSourceTaskAddress", name) == 0) { aBlurSourceTaskAddress = index; return; } |
| 62 | if (strcmp("aBlurDirection", name) == 0) { aBlurDirection = index; return; } |
| 63 | if (strcmp("aBlurEdgeMode", name) == 0) { aBlurEdgeMode = index; return; } |
| 64 | if (strcmp("aBlurParams", name) == 0) { aBlurParams = index; return; } |
| 65 | } |
| 66 | int get_loc(const char* name) const { |
| 67 | if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; } |
| 68 | if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; } |
| 69 | if (strcmp("aBlurRenderTaskAddress", name) == 0) { return aBlurRenderTaskAddress != NULL_ATTRIB16 ? aBlurRenderTaskAddress : -1; } |
| 70 | if (strcmp("aBlurSourceTaskAddress", name) == 0) { return aBlurSourceTaskAddress != NULL_ATTRIB16 ? aBlurSourceTaskAddress : -1; } |
| 71 | if (strcmp("aBlurDirection", name) == 0) { return aBlurDirection != NULL_ATTRIB16 ? aBlurDirection : -1; } |
| 72 | if (strcmp("aBlurEdgeMode", name) == 0) { return aBlurEdgeMode != NULL_ATTRIB16 ? aBlurEdgeMode : -1; } |
| 73 | if (strcmp("aBlurParams", name) == 0) { return aBlurParams != NULL_ATTRIB16 ? aBlurParams : -1; } |
| 74 | return -1; |
| 75 | } |
| 76 | } attrib_locations; |
| 77 | vec4_scalar vTransformBounds; |
| 78 | vec4_scalar vUvRect; |
| 79 | vec4_scalar vUvClampRect; |
| 80 | vec2_scalar vOffsetScale; |
| 81 | ivec2_scalar vSupport; |
| 82 | vec2_scalar vGaussCoefficients; |
| 83 | sampler2D sClipMask; |
| 84 | sampler2D sColor0; |
| 85 | sampler2D sGpuBufferF; |
| 86 | isampler2D sGpuBufferI; |
| 87 | sampler2D sPrimitiveHeadersF; |
| 88 | isampler2D sPrimitiveHeadersI; |
| 89 | sampler2D sRenderTasks; |
| 90 | sampler2D sTransformPalette; |
| 91 | mat4_scalar uTransform; |
| 92 | void bind_textures() { |
| 93 | sClipMask = lookup_sampler(&samplers.sClipMask_impl, samplers.sClipMask_slot); |
| 94 | sColor0 = lookup_sampler(&samplers.sColor0_impl, samplers.sColor0_slot); |
| 95 | sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot); |
| 96 | sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot); |
| 97 | sPrimitiveHeadersF = lookup_sampler(&samplers.sPrimitiveHeadersF_impl, samplers.sPrimitiveHeadersF_slot); |
| 98 | sPrimitiveHeadersI = lookup_isampler(&samplers.sPrimitiveHeadersI_impl, samplers.sPrimitiveHeadersI_slot); |
| 99 | sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot); |
| 100 | sTransformPalette = lookup_sampler(&samplers.sTransformPalette_impl, samplers.sTransformPalette_slot); |
| 101 | } |
| 102 | }; |
| 103 | struct cs_blur_COLOR_TARGET_vert : VertexShaderImpl, cs_blur_COLOR_TARGET_common { |
| 104 | private: |
| 105 | typedef cs_blur_COLOR_TARGET_vert Self; |
| 106 | // mat4_scalar uTransform; |
| 107 | vec2 aPosition; |
| 108 | // sampler2D sColor0; |
| 109 | // sampler2D sColor1; |
| 110 | // sampler2D sColor2; |
| 111 | struct RectWithSize_scalar { |
| 112 | vec2_scalar p0; |
| 113 | vec2_scalar size; |
| 114 | RectWithSize_scalar() = default; |
| 115 | RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){} |
| 116 | }; |
| 117 | struct RectWithSize { |
| 118 | vec2 p0; |
| 119 | vec2 size; |
| 120 | RectWithSize() = default; |
| 121 | RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){} |
| 122 | RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){ |
| 123 | } |
| 124 | IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){ |
| 125 | } |
| 126 | friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize( |
| 127 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size)); |
| 128 | }}; |
| 129 | struct RectWithEndpoint_scalar { |
| 130 | vec2_scalar p0; |
| 131 | vec2_scalar p1; |
| 132 | RectWithEndpoint_scalar() = default; |
| 133 | RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){} |
| 134 | }; |
| 135 | struct RectWithEndpoint { |
| 136 | vec2 p0; |
| 137 | vec2 p1; |
| 138 | RectWithEndpoint() = default; |
| 139 | RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){} |
| 140 | RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){ |
| 141 | } |
| 142 | IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){ |
| 143 | } |
| 144 | friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint( |
| 145 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1)); |
| 146 | }}; |
| 147 | // sampler2D sRenderTasks; |
| 148 | struct RenderTaskData_scalar { |
| 149 | RectWithEndpoint_scalar task_rect; |
| 150 | vec4_scalar user_data; |
| 151 | RenderTaskData_scalar() = default; |
| 152 | RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){} |
| 153 | }; |
| 154 | struct RenderTaskData { |
| 155 | RectWithEndpoint task_rect; |
| 156 | vec4 user_data; |
| 157 | RenderTaskData() = default; |
| 158 | RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){} |
| 159 | RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){ |
| 160 | } |
| 161 | IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){ |
| 162 | } |
| 163 | friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData( |
| 164 | if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data)); |
| 165 | }}; |
| 166 | struct PictureTask_scalar { |
| 167 | RectWithEndpoint_scalar task_rect; |
| 168 | float device_pixel_scale; |
| 169 | vec2_scalar content_origin; |
| 170 | PictureTask_scalar() = default; |
| 171 | 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){} |
| 172 | }; |
| 173 | struct PictureTask { |
| 174 | RectWithEndpoint task_rect; |
| 175 | Float device_pixel_scale; |
| 176 | vec2 content_origin; |
| 177 | PictureTask() = default; |
| 178 | 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){} |
| 179 | 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){ |
| 180 | } |
| 181 | IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){ |
| 182 | } |
| 183 | friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask( |
| 184 | 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)); |
| 185 | }}; |
| 186 | struct ClipArea_scalar { |
| 187 | RectWithEndpoint_scalar task_rect; |
| 188 | float device_pixel_scale; |
| 189 | vec2_scalar screen_origin; |
| 190 | ClipArea_scalar() = default; |
| 191 | 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){} |
| 192 | }; |
| 193 | struct ClipArea { |
| 194 | RectWithEndpoint task_rect; |
| 195 | Float device_pixel_scale; |
| 196 | vec2 screen_origin; |
| 197 | ClipArea() = default; |
| 198 | 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){} |
| 199 | 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){ |
| 200 | } |
| 201 | IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){ |
| 202 | } |
| 203 | friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea( |
| 204 | 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)); |
| 205 | }}; |
| 206 | // vec4_scalar vTransformBounds; |
| 207 | // sampler2D sTransformPalette; |
| 208 | struct Transform_scalar { |
| 209 | mat4_scalar m; |
| 210 | mat4_scalar inv_m; |
| 211 | bool is_axis_aligned; |
| 212 | Transform_scalar() = default; |
| 213 | 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){} |
| 214 | }; |
| 215 | struct Transform { |
| 216 | mat4 m; |
| 217 | mat4 inv_m; |
| 218 | Bool is_axis_aligned; |
| 219 | Transform() = default; |
| 220 | Transform(mat4 m, mat4 inv_m, Bool is_axis_aligned) : m(m), inv_m(inv_m), is_axis_aligned(is_axis_aligned){} |
| 221 | Transform(mat4_scalar m, mat4_scalar inv_m, bool is_axis_aligned):m(m),inv_m(inv_m),is_axis_aligned(is_axis_aligned){ |
| 222 | } |
| 223 | IMPLICIT Transform(Transform_scalar s):m(s.m),inv_m(s.inv_m),is_axis_aligned(s.is_axis_aligned){ |
| 224 | } |
| 225 | friend Transform if_then_else(I32 c, Transform t, Transform e) { return Transform( |
| 226 | 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)); |
| 227 | }}; |
| 228 | // sampler2D sGpuBufferF; |
| 229 | // isampler2D sGpuBufferI; |
| 230 | struct ImageSource_scalar { |
| 231 | RectWithEndpoint_scalar uv_rect; |
| 232 | vec4_scalar user_data; |
| 233 | ImageSource_scalar() = default; |
| 234 | ImageSource_scalar(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data) : uv_rect(uv_rect), user_data(user_data){} |
| 235 | }; |
| 236 | struct ImageSource { |
| 237 | RectWithEndpoint uv_rect; |
| 238 | vec4 user_data; |
| 239 | ImageSource() = default; |
| 240 | ImageSource(RectWithEndpoint uv_rect, vec4 user_data) : uv_rect(uv_rect), user_data(user_data){} |
| 241 | ImageSource(RectWithEndpoint_scalar uv_rect, vec4_scalar user_data):uv_rect(uv_rect),user_data(user_data){ |
| 242 | } |
| 243 | IMPLICIT ImageSource(ImageSource_scalar s):uv_rect(s.uv_rect),user_data(s.user_data){ |
| 244 | } |
| 245 | friend ImageSource if_then_else(I32 c, ImageSource t, ImageSource e) { return ImageSource( |
| 246 | if_then_else(c, t.uv_rect, e.uv_rect), if_then_else(c, t.user_data, e.user_data)); |
| 247 | }}; |
| 248 | struct ImageSourceExtra_scalar { |
| 249 | vec4_scalar st_tl; |
| 250 | vec4_scalar st_tr; |
| 251 | vec4_scalar st_bl; |
| 252 | vec4_scalar st_br; |
| 253 | ImageSourceExtra_scalar() = default; |
| 254 | 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){} |
| 255 | }; |
| 256 | struct ImageSourceExtra { |
| 257 | vec4 st_tl; |
| 258 | vec4 st_tr; |
| 259 | vec4 st_bl; |
| 260 | vec4 st_br; |
| 261 | ImageSourceExtra() = default; |
| 262 | 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){} |
| 263 | 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){ |
| 264 | } |
| 265 | 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){ |
| 266 | } |
| 267 | friend ImageSourceExtra if_then_else(I32 c, ImageSourceExtra t, ImageSourceExtra e) { return ImageSourceExtra( |
| 268 | 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)); |
| 269 | }}; |
| 270 | // sampler2D sClipMask; |
| 271 | // sampler2D sPrimitiveHeadersF; |
| 272 | // isampler2D sPrimitiveHeadersI; |
| 273 | ivec4_scalar aData; |
| 274 | struct Instance_scalar { |
| 275 | int32_t prim_header_address; |
| 276 | int32_t clip_address; |
| 277 | int32_t segment_index; |
| 278 | int32_t flags; |
| 279 | int32_t resource_address; |
| 280 | int32_t brush_kind; |
| 281 | Instance_scalar() = default; |
| 282 | 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){} |
| 283 | }; |
| 284 | struct Instance { |
| 285 | I32 prim_header_address; |
| 286 | I32 clip_address; |
| 287 | I32 segment_index; |
| 288 | I32 flags; |
| 289 | I32 resource_address; |
| 290 | I32 brush_kind; |
| 291 | Instance() = default; |
| 292 | 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){} |
| 293 | 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){ |
| 294 | } |
| 295 | 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){ |
| 296 | } |
| 297 | friend Instance if_then_else(I32 c, Instance t, Instance e) { return Instance( |
| 298 | 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)); |
| 299 | }}; |
| 300 | struct PrimitiveHeader_scalar { |
| 301 | RectWithEndpoint_scalar local_rect; |
| 302 | RectWithEndpoint_scalar local_clip_rect; |
| 303 | float z; |
| 304 | int32_t specific_prim_address; |
| 305 | int32_t transform_id; |
| 306 | int32_t picture_task_address; |
| 307 | ivec4_scalar user_data; |
| 308 | PrimitiveHeader_scalar() = default; |
| 309 | 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){} |
| 310 | }; |
| 311 | struct PrimitiveHeader { |
| 312 | RectWithEndpoint local_rect; |
| 313 | RectWithEndpoint local_clip_rect; |
| 314 | Float z; |
| 315 | I32 specific_prim_address; |
| 316 | I32 transform_id; |
| 317 | I32 picture_task_address; |
| 318 | ivec4 user_data; |
| 319 | PrimitiveHeader() = default; |
| 320 | 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){} |
| 321 | 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){ |
| 322 | } |
| 323 | 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){ |
| 324 | } |
| 325 | friend PrimitiveHeader if_then_else(I32 c, PrimitiveHeader t, PrimitiveHeader e) { return PrimitiveHeader( |
| 326 | 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)); |
| 327 | }}; |
| 328 | struct VertexInfo_scalar { |
| 329 | vec2_scalar local_pos; |
| 330 | vec4_scalar world_pos; |
| 331 | VertexInfo_scalar() = default; |
| 332 | VertexInfo_scalar(vec2_scalar local_pos, vec4_scalar world_pos) : local_pos(local_pos), world_pos(world_pos){} |
| 333 | }; |
| 334 | struct VertexInfo { |
| 335 | vec2 local_pos; |
| 336 | vec4 world_pos; |
| 337 | VertexInfo() = default; |
| 338 | VertexInfo(vec2 local_pos, vec4 world_pos) : local_pos(local_pos), world_pos(world_pos){} |
| 339 | VertexInfo(vec2_scalar local_pos, vec4_scalar world_pos):local_pos(local_pos),world_pos(world_pos){ |
| 340 | } |
| 341 | IMPLICIT VertexInfo(VertexInfo_scalar s):local_pos(s.local_pos),world_pos(s.world_pos){ |
| 342 | } |
| 343 | friend VertexInfo if_then_else(I32 c, VertexInfo t, VertexInfo e) { return VertexInfo( |
| 344 | if_then_else(c, t.local_pos, e.local_pos), if_then_else(c, t.world_pos, e.world_pos)); |
| 345 | }}; |
| 346 | vec2 vUv; |
| 347 | // vec4_scalar vUvRect; |
| 348 | // vec4_scalar vUvClampRect; |
| 349 | // vec2_scalar vOffsetScale; |
| 350 | // ivec2_scalar vSupport; |
| 351 | // vec2_scalar vGaussCoefficients; |
| 352 | int32_t aBlurRenderTaskAddress; |
| 353 | int32_t aBlurSourceTaskAddress; |
| 354 | int32_t aBlurDirection; |
| 355 | int32_t aBlurEdgeMode; |
| 356 | vec3_scalar aBlurParams; |
| 357 | struct BlurTask_scalar { |
| 358 | RectWithEndpoint_scalar task_rect; |
| 359 | float blur_radius; |
| 360 | vec2_scalar blur_region; |
| 361 | BlurTask_scalar() = default; |
| 362 | BlurTask_scalar(RectWithEndpoint_scalar task_rect, float blur_radius, vec2_scalar blur_region) : task_rect(task_rect), blur_radius(blur_radius), blur_region(blur_region){} |
| 363 | }; |
| 364 | struct BlurTask { |
| 365 | RectWithEndpoint task_rect; |
| 366 | Float blur_radius; |
| 367 | vec2 blur_region; |
| 368 | BlurTask() = default; |
| 369 | BlurTask(RectWithEndpoint task_rect, Float blur_radius, vec2 blur_region) : task_rect(task_rect), blur_radius(blur_radius), blur_region(blur_region){} |
| 370 | BlurTask(RectWithEndpoint_scalar task_rect, float blur_radius, vec2_scalar blur_region):task_rect(task_rect),blur_radius(blur_radius),blur_region(blur_region){ |
| 371 | } |
| 372 | IMPLICIT BlurTask(BlurTask_scalar s):task_rect(s.task_rect),blur_radius(s.blur_radius),blur_region(s.blur_region){ |
| 373 | } |
| 374 | friend BlurTask if_then_else(I32 c, BlurTask t, BlurTask e) { return BlurTask( |
| 375 | if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.blur_radius, e.blur_radius), if_then_else(c, t.blur_region, e.blur_region)); |
| 376 | }}; |
| 377 | RectWithEndpoint_scalar fetch_render_task_rect(int32_t index) { |
| 378 | ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u)))); |
| 379 | auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0); |
| 380 | vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0); |
| 381 | vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0); |
| 382 | RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W)); |
| 383 | return task_rect; |
| 384 | } |
| 385 | BlurTask_scalar fetch_blur_task(int32_t address) { |
| 386 | RectWithEndpoint_scalar task_rect = fetch_render_task_rect(address); |
| 387 | BlurTask_scalar task = BlurTask_scalar(task_rect, (aBlurParams).x, (aBlurParams).sel(Y,Z)); |
| 388 | return task; |
| 389 | } |
| 390 | void calculate_gauss_coefficients(float sigma) { |
| 391 | vGaussCoefficients = make_vec2((1.f)/((sqrt__glsl_sqrt((2.f)*(3.1415927f)))*(sigma)), exp__glsl_exp((-(0.5f))/((sigma)*(sigma)))); |
| 392 | vec3_scalar gauss_coefficient = make_vec3(vGaussCoefficients, ((vGaussCoefficients).y)*((vGaussCoefficients).y)); |
| 393 | float gauss_coefficient_total = (gauss_coefficient).x; |
| 394 | for ( int32_t i = 1; |
| 395 | (i)<=((vSupport).x); i += 2) { |
| 396 | (gauss_coefficient).lsel(X,Y) *= (gauss_coefficient).sel(Y,Z); |
| 397 | float gauss_coefficient_subtotal = (gauss_coefficient).x; |
| 398 | (gauss_coefficient).lsel(X,Y) *= (gauss_coefficient).sel(Y,Z); |
| 399 | gauss_coefficient_subtotal += (gauss_coefficient).x; |
| 400 | gauss_coefficient_total += (2.f)*(gauss_coefficient_subtotal); |
| 401 | } |
| 402 | (vGaussCoefficients).x /= gauss_coefficient_total; |
| 403 | } |
| 404 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
| 405 | BlurTask_scalar blur_task = fetch_blur_task(aBlurRenderTaskAddress); |
| 406 | RectWithEndpoint_scalar src_rect = fetch_render_task_rect(aBlurSourceTaskAddress); |
| 407 | RectWithEndpoint_scalar target_rect = (blur_task).task_rect; |
| 408 | vec2_scalar texture_size = make_vec2((textureSize(sColor0, 0)).sel(X,Y)); |
| 409 | (vSupport).x = (make_int(ceil__glsl_ceil((1.5f)*((blur_task).blur_radius))))*(2); |
| 410 | (vSupport).y = aBlurEdgeMode; |
| 411 | if (((vSupport).x)>(0)) { |
| 412 | { |
| 413 | calculate_gauss_coefficients((blur_task).blur_radius); |
| 414 | } |
| 415 | } else { |
| 416 | vGaussCoefficients = make_vec2(1.f, 1.f); |
| 417 | } |
| 418 | switch (aBlurDirection) { |
| 419 | case 0: |
| 420 | vOffsetScale = make_vec2((1.f)/((((src_rect).p1).x)-(((src_rect).p0).x)), 0.f); |
| 421 | break; |
| 422 | case 1: |
| 423 | vOffsetScale = make_vec2(0.f, (1.f)/((((src_rect).p1).y)-(((src_rect).p0).y))); |
| 424 | break; |
| 425 | default: |
| 426 | vOffsetScale = make_vec2(0.f); |
| 427 | } |
| 428 | vUvRect = make_vec4((src_rect).p0, (src_rect).p1); |
| 429 | vUvRect /= (texture_size).sel(X,Y,X,Y); |
| 430 | vUvClampRect = make_vec4(((src_rect).p0)+(make_vec2(0.5f)), (((src_rect).p0)+((blur_task).blur_region))-(make_vec2(0.5f))); |
| 431 | vUvClampRect /= (texture_size).sel(X,Y,X,Y); |
| 432 | vec2 pos = mix((target_rect).p0, (target_rect).p1, (aPosition).sel(X,Y)); |
| 433 | vUv = (aPosition).sel(X,Y); |
| 434 | gl_Position = (uTransform)*(make_vec4(pos, 0.f, 1.f)); |
| 435 | } |
| 436 | static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) { |
| 437 | Self* self = (Self*)impl; |
| 438 | if (self->samplers.set_slot(index, value)) return; |
| 439 | switch (index) { |
| 440 | case 8: |
| 441 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sClipMask |
| 442 | break; |
| 443 | case 9: |
| 444 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
| 445 | break; |
| 446 | case 3: |
| 447 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferF |
| 448 | break; |
| 449 | case 4: |
| 450 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferI |
| 451 | break; |
| 452 | case 5: |
| 453 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersF |
| 454 | break; |
| 455 | case 6: |
| 456 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersI |
| 457 | break; |
| 458 | case 1: |
| 459 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
| 460 | break; |
| 461 | case 2: |
| 462 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sTransformPalette |
| 463 | break; |
| 464 | case 7: |
| 465 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
| 466 | break; |
| 467 | } |
| 468 | } |
| 469 | static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) { |
| 470 | Self* self = (Self*)impl; |
| 471 | switch (index) { |
| 472 | case 8: |
| 473 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sClipMask |
| 474 | break; |
| 475 | case 9: |
| 476 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
| 477 | break; |
| 478 | case 3: |
| 479 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferF |
| 480 | break; |
| 481 | case 4: |
| 482 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferI |
| 483 | break; |
| 484 | case 5: |
| 485 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersF |
| 486 | break; |
| 487 | case 6: |
| 488 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersI |
| 489 | break; |
| 490 | case 1: |
| 491 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
| 492 | break; |
| 493 | case 2: |
| 494 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sTransformPalette |
| 495 | break; |
| 496 | case 7: |
| 497 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
| 498 | break; |
| 499 | } |
| 500 | } |
| 501 | static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) { |
| 502 | Self* self = (Self*)impl; |
| 503 | switch (index) { |
| 504 | case 8: |
| 505 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sClipMask |
| 506 | break; |
| 507 | case 9: |
| 508 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sColor0 |
| 509 | break; |
| 510 | case 3: |
| 511 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferF |
| 512 | break; |
| 513 | case 4: |
| 514 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferI |
| 515 | break; |
| 516 | case 5: |
| 517 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersF |
| 518 | break; |
| 519 | case 6: |
| 520 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPrimitiveHeadersI |
| 521 | break; |
| 522 | case 1: |
| 523 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
| 524 | break; |
| 525 | case 2: |
| 526 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sTransformPalette |
| 527 | break; |
| 528 | case 7: |
| 529 | self->uTransform = mat4_scalar::load_from_ptr(value); |
| 530 | break; |
| 531 | } |
| 532 | } |
| 533 | static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl; |
| 534 | load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count); |
| 535 | load_flat_attrib(self->aBlurRenderTaskAddress, attribs[self->attrib_locations.aBlurRenderTaskAddress], start, instance, count); |
| 536 | load_flat_attrib(self->aBlurSourceTaskAddress, attribs[self->attrib_locations.aBlurSourceTaskAddress], start, instance, count); |
| 537 | load_flat_attrib(self->aBlurDirection, attribs[self->attrib_locations.aBlurDirection], start, instance, count); |
| 538 | load_flat_attrib(self->aBlurEdgeMode, attribs[self->attrib_locations.aBlurEdgeMode], start, instance, count); |
| 539 | load_flat_attrib(self->aBlurParams, attribs[self->attrib_locations.aBlurParams], start, instance, count); |
| 540 | } |
| 541 | public: |
| 542 | struct InterpOutputs { |
| 543 | vec2_scalar vUv; |
| 544 | }; |
| 545 | private: |
| 546 | ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) { |
| 547 | for(int n = 0; n < 4; n++) { |
| 548 | auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr); |
| 549 | dest->vUv = get_nth(vUv, n); |
| 550 | dest_ptr += stride; |
| 551 | } |
| 552 | } |
| 553 | static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) { |
| 554 | Self* self = (Self*)impl; |
| 555 | self->main(); |
| 556 | self->store_interp_outputs(interps, interp_stride); |
| 557 | } |
| 558 | static void init_batch(VertexShaderImpl* impl) { |
| 559 | Self* self = (Self*)impl; self->bind_textures(); } |
| 560 | public: |
| 561 | cs_blur_COLOR_TARGET_vert() { |
| 562 | set_uniform_1i_func = &set_uniform_1i; |
| 563 | set_uniform_4fv_func = &set_uniform_4fv; |
| 564 | set_uniform_matrix4fv_func = &set_uniform_matrix4fv; |
| 565 | init_batch_func = &init_batch; |
| 566 | load_attribs_func = &load_attribs; |
| 567 | run_primitive_func = &run; |
| 568 | } |
| 569 | }; |
| 570 | |
| 571 | |
| 572 | struct cs_blur_COLOR_TARGET_frag : FragmentShaderImpl, cs_blur_COLOR_TARGET_vert { |
| 573 | private: |
| 574 | typedef cs_blur_COLOR_TARGET_frag Self; |
| 575 | #define oFragColorgl_FragColor gl_FragColor |
| 576 | // vec4 oFragColor; |
| 577 | // sampler2D sColor0; |
| 578 | // sampler2D sColor1; |
| 579 | // sampler2D sColor2; |
| 580 | struct RectWithSize_scalar { |
| 581 | vec2_scalar p0; |
| 582 | vec2_scalar size; |
| 583 | RectWithSize_scalar() = default; |
| 584 | RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){} |
| 585 | }; |
| 586 | struct RectWithSize { |
| 587 | vec2 p0; |
| 588 | vec2 size; |
| 589 | RectWithSize() = default; |
| 590 | RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){} |
| 591 | RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){ |
| 592 | } |
| 593 | IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){ |
| 594 | } |
| 595 | friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize( |
| 596 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size)); |
| 597 | }}; |
| 598 | struct RectWithEndpoint_scalar { |
| 599 | vec2_scalar p0; |
| 600 | vec2_scalar p1; |
| 601 | RectWithEndpoint_scalar() = default; |
| 602 | RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){} |
| 603 | }; |
| 604 | struct RectWithEndpoint { |
| 605 | vec2 p0; |
| 606 | vec2 p1; |
| 607 | RectWithEndpoint() = default; |
| 608 | RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){} |
| 609 | RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){ |
| 610 | } |
| 611 | IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){ |
| 612 | } |
| 613 | friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint( |
| 614 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1)); |
| 615 | }}; |
| 616 | // vec4_scalar vTransformBounds; |
| 617 | // sampler2D sGpuBufferF; |
| 618 | // isampler2D sGpuBufferI; |
| 619 | // sampler2D sClipMask; |
| 620 | struct Fragment_scalar { |
| 621 | vec4_scalar color; |
| 622 | Fragment_scalar() = default; |
| 623 | explicit Fragment_scalar(vec4_scalar color) : color(color){} |
| 624 | }; |
| 625 | struct Fragment { |
| 626 | vec4 color; |
| 627 | Fragment() = default; |
| 628 | explicit Fragment(vec4 color) : color(color){} |
| 629 | explicit Fragment(vec4_scalar color):color(color){ |
| 630 | } |
| 631 | IMPLICIT Fragment(Fragment_scalar s):color(s.color){ |
| 632 | } |
| 633 | friend Fragment if_then_else(I32 c, Fragment t, Fragment e) { return Fragment( |
| 634 | if_then_else(c, t.color, e.color)); |
| 635 | }}; |
| 636 | vec2 vUv; |
| 637 | // vec4_scalar vUvRect; |
| 638 | // vec4_scalar vUvClampRect; |
| 639 | // vec2_scalar vOffsetScale; |
| 640 | // ivec2_scalar vSupport; |
| 641 | // vec2_scalar vGaussCoefficients; |
| 642 | vec2 mirrored_repeat(vec2 uv) { |
| 643 | vec2 abs_uv = abs__glsl_abs(uv); |
| 644 | vec2 uv_int = floor__glsl_floor(abs_uv); |
| 645 | vec2 uv_frac = (abs_uv)-(uv_int); |
| 646 | vec2 f = mod(uv_int, make_vec2(2.f)); |
| 647 | return mix(uv_frac, (make_vec2(1.f))-(uv_frac), f); |
| 648 | } |
| 649 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
| 650 | vec2 uv = mix((vUvRect).sel(X,Y), (vUvRect).sel(Z,W), vUv); |
| 651 | vec4 original_color = texture(sColor0, uv); |
| 652 | vec3_scalar gauss_coefficient = make_vec3(vGaussCoefficients, ((vGaussCoefficients).y)*((vGaussCoefficients).y)); |
| 653 | vec4 avg_color = (original_color)*((gauss_coefficient).x); |
| 654 | int32_t support = min((vSupport).x, 300); |
| 655 | for ( int32_t i = 1; |
| 656 | (i)<=(support); i += 2) { |
| 657 | (gauss_coefficient).lsel(X,Y) *= (gauss_coefficient).sel(Y,Z); |
| 658 | float gauss_coefficient_subtotal = (gauss_coefficient).x; |
| 659 | (gauss_coefficient).lsel(X,Y) *= (gauss_coefficient).sel(Y,Z); |
| 660 | gauss_coefficient_subtotal += (gauss_coefficient).x; |
| 661 | float gauss_ratio = ((gauss_coefficient).x)/(gauss_coefficient_subtotal); |
| 662 | vec2_scalar offset = (vOffsetScale)*((make_float(i))+(gauss_ratio)); |
| 663 | vec2 uv0 = (vUv)-(offset); |
| 664 | vec2 uv1 = (vUv)+(offset); |
| 665 | if (((vSupport).y)==(1)) { |
| 666 | { |
| 667 | uv0 = mirrored_repeat(uv0); |
| 668 | uv1 = mirrored_repeat(uv1); |
| 669 | } |
| 670 | } |
| 671 | uv0 = mix((vUvRect).sel(X,Y), (vUvRect).sel(Z,W), uv0); |
| 672 | uv1 = mix((vUvRect).sel(X,Y), (vUvRect).sel(Z,W), uv1); |
| 673 | uv0 = max(uv0, (vUvClampRect).sel(X,Y)); |
| 674 | uv1 = min(uv1, (vUvClampRect).sel(Z,W)); |
| 675 | avg_color += ((texture(sColor0, uv0))+(texture(sColor0, uv1)))*(gauss_coefficient_subtotal); |
| 676 | } |
| 677 | oFragColorgl_FragColor = make_vec4(avg_color); |
| 678 | } |
| 679 | void swgl_drawSpanRGBA8() { |
| 680 | vec2 uv = mix((vUvRect).sel(X,Y), (vUvRect).sel(Z,W), vUv); |
| 681 | swgl_commitGaussianBlurRGBA8(sColor0, uv, vUvClampRect, ((vOffsetScale).x)!=(0.f), (vSupport).x, vGaussCoefficients)do { int drawn = 0; if (blend_key) { drawn = blendGaussianBlur <true>(sColor0, uv, vUvClampRect, swgl_OutRGBA8, swgl_SpanLength , ((vOffsetScale).x)!=(0.f), (vSupport).x, vGaussCoefficients ); } else { drawn = blendGaussianBlur<false>(sColor0, uv , vUvClampRect, swgl_OutRGBA8, swgl_SpanLength, ((vOffsetScale ).x)!=(0.f), (vSupport).x, vGaussCoefficients); } swgl_OutRGBA8 += drawn; swgl_SpanLength -= drawn; } while (0); |
| 682 | } |
| 683 | typedef cs_blur_COLOR_TARGET_vert::InterpOutputs InterpInputs; |
| 684 | InterpInputs interp_step; |
| 685 | struct InterpPerspective { |
| 686 | vec2 vUv; |
| 687 | }; |
| 688 | InterpPerspective interp_perspective; |
| 689 | 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_; |
| 690 | self->vUv = init_interp(init->vUv, step->vUv); |
| 691 | self->interp_step.vUv = step->vUv * 4.0f; |
| 692 | } |
| 693 | 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_; |
| 694 | Float w = 1.0f / self->gl_FragCoord.w; |
| 695 | self->interp_perspective.vUv = init_interp(init->vUv, step->vUv); |
| 696 | self->vUv = self->interp_perspective.vUv * w; |
| 697 | self->interp_step.vUv = step->vUv * 4.0f; |
| 698 | } |
| 699 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) { |
| 700 | float chunks = steps * 0.25f; |
| 701 | vUv += interp_step.vUv * chunks; |
| 702 | } |
| 703 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) { |
| 704 | step_perspective(steps); |
| 705 | float chunks = steps * 0.25f; |
| 706 | Float w = 1.0f / gl_FragCoord.w; |
| 707 | interp_perspective.vUv += interp_step.vUv * chunks; |
| 708 | vUv = w * interp_perspective.vUv; |
| 709 | } |
| 710 | static void run(FragmentShaderImpl* impl) { |
| 711 | Self* self = (Self*)impl; |
| 712 | self->main(); |
| 713 | self->step_interp_inputs(); |
| 714 | } |
| 715 | static void skip(FragmentShaderImpl* impl, int steps) { |
| 716 | Self* self = (Self*)impl; |
| 717 | self->step_interp_inputs(steps); |
| 718 | } |
| 719 | static void run_perspective(FragmentShaderImpl* impl) { |
| 720 | Self* self = (Self*)impl; |
| 721 | self->main(); |
| 722 | self->step_perspective_inputs(); |
| 723 | } |
| 724 | static void skip_perspective(FragmentShaderImpl* impl, int steps) { |
| 725 | Self* self = (Self*)impl; |
| 726 | self->step_perspective_inputs(steps); |
| 727 | } |
| 728 | static int draw_span_RGBA8(FragmentShaderImpl* impl) { |
| 729 | 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); } |
| 730 | public: |
| 731 | cs_blur_COLOR_TARGET_frag() { |
| 732 | init_span_func = &read_interp_inputs; |
| 733 | run_func = &run; |
| 734 | skip_func = &skip; |
| 735 | draw_span_RGBA8_func = &draw_span_RGBA8; |
| 736 | enable_perspective(); |
| 737 | init_span_w_func = &read_perspective_inputs; |
| 738 | run_w_func = &run_perspective; |
| 739 | skip_w_func = &skip_perspective; |
| 740 | } |
| 741 | }; |
| 742 | |
| 743 | struct cs_blur_COLOR_TARGET_program : ProgramImpl, cs_blur_COLOR_TARGET_frag { |
| 744 | int get_uniform(const char *name) const override { |
| 745 | if (strcmp("sClipMask", name) == 0) { return 8; } |
| 746 | if (strcmp("sColor0", name) == 0) { return 9; } |
| 747 | if (strcmp("sGpuBufferF", name) == 0) { return 3; } |
| 748 | if (strcmp("sGpuBufferI", name) == 0) { return 4; } |
| 749 | if (strcmp("sPrimitiveHeadersF", name) == 0) { return 5; } |
| 750 | if (strcmp("sPrimitiveHeadersI", name) == 0) { return 6; } |
| 751 | if (strcmp("sRenderTasks", name) == 0) { return 1; } |
| 752 | if (strcmp("sTransformPalette", name) == 0) { return 2; } |
| 753 | if (strcmp("uTransform", name) == 0) { return 7; } |
| 754 | return -1; |
| 755 | } |
| 756 | void bind_attrib(const char* name, int index) override { |
| 757 | attrib_locations.bind_loc(name, index); |
| 758 | } |
| 759 | int get_attrib(const char* name) const override { |
| 760 | return attrib_locations.get_loc(name); |
| 761 | } |
| 762 | size_t interpolants_size() const override { return sizeof(InterpOutputs); } |
| 763 | VertexShaderImpl* get_vertex_shader() override { |
| 764 | return this; |
| 765 | } |
| 766 | FragmentShaderImpl* get_fragment_shader() override { |
| 767 | return this; |
| 768 | } |
| 769 | const char* get_name() const override { return "cs_blur_COLOR_TARGET"; } |
| 770 | static ProgramImpl* loader() { return new cs_blur_COLOR_TARGET_program; } |
| 771 | }; |
| 772 |