| File: | root/firefox-clang/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/swgl-632c403fa1e5c7af/out/ps_path_tile_PATH_SSAA4.h |
| Warning: | line 264, column 14 Value stored to 'texel1' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | struct ps_path_tile_PATH_SSAA4_common { |
| 2 | struct Samplers { |
| 3 | sampler2D_impl sGpuBufferF_impl; |
| 4 | int sGpuBufferF_slot; |
| 5 | isampler2D_impl sGpuBufferI_impl; |
| 6 | int sGpuBufferI_slot; |
| 7 | sampler2D_impl sPathEdges_impl; |
| 8 | int sPathEdges_slot; |
| 9 | sampler2D_impl sRenderTasks_impl; |
| 10 | int sRenderTasks_slot; |
| 11 | bool set_slot(int index, int value) { |
| 12 | switch (index) { |
| 13 | case 2: |
| 14 | sGpuBufferF_slot = value; |
| 15 | return true; |
| 16 | case 3: |
| 17 | sGpuBufferI_slot = value; |
| 18 | return true; |
| 19 | case 5: |
| 20 | sPathEdges_slot = value; |
| 21 | return true; |
| 22 | case 1: |
| 23 | sRenderTasks_slot = value; |
| 24 | return true; |
| 25 | } |
| 26 | return false; |
| 27 | } |
| 28 | } samplers; |
| 29 | struct AttribLocations { |
| 30 | int aPosition = NULL_ATTRIB16; |
| 31 | int aData = NULL_ATTRIB16; |
| 32 | void bind_loc(const char* name, int index) { |
| 33 | if (strcmp("aPosition", name) == 0) { aPosition = index; return; } |
| 34 | if (strcmp("aData", name) == 0) { aData = index; return; } |
| 35 | } |
| 36 | int get_loc(const char* name) const { |
| 37 | if (strcmp("aPosition", name) == 0) { return aPosition != NULL_ATTRIB16 ? aPosition : -1; } |
| 38 | if (strcmp("aData", name) == 0) { return aData != NULL_ATTRIB16 ? aData : -1; } |
| 39 | return -1; |
| 40 | } |
| 41 | } attrib_locations; |
| 42 | ivec4_scalar vTileData; |
| 43 | vec4_scalar vColor; |
| 44 | sampler2D sGpuBufferF; |
| 45 | isampler2D sGpuBufferI; |
| 46 | sampler2D sPathEdges; |
| 47 | sampler2D sRenderTasks; |
| 48 | mat4_scalar uTransform; |
| 49 | void bind_textures() { |
| 50 | sGpuBufferF = lookup_sampler(&samplers.sGpuBufferF_impl, samplers.sGpuBufferF_slot); |
| 51 | sGpuBufferI = lookup_isampler(&samplers.sGpuBufferI_impl, samplers.sGpuBufferI_slot); |
| 52 | sPathEdges = lookup_sampler(&samplers.sPathEdges_impl, samplers.sPathEdges_slot); |
| 53 | sRenderTasks = lookup_sampler(&samplers.sRenderTasks_impl, samplers.sRenderTasks_slot); |
| 54 | } |
| 55 | }; |
| 56 | struct ps_path_tile_PATH_SSAA4_vert : VertexShaderImpl, ps_path_tile_PATH_SSAA4_common { |
| 57 | private: |
| 58 | typedef ps_path_tile_PATH_SSAA4_vert Self; |
| 59 | // mat4_scalar uTransform; |
| 60 | vec2 aPosition; |
| 61 | struct RectWithSize_scalar { |
| 62 | vec2_scalar p0; |
| 63 | vec2_scalar size; |
| 64 | RectWithSize_scalar() = default; |
| 65 | RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){} |
| 66 | }; |
| 67 | struct RectWithSize { |
| 68 | vec2 p0; |
| 69 | vec2 size; |
| 70 | RectWithSize() = default; |
| 71 | RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){} |
| 72 | RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){ |
| 73 | } |
| 74 | IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){ |
| 75 | } |
| 76 | friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize( |
| 77 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size)); |
| 78 | }}; |
| 79 | struct RectWithEndpoint_scalar { |
| 80 | vec2_scalar p0; |
| 81 | vec2_scalar p1; |
| 82 | RectWithEndpoint_scalar() = default; |
| 83 | RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){} |
| 84 | }; |
| 85 | struct RectWithEndpoint { |
| 86 | vec2 p0; |
| 87 | vec2 p1; |
| 88 | RectWithEndpoint() = default; |
| 89 | RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){} |
| 90 | RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){ |
| 91 | } |
| 92 | IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){ |
| 93 | } |
| 94 | friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint( |
| 95 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1)); |
| 96 | }}; |
| 97 | // sampler2D sRenderTasks; |
| 98 | struct RenderTaskData_scalar { |
| 99 | RectWithEndpoint_scalar task_rect; |
| 100 | vec4_scalar user_data; |
| 101 | RenderTaskData_scalar() = default; |
| 102 | RenderTaskData_scalar(RectWithEndpoint_scalar task_rect, vec4_scalar user_data) : task_rect(task_rect), user_data(user_data){} |
| 103 | }; |
| 104 | struct RenderTaskData { |
| 105 | RectWithEndpoint task_rect; |
| 106 | vec4 user_data; |
| 107 | RenderTaskData() = default; |
| 108 | RenderTaskData(RectWithEndpoint task_rect, vec4 user_data) : task_rect(task_rect), user_data(user_data){} |
| 109 | RenderTaskData(RectWithEndpoint_scalar task_rect, vec4_scalar user_data):task_rect(task_rect),user_data(user_data){ |
| 110 | } |
| 111 | IMPLICIT RenderTaskData(RenderTaskData_scalar s):task_rect(s.task_rect),user_data(s.user_data){ |
| 112 | } |
| 113 | friend RenderTaskData if_then_else(I32 c, RenderTaskData t, RenderTaskData e) { return RenderTaskData( |
| 114 | if_then_else(c, t.task_rect, e.task_rect), if_then_else(c, t.user_data, e.user_data)); |
| 115 | }}; |
| 116 | struct PictureTask_scalar { |
| 117 | RectWithEndpoint_scalar task_rect; |
| 118 | float device_pixel_scale; |
| 119 | vec2_scalar content_origin; |
| 120 | PictureTask_scalar() = default; |
| 121 | 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){} |
| 122 | }; |
| 123 | struct PictureTask { |
| 124 | RectWithEndpoint task_rect; |
| 125 | Float device_pixel_scale; |
| 126 | vec2 content_origin; |
| 127 | PictureTask() = default; |
| 128 | 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){} |
| 129 | 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){ |
| 130 | } |
| 131 | IMPLICIT PictureTask(PictureTask_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),content_origin(s.content_origin){ |
| 132 | } |
| 133 | friend PictureTask if_then_else(I32 c, PictureTask t, PictureTask e) { return PictureTask( |
| 134 | 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)); |
| 135 | }}; |
| 136 | struct ClipArea_scalar { |
| 137 | RectWithEndpoint_scalar task_rect; |
| 138 | float device_pixel_scale; |
| 139 | vec2_scalar screen_origin; |
| 140 | ClipArea_scalar() = default; |
| 141 | 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){} |
| 142 | }; |
| 143 | struct ClipArea { |
| 144 | RectWithEndpoint task_rect; |
| 145 | Float device_pixel_scale; |
| 146 | vec2 screen_origin; |
| 147 | ClipArea() = default; |
| 148 | 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){} |
| 149 | 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){ |
| 150 | } |
| 151 | IMPLICIT ClipArea(ClipArea_scalar s):task_rect(s.task_rect),device_pixel_scale(s.device_pixel_scale),screen_origin(s.screen_origin){ |
| 152 | } |
| 153 | friend ClipArea if_then_else(I32 c, ClipArea t, ClipArea e) { return ClipArea( |
| 154 | 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)); |
| 155 | }}; |
| 156 | // sampler2D sGpuBufferF; |
| 157 | // isampler2D sGpuBufferI; |
| 158 | // sampler2D sPathEdges; |
| 159 | struct PathTile_scalar { |
| 160 | vec4_scalar rect; |
| 161 | ivec2_scalar edges; |
| 162 | int32_t backdrop; |
| 163 | int32_t path_address; |
| 164 | PathTile_scalar() = default; |
| 165 | PathTile_scalar(vec4_scalar rect, ivec2_scalar edges, int32_t backdrop, int32_t path_address) : rect(rect), edges(edges), backdrop(backdrop), path_address(path_address){} |
| 166 | }; |
| 167 | struct PathTile { |
| 168 | vec4 rect; |
| 169 | ivec2 edges; |
| 170 | I32 backdrop; |
| 171 | I32 path_address; |
| 172 | PathTile() = default; |
| 173 | PathTile(vec4 rect, ivec2 edges, I32 backdrop, I32 path_address) : rect(rect), edges(edges), backdrop(backdrop), path_address(path_address){} |
| 174 | PathTile(vec4_scalar rect, ivec2_scalar edges, int32_t backdrop, int32_t path_address):rect(rect),edges(edges),backdrop(backdrop),path_address(path_address){ |
| 175 | } |
| 176 | IMPLICIT PathTile(PathTile_scalar s):rect(s.rect),edges(s.edges),backdrop(s.backdrop),path_address(s.path_address){ |
| 177 | } |
| 178 | friend PathTile if_then_else(I32 c, PathTile t, PathTile e) { return PathTile( |
| 179 | if_then_else(c, t.rect, e.rect), if_then_else(c, t.edges, e.edges), if_then_else(c, t.backdrop, e.backdrop), if_then_else(c, t.path_address, e.path_address)); |
| 180 | }}; |
| 181 | struct PathInfo_scalar { |
| 182 | int32_t render_task_address; |
| 183 | int32_t fill_rule; |
| 184 | float opacity; |
| 185 | PathInfo_scalar() = default; |
| 186 | PathInfo_scalar(int32_t render_task_address, int32_t fill_rule, float opacity) : render_task_address(render_task_address), fill_rule(fill_rule), opacity(opacity){} |
| 187 | }; |
| 188 | struct PathInfo { |
| 189 | I32 render_task_address; |
| 190 | I32 fill_rule; |
| 191 | Float opacity; |
| 192 | PathInfo() = default; |
| 193 | PathInfo(I32 render_task_address, I32 fill_rule, Float opacity) : render_task_address(render_task_address), fill_rule(fill_rule), opacity(opacity){} |
| 194 | PathInfo(int32_t render_task_address, int32_t fill_rule, float opacity):render_task_address(render_task_address),fill_rule(fill_rule),opacity(opacity){ |
| 195 | } |
| 196 | IMPLICIT PathInfo(PathInfo_scalar s):render_task_address(s.render_task_address),fill_rule(s.fill_rule),opacity(s.opacity){ |
| 197 | } |
| 198 | friend PathInfo if_then_else(I32 c, PathInfo t, PathInfo e) { return PathInfo( |
| 199 | if_then_else(c, t.render_task_address, e.render_task_address), if_then_else(c, t.fill_rule, e.fill_rule), if_then_else(c, t.opacity, e.opacity)); |
| 200 | }}; |
| 201 | struct PathPrimInfo_scalar { |
| 202 | int32_t z_id; |
| 203 | vec4_scalar color; |
| 204 | vec4_scalar scissor; |
| 205 | PathPrimInfo_scalar() = default; |
| 206 | PathPrimInfo_scalar(int32_t z_id, vec4_scalar color, vec4_scalar scissor) : z_id(z_id), color(color), scissor(scissor){} |
| 207 | }; |
| 208 | struct PathPrimInfo { |
| 209 | I32 z_id; |
| 210 | vec4 color; |
| 211 | vec4 scissor; |
| 212 | PathPrimInfo() = default; |
| 213 | PathPrimInfo(I32 z_id, vec4 color, vec4 scissor) : z_id(z_id), color(color), scissor(scissor){} |
| 214 | PathPrimInfo(int32_t z_id, vec4_scalar color, vec4_scalar scissor):z_id(z_id),color(color),scissor(scissor){ |
| 215 | } |
| 216 | IMPLICIT PathPrimInfo(PathPrimInfo_scalar s):z_id(s.z_id),color(s.color),scissor(s.scissor){ |
| 217 | } |
| 218 | friend PathPrimInfo if_then_else(I32 c, PathPrimInfo t, PathPrimInfo e) { return PathPrimInfo( |
| 219 | if_then_else(c, t.z_id, e.z_id), if_then_else(c, t.color, e.color), if_then_else(c, t.scissor, e.scissor)); |
| 220 | }}; |
| 221 | vec2 vUv; |
| 222 | // ivec4_scalar vTileData; |
| 223 | // vec4_scalar vColor; |
| 224 | ivec4_scalar aData; |
| 225 | PathTile_scalar decode_path_tile(ivec4_scalar data) { |
| 226 | PathTile_scalar tile; |
| 227 | vec2_scalar offset = make_vec2(make_float((((data).x)>>(10))&(1023)), make_float(((data).x)&(1023))); |
| 228 | float extend_x = make_float((((data).x)>>(20))&(1023)); |
| 229 | (tile).rect = (make_vec4((offset).x, (offset).y, (((offset).x)+(1.f))+(extend_x), ((offset).y)+(1.f)))*(16.f); |
| 230 | int32_t edge_count = (((data).z)>>(16))&(65535); |
| 231 | (tile).edges = make_ivec2((data).y, ((data).y)+(edge_count)); |
| 232 | (tile).backdrop = (((data).z)&(65535))-(128); |
| 233 | (tile).path_address = (data).w; |
| 234 | return tile; |
| 235 | } |
| 236 | ivec2_scalar get_gpu_buffer_uv(int32_t address) { |
| 237 | return make_ivec2((make_uint(address))%(1024u), (make_uint(address))/(1024u)); |
| 238 | } |
| 239 | ivec4_scalar fetch_from_gpu_buffer_1i(int32_t address) { |
| 240 | ivec2_scalar uv = get_gpu_buffer_uv(address); |
| 241 | return texelFetch(sGpuBufferI, uv, 0); |
| 242 | } |
| 243 | PathInfo_scalar fetch_path_info(int32_t address) { |
| 244 | ivec4_scalar data = fetch_from_gpu_buffer_1i(address); |
| 245 | PathInfo_scalar path; |
| 246 | (path).render_task_address = (data).x; |
| 247 | (path).fill_rule = (data).y; |
| 248 | (path).opacity = (make_float((data).z))/(65535.f); |
| 249 | return path; |
| 250 | } |
| 251 | PathPrimInfo_scalar fetch_path_prim_info(int32_t address) { |
| 252 | ivec4_scalar data = fetch_from_gpu_buffer_1i((address)+(1)); |
| 253 | ivec4_scalar scissor = fetch_from_gpu_buffer_1i((address)+(2)); |
| 254 | PathPrimInfo_scalar prim; |
| 255 | (prim).z_id = (data).x; |
| 256 | (prim).color = (make_vec4(make_float((((data).y)>>(16))&(65535)), make_float(((data).y)&(65535)), make_float((((data).z)>>(16))&(65535)), make_float(((data).z)&(65535))))/(65535.f); |
| 257 | (prim).scissor = make_vec4(scissor); |
| 258 | return prim; |
| 259 | } |
| 260 | RectWithEndpoint_scalar fetch_render_task_rect(int32_t index) { |
| 261 | ivec2_scalar uv = make_ivec2(make_int((2u)*((make_uint(index))%((1024u)/(2u)))), make_int((make_uint(index))/((1024u)/(2u)))); |
| 262 | auto sRenderTasks_uv_fetch = texelFetchPtr(sRenderTasks, uv, 0, 1, 0, 0); |
| 263 | vec4_scalar texel0 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 0, 0); |
| 264 | vec4_scalar texel1 = texelFetchUnchecked(sRenderTasks, sRenderTasks_uv_fetch, 1, 0); |
Value stored to 'texel1' during its initialization is never read | |
| 265 | RectWithEndpoint_scalar task_rect = RectWithEndpoint_scalar((texel0).sel(X,Y), (texel0).sel(Z,W)); |
| 266 | return task_rect; |
| 267 | } |
| 268 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
| 269 | PathTile_scalar tile = decode_path_tile(aData); |
| 270 | PathInfo_scalar path = fetch_path_info((tile).path_address); |
| 271 | PathPrimInfo_scalar prim = fetch_path_prim_info((tile).path_address); |
| 272 | RectWithEndpoint_scalar task_rect = fetch_render_task_rect((path).render_task_address); |
| 273 | vec2_scalar p0 = clamp(((tile).rect).sel(X,Y), ((prim).scissor).sel(X,Y), ((prim).scissor).sel(Z,W)); |
| 274 | vec2_scalar p1 = clamp(((tile).rect).sel(Z,W), ((prim).scissor).sel(X,Y), ((prim).scissor).sel(Z,W)); |
| 275 | vec2 pos = mix(p0, p1, (aPosition).sel(X,Y)); |
| 276 | vUv = (pos)-(((tile).rect).sel(X,Y)); |
| 277 | vTileData = make_ivec4((tile).edges, (tile).backdrop, (path).fill_rule); |
| 278 | vColor = (prim).color; |
| 279 | gl_Position = (uTransform)*(make_vec4(((task_rect).p0)+(pos), make_float((prim).z_id), 1.f)); |
| 280 | } |
| 281 | static void set_uniform_1i(VertexShaderImpl* impl, int index, int value) { |
| 282 | Self* self = (Self*)impl; |
| 283 | if (self->samplers.set_slot(index, value)) return; |
| 284 | switch (index) { |
| 285 | case 2: |
| 286 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferF |
| 287 | break; |
| 288 | case 3: |
| 289 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferI |
| 290 | break; |
| 291 | case 5: |
| 292 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPathEdges |
| 293 | break; |
| 294 | case 1: |
| 295 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
| 296 | break; |
| 297 | case 4: |
| 298 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | static void set_uniform_4fv(VertexShaderImpl* impl, int index, const float *value) { |
| 303 | Self* self = (Self*)impl; |
| 304 | switch (index) { |
| 305 | case 2: |
| 306 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferF |
| 307 | break; |
| 308 | case 3: |
| 309 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferI |
| 310 | break; |
| 311 | case 5: |
| 312 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPathEdges |
| 313 | break; |
| 314 | case 1: |
| 315 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
| 316 | break; |
| 317 | case 4: |
| 318 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // uTransform |
| 319 | break; |
| 320 | } |
| 321 | } |
| 322 | static void set_uniform_matrix4fv(VertexShaderImpl* impl, int index, const float *value) { |
| 323 | Self* self = (Self*)impl; |
| 324 | switch (index) { |
| 325 | case 2: |
| 326 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferF |
| 327 | break; |
| 328 | case 3: |
| 329 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sGpuBufferI |
| 330 | break; |
| 331 | case 5: |
| 332 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sPathEdges |
| 333 | break; |
| 334 | case 1: |
| 335 | assert(0)(static_cast <bool> (0) ? void (0) : __assert_fail ("0" , __builtin_FILE (), __builtin_LINE (), __extension__ __PRETTY_FUNCTION__ )); // sRenderTasks |
| 336 | break; |
| 337 | case 4: |
| 338 | self->uTransform = mat4_scalar::load_from_ptr(value); |
| 339 | break; |
| 340 | } |
| 341 | } |
| 342 | static void load_attribs(VertexShaderImpl* impl, VertexAttrib *attribs, uint32_t start, int instance, int count) {Self* self = (Self*)impl; |
| 343 | load_attrib(self->aPosition, attribs[self->attrib_locations.aPosition], start, instance, count); |
| 344 | load_flat_attrib(self->aData, attribs[self->attrib_locations.aData], start, instance, count); |
| 345 | } |
| 346 | public: |
| 347 | struct InterpOutputs { |
| 348 | vec2_scalar vUv; |
| 349 | }; |
| 350 | private: |
| 351 | ALWAYS_INLINE__attribute__((always_inline)) inline void store_interp_outputs(char* dest_ptr, size_t stride) { |
| 352 | for(int n = 0; n < 4; n++) { |
| 353 | auto* dest = reinterpret_cast<InterpOutputs*>(dest_ptr); |
| 354 | dest->vUv = get_nth(vUv, n); |
| 355 | dest_ptr += stride; |
| 356 | } |
| 357 | } |
| 358 | static void run(VertexShaderImpl* impl, char* interps, size_t interp_stride) { |
| 359 | Self* self = (Self*)impl; |
| 360 | self->main(); |
| 361 | self->store_interp_outputs(interps, interp_stride); |
| 362 | } |
| 363 | static void init_batch(VertexShaderImpl* impl) { |
| 364 | Self* self = (Self*)impl; self->bind_textures(); } |
| 365 | public: |
| 366 | ps_path_tile_PATH_SSAA4_vert() { |
| 367 | set_uniform_1i_func = &set_uniform_1i; |
| 368 | set_uniform_4fv_func = &set_uniform_4fv; |
| 369 | set_uniform_matrix4fv_func = &set_uniform_matrix4fv; |
| 370 | init_batch_func = &init_batch; |
| 371 | load_attribs_func = &load_attribs; |
| 372 | run_primitive_func = &run; |
| 373 | } |
| 374 | }; |
| 375 | |
| 376 | |
| 377 | struct ps_path_tile_PATH_SSAA4_frag : FragmentShaderImpl, ps_path_tile_PATH_SSAA4_vert { |
| 378 | private: |
| 379 | typedef ps_path_tile_PATH_SSAA4_frag Self; |
| 380 | #define oFragColorgl_FragColor gl_FragColor |
| 381 | // vec4 oFragColor; |
| 382 | struct RectWithSize_scalar { |
| 383 | vec2_scalar p0; |
| 384 | vec2_scalar size; |
| 385 | RectWithSize_scalar() = default; |
| 386 | RectWithSize_scalar(vec2_scalar p0, vec2_scalar size) : p0(p0), size(size){} |
| 387 | }; |
| 388 | struct RectWithSize { |
| 389 | vec2 p0; |
| 390 | vec2 size; |
| 391 | RectWithSize() = default; |
| 392 | RectWithSize(vec2 p0, vec2 size) : p0(p0), size(size){} |
| 393 | RectWithSize(vec2_scalar p0, vec2_scalar size):p0(p0),size(size){ |
| 394 | } |
| 395 | IMPLICIT RectWithSize(RectWithSize_scalar s):p0(s.p0),size(s.size){ |
| 396 | } |
| 397 | friend RectWithSize if_then_else(I32 c, RectWithSize t, RectWithSize e) { return RectWithSize( |
| 398 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.size, e.size)); |
| 399 | }}; |
| 400 | struct RectWithEndpoint_scalar { |
| 401 | vec2_scalar p0; |
| 402 | vec2_scalar p1; |
| 403 | RectWithEndpoint_scalar() = default; |
| 404 | RectWithEndpoint_scalar(vec2_scalar p0, vec2_scalar p1) : p0(p0), p1(p1){} |
| 405 | }; |
| 406 | struct RectWithEndpoint { |
| 407 | vec2 p0; |
| 408 | vec2 p1; |
| 409 | RectWithEndpoint() = default; |
| 410 | RectWithEndpoint(vec2 p0, vec2 p1) : p0(p0), p1(p1){} |
| 411 | RectWithEndpoint(vec2_scalar p0, vec2_scalar p1):p0(p0),p1(p1){ |
| 412 | } |
| 413 | IMPLICIT RectWithEndpoint(RectWithEndpoint_scalar s):p0(s.p0),p1(s.p1){ |
| 414 | } |
| 415 | friend RectWithEndpoint if_then_else(I32 c, RectWithEndpoint t, RectWithEndpoint e) { return RectWithEndpoint( |
| 416 | if_then_else(c, t.p0, e.p0), if_then_else(c, t.p1, e.p1)); |
| 417 | }}; |
| 418 | // sampler2D sGpuBufferF; |
| 419 | // isampler2D sGpuBufferI; |
| 420 | // sampler2D sPathEdges; |
| 421 | vec2 vUv; |
| 422 | // ivec4_scalar vTileData; |
| 423 | // vec4_scalar vColor; |
| 424 | Float ssaa_sample(vec2_scalar offset, vec2 edge, Float cross_at_origin, Float y_min, Float y_max, float winding) { |
| 425 | Bool in_y_range = ((y_min)<=((offset).y))&&((y_max)>=((offset).y)); |
| 426 | Float cross = ((cross_at_origin)+(((edge).x)*((offset).y)))-(((edge).y)*((offset).x)); |
| 427 | return if_then_else((in_y_range)&&((cross)>=(0.f)), winding, 0.f); |
| 428 | } |
| 429 | Float path_even_odd(Float winding_number) { |
| 430 | return (1.f)-(abs__glsl_abs((mod(abs__glsl_abs(winding_number), 2.f))-(1.f))); |
| 431 | } |
| 432 | Float path_non_zero(Float winding_number) { |
| 433 | return min(abs__glsl_abs(winding_number), 1.f); |
| 434 | } |
| 435 | Float path_tile_coverage(vec2 uv, ivec2_scalar edges, int32_t backdrop, int32_t fill_rule) { |
| 436 | vec4 wn = make_vec4(make_float(backdrop)); |
| 437 | int32_t end = min((edges).y, ((edges).x)+(512)); |
| 438 | for ( int32_t edge_idx = (edges).x; |
| 439 | (edge_idx)<(end); edge_idx++) { |
| 440 | ivec2_scalar edge_uv = make_ivec2(make_int((make_uint(edge_idx))%(1024u)), make_int((make_uint(edge_idx))/(1024u))); |
| 441 | vec4_scalar edge = (texelFetch(sPathEdges, edge_uv, 0))*((255.f)/(15.f)); |
| 442 | vec2_scalar p0 = (edge).sel(X,Y); |
| 443 | vec2_scalar p1 = (edge).sel(Z,W); |
| 444 | if (((p0).y)==((p1).y)) { |
| 445 | { |
| 446 | continue; |
| 447 | } |
| 448 | } |
| 449 | bool downwards = ((p1).y)>((p0).y); |
| 450 | float s = downwards ? 1.f : -(1.f); |
| 451 | vec2 upper = (downwards ? p0 : p1)-(uv); |
| 452 | vec2 lower = (downwards ? p1 : p0)-(uv); |
| 453 | Float y_min = -((lower).y); |
| 454 | Float y_max = -((upper).y); |
| 455 | auto _c2_ = ((y_min)<=((3.f)/(8.f)))&&((y_max)>=((-(3.f))/(8.f))); |
| 456 | { |
| 457 | vec2_scalar const a = make_vec2((1.f)/(8.f), (-(3.f))/(8.f)); |
| 458 | vec2_scalar const b = make_vec2((-(3.f))/(8.f), (-(1.f))/(8.f)); |
| 459 | vec2_scalar const c = make_vec2((3.f)/(8.f), (1.f)/(8.f)); |
| 460 | vec2_scalar const d = make_vec2((-(1.f))/(8.f), (3.f)/(8.f)); |
| 461 | vec2 v = (lower)-(upper); |
| 462 | Float cross_at_origin = (((v).x)*((upper).y))-(((upper).x)*((v).y)); |
| 463 | (wn).x = if_then_else(_c2_,(wn).x+ssaa_sample(a, v, cross_at_origin, y_min, y_max, s),(wn).x); |
| 464 | (wn).y = if_then_else(_c2_,(wn).y+ssaa_sample(b, v, cross_at_origin, y_min, y_max, s),(wn).y); |
| 465 | (wn).z = if_then_else(_c2_,(wn).z+ssaa_sample(c, v, cross_at_origin, y_min, y_max, s),(wn).z); |
| 466 | (wn).w = if_then_else(_c2_,(wn).w+ssaa_sample(d, v, cross_at_origin, y_min, y_max, s),(wn).w); |
| 467 | } |
| 468 | } |
| 469 | Float mask; |
| 470 | if (((fill_rule)&(1))==(0)) { |
| 471 | { |
| 472 | mask = (((path_even_odd((wn).x))+(path_even_odd((wn).y)))+(path_even_odd((wn).z)))+(path_even_odd((wn).w)); |
| 473 | } |
| 474 | } else { |
| 475 | mask = (((path_non_zero((wn).x))+(path_non_zero((wn).y)))+(path_non_zero((wn).z)))+(path_non_zero((wn).w)); |
| 476 | } |
| 477 | mask *= 0.25f; |
| 478 | if (((fill_rule)&(2))!=(0)) { |
| 479 | { |
| 480 | mask = (1.f)-(mask); |
| 481 | } |
| 482 | } |
| 483 | return mask; |
| 484 | } |
| 485 | ALWAYS_INLINE__attribute__((always_inline)) inline void main(void) { |
| 486 | Float coverage = path_tile_coverage(vUv, (vTileData).sel(X,Y), (vTileData).z, (vTileData).w); |
| 487 | oFragColorgl_FragColor = (vColor)*(coverage); |
| 488 | } |
| 489 | typedef ps_path_tile_PATH_SSAA4_vert::InterpOutputs InterpInputs; |
| 490 | InterpInputs interp_step; |
| 491 | struct InterpPerspective { |
| 492 | vec2 vUv; |
| 493 | }; |
| 494 | InterpPerspective interp_perspective; |
| 495 | 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_; |
| 496 | self->vUv = init_interp(init->vUv, step->vUv); |
| 497 | self->interp_step.vUv = step->vUv * 4.0f; |
| 498 | } |
| 499 | 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_; |
| 500 | Float w = 1.0f / self->gl_FragCoord.w; |
| 501 | self->interp_perspective.vUv = init_interp(init->vUv, step->vUv); |
| 502 | self->vUv = self->interp_perspective.vUv * w; |
| 503 | self->interp_step.vUv = step->vUv * 4.0f; |
| 504 | } |
| 505 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_interp_inputs(int steps = 4) { |
| 506 | float chunks = steps * 0.25f; |
| 507 | vUv += interp_step.vUv * chunks; |
| 508 | } |
| 509 | ALWAYS_INLINE__attribute__((always_inline)) inline void step_perspective_inputs(int steps = 4) { |
| 510 | step_perspective(steps); |
| 511 | float chunks = steps * 0.25f; |
| 512 | Float w = 1.0f / gl_FragCoord.w; |
| 513 | interp_perspective.vUv += interp_step.vUv * chunks; |
| 514 | vUv = w * interp_perspective.vUv; |
| 515 | } |
| 516 | static void run(FragmentShaderImpl* impl) { |
| 517 | Self* self = (Self*)impl; |
| 518 | self->main(); |
| 519 | self->step_interp_inputs(); |
| 520 | } |
| 521 | static void skip(FragmentShaderImpl* impl, int steps) { |
| 522 | Self* self = (Self*)impl; |
| 523 | self->step_interp_inputs(steps); |
| 524 | } |
| 525 | static void run_perspective(FragmentShaderImpl* impl) { |
| 526 | Self* self = (Self*)impl; |
| 527 | self->main(); |
| 528 | self->step_perspective_inputs(); |
| 529 | } |
| 530 | static void skip_perspective(FragmentShaderImpl* impl, int steps) { |
| 531 | Self* self = (Self*)impl; |
| 532 | self->step_perspective_inputs(steps); |
| 533 | } |
| 534 | public: |
| 535 | ps_path_tile_PATH_SSAA4_frag() { |
| 536 | init_span_func = &read_interp_inputs; |
| 537 | run_func = &run; |
| 538 | skip_func = &skip; |
| 539 | enable_perspective(); |
| 540 | init_span_w_func = &read_perspective_inputs; |
| 541 | run_w_func = &run_perspective; |
| 542 | skip_w_func = &skip_perspective; |
| 543 | } |
| 544 | }; |
| 545 | |
| 546 | struct ps_path_tile_PATH_SSAA4_program : ProgramImpl, ps_path_tile_PATH_SSAA4_frag { |
| 547 | int get_uniform(const char *name) const override { |
| 548 | if (strcmp("sGpuBufferF", name) == 0) { return 2; } |
| 549 | if (strcmp("sGpuBufferI", name) == 0) { return 3; } |
| 550 | if (strcmp("sPathEdges", name) == 0) { return 5; } |
| 551 | if (strcmp("sRenderTasks", name) == 0) { return 1; } |
| 552 | if (strcmp("uTransform", name) == 0) { return 4; } |
| 553 | return -1; |
| 554 | } |
| 555 | void bind_attrib(const char* name, int index) override { |
| 556 | attrib_locations.bind_loc(name, index); |
| 557 | } |
| 558 | int get_attrib(const char* name) const override { |
| 559 | return attrib_locations.get_loc(name); |
| 560 | } |
| 561 | size_t interpolants_size() const override { return sizeof(InterpOutputs); } |
| 562 | VertexShaderImpl* get_vertex_shader() override { |
| 563 | return this; |
| 564 | } |
| 565 | FragmentShaderImpl* get_fragment_shader() override { |
| 566 | return this; |
| 567 | } |
| 568 | const char* get_name() const override { return "ps_path_tile_PATH_SSAA4"; } |
| 569 | static ProgramImpl* loader() { return new ps_path_tile_PATH_SSAA4_program; } |
| 570 | }; |
| 571 |