~eliasnaur/gio

284659d3eac9868d17bcaac860034334b1b73264 — Elias Naur a month ago c849c5b
gpu/shaders: [compute] remove unused command from kernel4

Signed-off-by: Elias Naur <mail@eliasnaur.com>
3 files changed, 4 insertions(+), 47 deletions(-)

M gpu/shaders.go
M gpu/shaders/kernel4.comp
M gpu/shaders/ptcl.h
M gpu/shaders.go => gpu/shaders.go +2 -2
@@ 238,7 238,7 @@ var (
	}
	shader_coarse_comp = backend.ShaderSources{
		Name:      "coarse.comp",
		GLSL310ES: "#version 310 es\nlayout(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;\n\nstruct Alloc\n{\n    uint offset;\n};\n\nstruct MallocResult\n{\n    Alloc alloc;\n    bool failed;\n};\n\nstruct AnnoFillRef\n{\n    uint offset;\n};\n\nstruct AnnoFill\n{\n    vec4 bbox;\n    uint rgba_color;\n};\n\nstruct AnnoFillImageRef\n{\n    uint offset;\n};\n\nstruct AnnoFillImage\n{\n    vec4 bbox;\n    uint index;\n    ivec2 offset;\n};\n\nstruct AnnoStrokeRef\n{\n    uint offset;\n};\n\nstruct AnnoStroke\n{\n    vec4 bbox;\n    uint rgba_color;\n    float linewidth;\n};\n\nstruct AnnotatedRef\n{\n    uint offset;\n};\n\nstruct BinInstanceRef\n{\n    uint offset;\n};\n\nstruct BinInstance\n{\n    uint element_ix;\n};\n\nstruct PathRef\n{\n    uint offset;\n};\n\nstruct TileRef\n{\n    uint offset;\n};\n\nstruct Path\n{\n    uvec4 bbox;\n    TileRef tiles;\n};\n\nstruct TileSegRef\n{\n    uint offset;\n};\n\nstruct Tile\n{\n    TileSegRef tile;\n    int backdrop;\n};\n\nstruct CmdStrokeRef\n{\n    uint offset;\n};\n\nstruct CmdStroke\n{\n    uint tile_ref;\n    float half_width;\n    uint rgba_color;\n};\n\nstruct CmdFillRef\n{\n    uint offset;\n};\n\nstruct CmdFill\n{\n    uint tile_ref;\n    int backdrop;\n    uint rgba_color;\n};\n\nstruct CmdFillImageRef\n{\n    uint offset;\n};\n\nstruct CmdFillImage\n{\n    uint tile_ref;\n    int backdrop;\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdBeginClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginClip\n{\n    uint tile_ref;\n    int backdrop;\n};\n\nstruct CmdBeginSolidClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginSolidClip\n{\n    float alpha;\n};\n\nstruct CmdEndClipRef\n{\n    uint offset;\n};\n\nstruct CmdEndClip\n{\n    float alpha;\n};\n\nstruct CmdSolidRef\n{\n    uint offset;\n};\n\nstruct CmdSolid\n{\n    uint rgba_color;\n};\n\nstruct CmdSolidImageRef\n{\n    uint offset;\n};\n\nstruct CmdSolidImage\n{\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdJumpRef\n{\n    uint offset;\n};\n\nstruct CmdJump\n{\n    uint new_ref;\n};\n\nstruct CmdRef\n{\n    uint offset;\n};\n\nstruct Config\n{\n    uint n_elements;\n    uint n_pathseg;\n    uint width_in_tiles;\n    uint height_in_tiles;\n    Alloc tile_alloc;\n    Alloc bin_alloc;\n    Alloc ptcl_alloc;\n    Alloc pathseg_alloc;\n    Alloc anno_alloc;\n};\n\nlayout(binding = 0, std430) buffer Memory\n{\n    uint mem_offset;\n    uint mem_error;\n    uint memory[];\n} _307;\n\nlayout(binding = 1, std430) readonly buffer ConfigBuf\n{\n    Config conf;\n} _1178;\n\nshared uint sh_bitmaps[4][128];\nshared Alloc sh_part_elements[128];\nshared uint sh_part_count[128];\nshared uint sh_elements[128];\nshared uint sh_tile_stride[128];\nshared uint sh_tile_width[128];\nshared uint sh_tile_x0[128];\nshared uint sh_tile_y0[128];\nshared uint sh_tile_base[128];\nshared uint sh_tile_count[128];\n\nAlloc new_alloc(uint offset, uint size)\n{\n    Alloc a;\n    a.offset = offset;\n    return a;\n}\n\nAlloc slice_mem(Alloc a, uint offset, uint size)\n{\n    uint param = a.offset + offset;\n    uint param_1 = size;\n    return new_alloc(param, param_1);\n}\n\nbool touch_mem(Alloc alloc, uint offset)\n{\n    return true;\n}\n\nuint read_mem(Alloc alloc, uint offset)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return 0u;\n    }\n    uint v = _307.memory[offset];\n    return v;\n}\n\nBinInstanceRef BinInstance_index(BinInstanceRef ref, uint index)\n{\n    return BinInstanceRef(ref.offset + (index * 4u));\n}\n\nBinInstance BinInstance_read(Alloc a, BinInstanceRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    BinInstance s;\n    s.element_ix = raw0;\n    return s;\n}\n\nuint Annotated_tag(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    return read_mem(param, param_1);\n}\n\nPath Path_read(Alloc a, PathRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Path s;\n    s.bbox = uvec4(raw0 & 65535u, raw0 >> uint(16), raw1 & 65535u, raw1 >> uint(16));\n    s.tiles = TileRef(raw2);\n    return s;\n}\n\nvoid write_tile_alloc(uint el_ix, Alloc a)\n{\n}\n\nAlloc read_tile_alloc(uint el_ix)\n{\n    uint param = 0u;\n    uint param_1 = uint(int(uint(_307.memory.length())) * 4);\n    return new_alloc(param, param_1);\n}\n\nTile Tile_read(Alloc a, TileRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Tile s;\n    s.tile = TileSegRef(raw0);\n    s.backdrop = int(raw1);\n    return s;\n}\n\nAnnoFill AnnoFill_read(Alloc a, AnnoFillRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    AnnoFill s;\n    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.rgba_color = raw4;\n    return s;\n}\n\nAnnoFill Annotated_Fill_read(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    AnnoFillRef param_1 = AnnoFillRef(ref.offset + 4u);\n    return AnnoFill_read(param, param_1);\n}\n\nMallocResult malloc(uint size)\n{\n    MallocResult r;\n    r.failed = false;\n    uint _313 = atomicAdd(_307.mem_offset, size);\n    uint offset = _313;\n    uint param = offset;\n    uint param_1 = size;\n    r.alloc = new_alloc(param, param_1);\n    if ((offset + size) > uint(int(uint(_307.memory.length())) * 4))\n    {\n        r.failed = true;\n        uint _334 = atomicMax(_307.mem_error, 1u);\n        return r;\n    }\n    return r;\n}\n\nvoid write_mem(Alloc alloc, uint offset, uint val)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return;\n    }\n    _307.memory[offset] = val;\n}\n\nvoid CmdJump_write(Alloc a, CmdJumpRef ref, CmdJump s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.new_ref;\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_Jump_write(Alloc a, CmdRef ref, CmdJump s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 12u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdJumpRef param_4 = CmdJumpRef(ref.offset + 4u);\n    CmdJump param_5 = s;\n    CmdJump_write(param_3, param_4, param_5);\n}\n\nbool alloc_cmd(inout Alloc cmd_alloc, inout CmdRef cmd_ref, inout uint cmd_limit)\n{\n    if (cmd_ref.offset < cmd_limit)\n    {\n        return true;\n    }\n    uint param = 1024u;\n    MallocResult _1138 = malloc(param);\n    MallocResult new_cmd = _1138;\n    if (new_cmd.failed)\n    {\n        return false;\n    }\n    CmdJump jump = CmdJump(new_cmd.alloc.offset);\n    Alloc param_1 = cmd_alloc;\n    CmdRef param_2 = cmd_ref;\n    CmdJump param_3 = jump;\n    Cmd_Jump_write(param_1, param_2, param_3);\n    cmd_alloc = new_cmd.alloc;\n    cmd_ref = CmdRef(cmd_alloc.offset);\n    cmd_limit = (cmd_alloc.offset + 1024u) - 40u;\n    return true;\n}\n\nvoid CmdFill_write(Alloc a, CmdFillRef ref, CmdFill s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = uint(s.backdrop);\n    write_mem(param_3, param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 2u;\n    uint param_8 = s.rgba_color;\n    write_mem(param_6, param_7, param_8);\n}\n\nvoid Cmd_Fill_write(Alloc a, CmdRef ref, CmdFill s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 3u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdFillRef param_4 = CmdFillRef(ref.offset + 4u);\n    CmdFill param_5 = s;\n    CmdFill_write(param_3, param_4, param_5);\n}\n\nvoid CmdSolid_write(Alloc a, CmdSolidRef ref, CmdSolid s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.rgba_color;\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_Solid_write(Alloc a, CmdRef ref, CmdSolid s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 9u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdSolidRef param_4 = CmdSolidRef(ref.offset + 4u);\n    CmdSolid param_5 = s;\n    CmdSolid_write(param_3, param_4, param_5);\n}\n\nAnnoFillImage AnnoFillImage_read(Alloc a, AnnoFillImageRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    Alloc param_10 = a;\n    uint param_11 = ix + 5u;\n    uint raw5 = read_mem(param_10, param_11);\n    AnnoFillImage s;\n    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.index = raw4;\n    s.offset = ivec2(int(raw5 << uint(16)) >> 16, int(raw5) >> 16);\n    return s;\n}\n\nAnnoFillImage Annotated_FillImage_read(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    AnnoFillImageRef param_1 = AnnoFillImageRef(ref.offset + 4u);\n    return AnnoFillImage_read(param, param_1);\n}\n\nvoid CmdFillImage_write(Alloc a, CmdFillImageRef ref, CmdFillImage s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = uint(s.backdrop);\n    write_mem(param_3, param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 2u;\n    uint param_8 = s.index;\n    write_mem(param_6, param_7, param_8);\n    Alloc param_9 = a;\n    uint param_10 = ix + 3u;\n    uint param_11 = (uint(s.offset.x) & 65535u) | (uint(s.offset.y) << uint(16));\n    write_mem(param_9, param_10, param_11);\n}\n\nvoid Cmd_FillImage_write(Alloc a, CmdRef ref, CmdFillImage s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 4u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdFillImageRef param_4 = CmdFillImageRef(ref.offset + 4u);\n    CmdFillImage param_5 = s;\n    CmdFillImage_write(param_3, param_4, param_5);\n}\n\nvoid CmdSolidImage_write(Alloc a, CmdSolidImageRef ref, CmdSolidImage s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.index;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = (uint(s.offset.x) & 65535u) | (uint(s.offset.y) << uint(16));\n    write_mem(param_3, param_4, param_5);\n}\n\nvoid Cmd_SolidImage_write(Alloc a, CmdRef ref, CmdSolidImage s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 11u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdSolidImageRef param_4 = CmdSolidImageRef(ref.offset + 4u);\n    CmdSolidImage param_5 = s;\n    CmdSolidImage_write(param_3, param_4, param_5);\n}\n\nvoid CmdBeginClip_write(Alloc a, CmdBeginClipRef ref, CmdBeginClip s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = uint(s.backdrop);\n    write_mem(param_3, param_4, param_5);\n}\n\nvoid Cmd_BeginClip_write(Alloc a, CmdRef ref, CmdBeginClip s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 5u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdBeginClipRef param_4 = CmdBeginClipRef(ref.offset + 4u);\n    CmdBeginClip param_5 = s;\n    CmdBeginClip_write(param_3, param_4, param_5);\n}\n\nvoid CmdBeginSolidClip_write(Alloc a, CmdBeginSolidClipRef ref, CmdBeginSolidClip s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = floatBitsToUint(s.alpha);\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_BeginSolidClip_write(Alloc a, CmdRef ref, CmdBeginSolidClip s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 6u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdBeginSolidClipRef param_4 = CmdBeginSolidClipRef(ref.offset + 4u);\n    CmdBeginSolidClip param_5 = s;\n    CmdBeginSolidClip_write(param_3, param_4, param_5);\n}\n\nvoid CmdEndClip_write(Alloc a, CmdEndClipRef ref, CmdEndClip s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = floatBitsToUint(s.alpha);\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_EndClip_write(Alloc a, CmdRef ref, CmdEndClip s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 7u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdEndClipRef param_4 = CmdEndClipRef(ref.offset + 4u);\n    CmdEndClip param_5 = s;\n    CmdEndClip_write(param_3, param_4, param_5);\n}\n\nAnnoStroke AnnoStroke_read(Alloc a, AnnoStrokeRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    Alloc param_10 = a;\n    uint param_11 = ix + 5u;\n    uint raw5 = read_mem(param_10, param_11);\n    AnnoStroke s;\n    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.rgba_color = raw4;\n    s.linewidth = uintBitsToFloat(raw5);\n    return s;\n}\n\nAnnoStroke Annotated_Stroke_read(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    AnnoStrokeRef param_1 = AnnoStrokeRef(ref.offset + 4u);\n    return AnnoStroke_read(param, param_1);\n}\n\nvoid CmdStroke_write(Alloc a, CmdStrokeRef ref, CmdStroke s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = floatBitsToUint(s.half_width);\n    write_mem(param_3, param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 2u;\n    uint param_8 = s.rgba_color;\n    write_mem(param_6, param_7, param_8);\n}\n\nvoid Cmd_Stroke_write(Alloc a, CmdRef ref, CmdStroke s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 8u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdStrokeRef param_4 = CmdStrokeRef(ref.offset + 4u);\n    CmdStroke param_5 = s;\n    CmdStroke_write(param_3, param_4, param_5);\n}\n\nvoid Cmd_End_write(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 0u;\n    write_mem(param, param_1, param_2);\n}\n\nvoid main()\n{\n    if (_307.mem_error != 0u)\n    {\n        return;\n    }\n    uint width_in_bins = ((_1178.conf.width_in_tiles + 16u) - 1u) / 16u;\n    uint bin_ix = (width_in_bins * gl_WorkGroupID.y) + gl_WorkGroupID.x;\n    uint partition_ix = 0u;\n    uint n_partitions = ((_1178.conf.n_elements + 128u) - 1u) / 128u;\n    uint th_ix = gl_LocalInvocationID.x;\n    uint bin_tile_x = 16u * gl_WorkGroupID.x;\n    uint bin_tile_y = 8u * gl_WorkGroupID.y;\n    uint tile_x = gl_LocalInvocationID.x % 16u;\n    uint tile_y = gl_LocalInvocationID.x / 16u;\n    uint this_tile_ix = (((bin_tile_y + tile_y) * _1178.conf.width_in_tiles) + bin_tile_x) + tile_x;\n    Alloc param;\n    param.offset = _1178.conf.ptcl_alloc.offset;\n    uint param_1 = this_tile_ix * 1024u;\n    uint param_2 = 1024u;\n    Alloc cmd_alloc = slice_mem(param, param_1, param_2);\n    CmdRef cmd_ref = CmdRef(cmd_alloc.offset);\n    uint cmd_limit = (cmd_ref.offset + 1024u) - 40u;\n    uint clip_depth = 0u;\n    uint clip_zero_depth = 0u;\n    uint clip_one_mask = 0u;\n    uint rd_ix = 0u;\n    uint wr_ix = 0u;\n    uint part_start_ix = 0u;\n    uint ready_ix = 0u;\n    Alloc param_3;\n    Alloc param_5;\n    uint _1454;\n    uint element_ix;\n    AnnotatedRef ref;\n    Alloc param_13;\n    Alloc param_15;\n    uint tile_count;\n    Alloc param_21;\n    uint _1765;\n    bool include_tile;\n    Alloc param_26;\n    Tile tile_1;\n    Alloc param_31;\n    CmdFill cmd_fill;\n    Alloc param_45;\n    CmdFillImage cmd_fill_img;\n    CmdSolidImage cmd_solid_img;\n    CmdBeginClip cmd_begin_clip;\n    Alloc param_77;\n    CmdStroke cmd_stroke;\n    while (true)\n    {\n        for (uint i = 0u; i < 4u; i++)\n        {\n            sh_bitmaps[i][th_ix] = 0u;\n        }\n        bool _1506;\n        for (;;)\n        {\n            if ((ready_ix == wr_ix) && (partition_ix < n_partitions))\n            {\n                part_start_ix = ready_ix;\n                uint count = 0u;\n                bool _1304 = th_ix < 128u;\n                bool _1312;\n                if (_1304)\n                {\n                    _1312 = (partition_ix + th_ix) < n_partitions;\n                }\n                else\n                {\n                    _1312 = _1304;\n                }\n                if (_1312)\n                {\n                    uint in_ix = (_1178.conf.bin_alloc.offset >> uint(2)) + ((((partition_ix + th_ix) * 128u) + bin_ix) * 2u);\n                    param_3.offset = _1178.conf.bin_alloc.offset;\n                    uint param_4 = in_ix;\n                    count = read_mem(param_3, param_4);\n                    param_5.offset = _1178.conf.bin_alloc.offset;\n                    uint param_6 = in_ix + 1u;\n                    uint offset = read_mem(param_5, param_6);\n                    uint param_7 = offset;\n                    uint param_8 = count * 4u;\n                    sh_part_elements[th_ix] = new_alloc(param_7, param_8);\n                }\n                for (uint i_1 = 0u; i_1 < 7u; i_1++)\n                {\n                    if (th_ix < 128u)\n                    {\n                        sh_part_count[th_ix] = count;\n                    }\n                    barrier();\n                    if (th_ix < 128u)\n                    {\n                        if (th_ix >= uint(1 << int(i_1)))\n                        {\n                            count += sh_part_count[th_ix - uint(1 << int(i_1))];\n                        }\n                    }\n                    barrier();\n                }\n                if (th_ix < 128u)\n                {\n                    sh_part_count[th_ix] = part_start_ix + count;\n                }\n                barrier();\n                ready_ix = sh_part_count[127];\n                partition_ix += 128u;\n            }\n            uint ix = rd_ix + th_ix;\n            if ((ix >= wr_ix) && (ix < ready_ix))\n            {\n                uint part_ix = 0u;\n                for (uint i_2 = 0u; i_2 < 7u; i_2++)\n                {\n                    uint probe = part_ix + uint(64 >> int(i_2));\n                    if (ix >= sh_part_count[probe - 1u])\n                    {\n                        part_ix = probe;\n                    }\n                }\n                if (part_ix > 0u)\n                {\n                    _1454 = sh_part_count[part_ix - 1u];\n                }\n                else\n                {\n                    _1454 = part_start_ix;\n                }\n                ix -= _1454;\n                Alloc bin_alloc = sh_part_elements[part_ix];\n                BinInstanceRef inst_ref = BinInstanceRef(bin_alloc.offset);\n                BinInstanceRef param_9 = inst_ref;\n                uint param_10 = ix;\n                Alloc param_11 = bin_alloc;\n                BinInstanceRef param_12 = BinInstance_index(param_9, param_10);\n                BinInstance inst = BinInstance_read(param_11, param_12);\n                sh_elements[th_ix] = inst.element_ix;\n            }\n            barrier();\n            wr_ix = min((rd_ix + 128u), ready_ix);\n            bool _1496 = (wr_ix - rd_ix) < 128u;\n            if (_1496)\n            {\n                _1506 = (wr_ix < ready_ix) || (partition_ix < n_partitions);\n            }\n            else\n            {\n                _1506 = _1496;\n            }\n            if (_1506)\n            {\n                continue;\n            }\n            else\n            {\n                break;\n            }\n        }\n        uint tag = 0u;\n        if ((th_ix + rd_ix) < wr_ix)\n        {\n            element_ix = sh_elements[th_ix];\n            ref = AnnotatedRef(_1178.conf.anno_alloc.offset + (element_ix * 28u));\n            param_13.offset = _1178.conf.anno_alloc.offset;\n            AnnotatedRef param_14 = ref;\n            tag = Annotated_tag(param_13, param_14);\n        }\n        switch (tag)\n        {\n            case 2u:\n            case 3u:\n            case 1u:\n            case 4u:\n            case 5u:\n            {\n                uint path_ix = element_ix;\n                param_15.offset = _1178.conf.tile_alloc.offset;\n                PathRef param_16 = PathRef(_1178.conf.tile_alloc.offset + (path_ix * 12u));\n                Path path = Path_read(param_15, param_16);\n                uint stride = path.bbox.z - path.bbox.x;\n                sh_tile_stride[th_ix] = stride;\n                int dx = int(path.bbox.x) - int(bin_tile_x);\n                int dy = int(path.bbox.y) - int(bin_tile_y);\n                int x0 = clamp(dx, 0, 16);\n                int y0 = clamp(dy, 0, 8);\n                int x1 = clamp(int(path.bbox.z) - int(bin_tile_x), 0, 16);\n                int y1 = clamp(int(path.bbox.w) - int(bin_tile_y), 0, 8);\n                sh_tile_width[th_ix] = uint(x1 - x0);\n                sh_tile_x0[th_ix] = uint(x0);\n                sh_tile_y0[th_ix] = uint(y0);\n                tile_count = uint(x1 - x0) * uint(y1 - y0);\n                uint base = path.tiles.offset - (((uint(dy) * stride) + uint(dx)) * 8u);\n                sh_tile_base[th_ix] = base;\n                uint param_17 = path.tiles.offset;\n                uint param_18 = ((path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y)) * 8u;\n                Alloc path_alloc = new_alloc(param_17, param_18);\n                uint param_19 = th_ix;\n                Alloc param_20 = path_alloc;\n                write_tile_alloc(param_19, param_20);\n                break;\n            }\n            default:\n            {\n                tile_count = 0u;\n                break;\n            }\n        }\n        sh_tile_count[th_ix] = tile_count;\n        for (uint i_3 = 0u; i_3 < 7u; i_3++)\n        {\n            barrier();\n            if (th_ix >= uint(1 << int(i_3)))\n            {\n                tile_count += sh_tile_count[th_ix - uint(1 << int(i_3))];\n            }\n            barrier();\n            sh_tile_count[th_ix] = tile_count;\n        }\n        barrier();\n        uint total_tile_count = sh_tile_count[127];\n        for (uint ix_1 = th_ix; ix_1 < total_tile_count; ix_1 += 128u)\n        {\n            uint el_ix = 0u;\n            for (uint i_4 = 0u; i_4 < 7u; i_4++)\n            {\n                uint probe_1 = el_ix + uint(64 >> int(i_4));\n                if (ix_1 >= sh_tile_count[probe_1 - 1u])\n                {\n                    el_ix = probe_1;\n                }\n            }\n            AnnotatedRef ref_1 = AnnotatedRef(_1178.conf.anno_alloc.offset + (sh_elements[el_ix] * 28u));\n            param_21.offset = _1178.conf.anno_alloc.offset;\n            AnnotatedRef param_22 = ref_1;\n            uint tag_1 = Annotated_tag(param_21, param_22);\n            if (el_ix > 0u)\n            {\n                _1765 = sh_tile_count[el_ix - 1u];\n            }\n            else\n            {\n                _1765 = 0u;\n            }\n            uint seq_ix = ix_1 - _1765;\n            uint width = sh_tile_width[el_ix];\n            uint x = sh_tile_x0[el_ix] + (seq_ix % width);\n            uint y = sh_tile_y0[el_ix] + (seq_ix / width);\n            if ((tag_1 == 4u) || (tag_1 == 5u))\n            {\n                include_tile = true;\n            }\n            else\n            {\n                uint param_23 = el_ix;\n                Alloc param_24 = read_tile_alloc(param_23);\n                TileRef param_25 = TileRef(sh_tile_base[el_ix] + (((sh_tile_stride[el_ix] * y) + x) * 8u));\n                Tile tile = Tile_read(param_24, param_25);\n                bool _1826 = tile.tile.offset != 0u;\n                bool _1833;\n                if (!_1826)\n                {\n                    _1833 = tile.backdrop != 0;\n                }\n                else\n                {\n                    _1833 = _1826;\n                }\n                include_tile = _1833;\n            }\n            if (include_tile)\n            {\n                uint el_slice = el_ix / 32u;\n                uint el_mask = uint(1 << int(el_ix & 31u));\n                uint _1854 = atomicOr(sh_bitmaps[el_slice][(y * 16u) + x], el_mask);\n            }\n        }\n        barrier();\n        uint slice_ix = 0u;\n        uint bitmap = sh_bitmaps[0][th_ix];\n        while (true)\n        {\n            if (bitmap == 0u)\n            {\n                slice_ix++;\n                if (slice_ix == 4u)\n                {\n                    break;\n                }\n                bitmap = sh_bitmaps[slice_ix][th_ix];\n                if (bitmap == 0u)\n                {\n                    continue;\n                }\n            }\n            uint element_ref_ix = (slice_ix * 32u) + uint(findLSB(bitmap));\n            uint element_ix_1 = sh_elements[element_ref_ix];\n            bitmap &= (bitmap - 1u);\n            ref = AnnotatedRef(_1178.conf.anno_alloc.offset + (element_ix_1 * 28u));\n            param_26.offset = _1178.conf.anno_alloc.offset;\n            AnnotatedRef param_27 = ref;\n            tag = Annotated_tag(param_26, param_27);\n            if (clip_zero_depth == 0u)\n            {\n                switch (tag)\n                {\n                    case 2u:\n                    {\n                        uint param_28 = element_ref_ix;\n                        Alloc param_29 = read_tile_alloc(param_28);\n                        TileRef param_30 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_29, param_30);\n                        param_31.offset = _1178.conf.anno_alloc.offset;\n                        AnnotatedRef param_32 = ref;\n                        AnnoFill fill = Annotated_Fill_read(param_31, param_32);\n                        Alloc param_33 = cmd_alloc;\n                        CmdRef param_34 = cmd_ref;\n                        uint param_35 = cmd_limit;\n                        bool _1962 = alloc_cmd(param_33, param_34, param_35);\n                        cmd_alloc = param_33;\n                        cmd_ref = param_34;\n                        cmd_limit = param_35;\n                        if (!_1962)\n                        {\n                            break;\n                        }\n                        if (tile_1.tile.offset != 0u)\n                        {\n                            cmd_fill.tile_ref = tile_1.tile.offset;\n                            cmd_fill.backdrop = tile_1.backdrop;\n                            cmd_fill.rgba_color = fill.rgba_color;\n                            Alloc param_36 = cmd_alloc;\n                            CmdRef param_37 = cmd_ref;\n                            CmdFill param_38 = cmd_fill;\n                            Cmd_Fill_write(param_36, param_37, param_38);\n                        }\n                        else\n                        {\n                            Alloc param_39 = cmd_alloc;\n                            CmdRef param_40 = cmd_ref;\n                            CmdSolid param_41 = CmdSolid(fill.rgba_color);\n                            Cmd_Solid_write(param_39, param_40, param_41);\n                        }\n                        cmd_ref.offset += 20u;\n                        break;\n                    }\n                    case 3u:\n                    {\n                        uint param_42 = element_ref_ix;\n                        Alloc param_43 = read_tile_alloc(param_42);\n                        TileRef param_44 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_43, param_44);\n                        param_45.offset = _1178.conf.anno_alloc.offset;\n                        AnnotatedRef param_46 = ref;\n                        AnnoFillImage fill_img = Annotated_FillImage_read(param_45, param_46);\n                        Alloc param_47 = cmd_alloc;\n                        CmdRef param_48 = cmd_ref;\n                        uint param_49 = cmd_limit;\n                        bool _2042 = alloc_cmd(param_47, param_48, param_49);\n                        cmd_alloc = param_47;\n                        cmd_ref = param_48;\n                        cmd_limit = param_49;\n                        if (!_2042)\n                        {\n                            break;\n                        }\n                        if (tile_1.tile.offset != 0u)\n                        {\n                            cmd_fill_img.tile_ref = tile_1.tile.offset;\n                            cmd_fill_img.backdrop = tile_1.backdrop;\n                            cmd_fill_img.index = fill_img.index;\n                            cmd_fill_img.offset = fill_img.offset;\n                            Alloc param_50 = cmd_alloc;\n                            CmdRef param_51 = cmd_ref;\n                            CmdFillImage param_52 = cmd_fill_img;\n                            Cmd_FillImage_write(param_50, param_51, param_52);\n                        }\n                        else\n                        {\n                            cmd_solid_img.index = fill_img.index;\n                            cmd_solid_img.offset = fill_img.offset;\n                            Alloc param_53 = cmd_alloc;\n                            CmdRef param_54 = cmd_ref;\n                            CmdSolidImage param_55 = cmd_solid_img;\n                            Cmd_SolidImage_write(param_53, param_54, param_55);\n                        }\n                        cmd_ref.offset += 20u;\n                        break;\n                    }\n                    case 4u:\n                    {\n                        uint param_56 = element_ref_ix;\n                        Alloc param_57 = read_tile_alloc(param_56);\n                        TileRef param_58 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_57, param_58);\n                        bool _2116 = tile_1.tile.offset == 0u;\n                        bool _2122;\n                        if (_2116)\n                        {\n                            _2122 = tile_1.backdrop == 0;\n                        }\n                        else\n                        {\n                            _2122 = _2116;\n                        }\n                        if (_2122)\n                        {\n                            clip_zero_depth = clip_depth + 1u;\n                        }\n                        else\n                        {\n                            if ((tile_1.tile.offset == 0u) && (clip_depth < 32u))\n                            {\n                                clip_one_mask |= uint(1 << int(clip_depth));\n                            }\n                            else\n                            {\n                                Alloc param_59 = cmd_alloc;\n                                CmdRef param_60 = cmd_ref;\n                                uint param_61 = cmd_limit;\n                                bool _2148 = alloc_cmd(param_59, param_60, param_61);\n                                cmd_alloc = param_59;\n                                cmd_ref = param_60;\n                                cmd_limit = param_61;\n                                if (!_2148)\n                                {\n                                    break;\n                                }\n                                if (tile_1.tile.offset != 0u)\n                                {\n                                    cmd_begin_clip.tile_ref = tile_1.tile.offset;\n                                    cmd_begin_clip.backdrop = tile_1.backdrop;\n                                    Alloc param_62 = cmd_alloc;\n                                    CmdRef param_63 = cmd_ref;\n                                    CmdBeginClip param_64 = cmd_begin_clip;\n                                    Cmd_BeginClip_write(param_62, param_63, param_64);\n                                }\n                                else\n                                {\n                                    float alpha = (tile_1.backdrop == 0) ? 0.0 : 1.0;\n                                    Alloc param_65 = cmd_alloc;\n                                    CmdRef param_66 = cmd_ref;\n                                    CmdBeginSolidClip param_67 = CmdBeginSolidClip(alpha);\n                                    Cmd_BeginSolidClip_write(param_65, param_66, param_67);\n                                }\n                                cmd_ref.offset += 20u;\n                                if (clip_depth < 32u)\n                                {\n                                    clip_one_mask &= uint(~(1 << int(clip_depth)));\n                                }\n                            }\n                        }\n                        clip_depth++;\n                        break;\n                    }\n                    case 5u:\n                    {\n                        clip_depth--;\n                        bool _2211 = clip_depth >= 32u;\n                        bool _2221;\n                        if (!_2211)\n                        {\n                            _2221 = (clip_one_mask & uint(1 << int(clip_depth))) == 0u;\n                        }\n                        else\n                        {\n                            _2221 = _2211;\n                        }\n                        if (_2221)\n                        {\n                            Alloc param_68 = cmd_alloc;\n                            CmdRef param_69 = cmd_ref;\n                            uint param_70 = cmd_limit;\n                            bool _2230 = alloc_cmd(param_68, param_69, param_70);\n                            cmd_alloc = param_68;\n                            cmd_ref = param_69;\n                            cmd_limit = param_70;\n                            if (!_2230)\n                            {\n                                break;\n                            }\n                            Alloc param_71 = cmd_alloc;\n                            CmdRef param_72 = cmd_ref;\n                            CmdEndClip param_73 = CmdEndClip(1.0);\n                            Cmd_EndClip_write(param_71, param_72, param_73);\n                            cmd_ref.offset += 20u;\n                        }\n                        break;\n                    }\n                    case 1u:\n                    {\n                        uint param_74 = element_ref_ix;\n                        Alloc param_75 = read_tile_alloc(param_74);\n                        TileRef param_76 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_75, param_76);\n                        param_77.offset = _1178.conf.anno_alloc.offset;\n                        AnnotatedRef param_78 = ref;\n                        AnnoStroke stroke = Annotated_Stroke_read(param_77, param_78);\n                        cmd_stroke.tile_ref = tile_1.tile.offset;\n                        cmd_stroke.half_width = 0.5 * stroke.linewidth;\n                        cmd_stroke.rgba_color = stroke.rgba_color;\n                        Alloc param_79 = cmd_alloc;\n                        CmdRef param_80 = cmd_ref;\n                        uint param_81 = cmd_limit;\n                        bool _2296 = alloc_cmd(param_79, param_80, param_81);\n                        cmd_alloc = param_79;\n                        cmd_ref = param_80;\n                        cmd_limit = param_81;\n                        if (!_2296)\n                        {\n                            break;\n                        }\n                        Alloc param_82 = cmd_alloc;\n                        CmdRef param_83 = cmd_ref;\n                        CmdStroke param_84 = cmd_stroke;\n                        Cmd_Stroke_write(param_82, param_83, param_84);\n                        cmd_ref.offset += 20u;\n                        break;\n                    }\n                }\n            }\n            else\n            {\n                switch (tag)\n                {\n                    case 4u:\n                    {\n                        clip_depth++;\n                        break;\n                    }\n                    case 5u:\n                    {\n                        if (clip_depth == clip_zero_depth)\n                        {\n                            clip_zero_depth = 0u;\n                        }\n                        clip_depth--;\n                        break;\n                    }\n                }\n            }\n        }\n        barrier();\n        rd_ix += 128u;\n        if ((rd_ix >= ready_ix) && (partition_ix >= n_partitions))\n        {\n            break;\n        }\n    }\n    bool _2351 = (bin_tile_x + tile_x) < _1178.conf.width_in_tiles;\n    bool _2360;\n    if (_2351)\n    {\n        _2360 = (bin_tile_y + tile_y) < _1178.conf.height_in_tiles;\n    }\n    else\n    {\n        _2360 = _2351;\n    }\n    if (_2360)\n    {\n        Alloc param_85 = cmd_alloc;\n        CmdRef param_86 = cmd_ref;\n        Cmd_End_write(param_85, param_86);\n    }\n}\n\n",
		GLSL310ES: "#version 310 es\nlayout(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;\n\nstruct Alloc\n{\n    uint offset;\n};\n\nstruct MallocResult\n{\n    Alloc alloc;\n    bool failed;\n};\n\nstruct AnnoFillRef\n{\n    uint offset;\n};\n\nstruct AnnoFill\n{\n    vec4 bbox;\n    uint rgba_color;\n};\n\nstruct AnnoFillImageRef\n{\n    uint offset;\n};\n\nstruct AnnoFillImage\n{\n    vec4 bbox;\n    uint index;\n    ivec2 offset;\n};\n\nstruct AnnoStrokeRef\n{\n    uint offset;\n};\n\nstruct AnnoStroke\n{\n    vec4 bbox;\n    uint rgba_color;\n    float linewidth;\n};\n\nstruct AnnotatedRef\n{\n    uint offset;\n};\n\nstruct BinInstanceRef\n{\n    uint offset;\n};\n\nstruct BinInstance\n{\n    uint element_ix;\n};\n\nstruct PathRef\n{\n    uint offset;\n};\n\nstruct TileRef\n{\n    uint offset;\n};\n\nstruct Path\n{\n    uvec4 bbox;\n    TileRef tiles;\n};\n\nstruct TileSegRef\n{\n    uint offset;\n};\n\nstruct Tile\n{\n    TileSegRef tile;\n    int backdrop;\n};\n\nstruct CmdStrokeRef\n{\n    uint offset;\n};\n\nstruct CmdStroke\n{\n    uint tile_ref;\n    float half_width;\n    uint rgba_color;\n};\n\nstruct CmdFillRef\n{\n    uint offset;\n};\n\nstruct CmdFill\n{\n    uint tile_ref;\n    int backdrop;\n    uint rgba_color;\n};\n\nstruct CmdFillImageRef\n{\n    uint offset;\n};\n\nstruct CmdFillImage\n{\n    uint tile_ref;\n    int backdrop;\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdBeginClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginClip\n{\n    uint tile_ref;\n    int backdrop;\n};\n\nstruct CmdBeginSolidClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginSolidClip\n{\n    float alpha;\n};\n\nstruct CmdEndClipRef\n{\n    uint offset;\n};\n\nstruct CmdEndClip\n{\n    float alpha;\n};\n\nstruct CmdSolidRef\n{\n    uint offset;\n};\n\nstruct CmdSolid\n{\n    uint rgba_color;\n};\n\nstruct CmdSolidImageRef\n{\n    uint offset;\n};\n\nstruct CmdSolidImage\n{\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdJumpRef\n{\n    uint offset;\n};\n\nstruct CmdJump\n{\n    uint new_ref;\n};\n\nstruct CmdRef\n{\n    uint offset;\n};\n\nstruct Config\n{\n    uint n_elements;\n    uint n_pathseg;\n    uint width_in_tiles;\n    uint height_in_tiles;\n    Alloc tile_alloc;\n    Alloc bin_alloc;\n    Alloc ptcl_alloc;\n    Alloc pathseg_alloc;\n    Alloc anno_alloc;\n};\n\nlayout(binding = 0, std430) buffer Memory\n{\n    uint mem_offset;\n    uint mem_error;\n    uint memory[];\n} _307;\n\nlayout(binding = 1, std430) readonly buffer ConfigBuf\n{\n    Config conf;\n} _1178;\n\nshared uint sh_bitmaps[4][128];\nshared Alloc sh_part_elements[128];\nshared uint sh_part_count[128];\nshared uint sh_elements[128];\nshared uint sh_tile_stride[128];\nshared uint sh_tile_width[128];\nshared uint sh_tile_x0[128];\nshared uint sh_tile_y0[128];\nshared uint sh_tile_base[128];\nshared uint sh_tile_count[128];\n\nAlloc new_alloc(uint offset, uint size)\n{\n    Alloc a;\n    a.offset = offset;\n    return a;\n}\n\nAlloc slice_mem(Alloc a, uint offset, uint size)\n{\n    uint param = a.offset + offset;\n    uint param_1 = size;\n    return new_alloc(param, param_1);\n}\n\nbool touch_mem(Alloc alloc, uint offset)\n{\n    return true;\n}\n\nuint read_mem(Alloc alloc, uint offset)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return 0u;\n    }\n    uint v = _307.memory[offset];\n    return v;\n}\n\nBinInstanceRef BinInstance_index(BinInstanceRef ref, uint index)\n{\n    return BinInstanceRef(ref.offset + (index * 4u));\n}\n\nBinInstance BinInstance_read(Alloc a, BinInstanceRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    BinInstance s;\n    s.element_ix = raw0;\n    return s;\n}\n\nuint Annotated_tag(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    return read_mem(param, param_1);\n}\n\nPath Path_read(Alloc a, PathRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Path s;\n    s.bbox = uvec4(raw0 & 65535u, raw0 >> uint(16), raw1 & 65535u, raw1 >> uint(16));\n    s.tiles = TileRef(raw2);\n    return s;\n}\n\nvoid write_tile_alloc(uint el_ix, Alloc a)\n{\n}\n\nAlloc read_tile_alloc(uint el_ix)\n{\n    uint param = 0u;\n    uint param_1 = uint(int(uint(_307.memory.length())) * 4);\n    return new_alloc(param, param_1);\n}\n\nTile Tile_read(Alloc a, TileRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Tile s;\n    s.tile = TileSegRef(raw0);\n    s.backdrop = int(raw1);\n    return s;\n}\n\nAnnoFill AnnoFill_read(Alloc a, AnnoFillRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    AnnoFill s;\n    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.rgba_color = raw4;\n    return s;\n}\n\nAnnoFill Annotated_Fill_read(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    AnnoFillRef param_1 = AnnoFillRef(ref.offset + 4u);\n    return AnnoFill_read(param, param_1);\n}\n\nMallocResult malloc(uint size)\n{\n    MallocResult r;\n    r.failed = false;\n    uint _313 = atomicAdd(_307.mem_offset, size);\n    uint offset = _313;\n    uint param = offset;\n    uint param_1 = size;\n    r.alloc = new_alloc(param, param_1);\n    if ((offset + size) > uint(int(uint(_307.memory.length())) * 4))\n    {\n        r.failed = true;\n        uint _334 = atomicMax(_307.mem_error, 1u);\n        return r;\n    }\n    return r;\n}\n\nvoid write_mem(Alloc alloc, uint offset, uint val)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return;\n    }\n    _307.memory[offset] = val;\n}\n\nvoid CmdJump_write(Alloc a, CmdJumpRef ref, CmdJump s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.new_ref;\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_Jump_write(Alloc a, CmdRef ref, CmdJump s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 11u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdJumpRef param_4 = CmdJumpRef(ref.offset + 4u);\n    CmdJump param_5 = s;\n    CmdJump_write(param_3, param_4, param_5);\n}\n\nbool alloc_cmd(inout Alloc cmd_alloc, inout CmdRef cmd_ref, inout uint cmd_limit)\n{\n    if (cmd_ref.offset < cmd_limit)\n    {\n        return true;\n    }\n    uint param = 1024u;\n    MallocResult _1138 = malloc(param);\n    MallocResult new_cmd = _1138;\n    if (new_cmd.failed)\n    {\n        return false;\n    }\n    CmdJump jump = CmdJump(new_cmd.alloc.offset);\n    Alloc param_1 = cmd_alloc;\n    CmdRef param_2 = cmd_ref;\n    CmdJump param_3 = jump;\n    Cmd_Jump_write(param_1, param_2, param_3);\n    cmd_alloc = new_cmd.alloc;\n    cmd_ref = CmdRef(cmd_alloc.offset);\n    cmd_limit = (cmd_alloc.offset + 1024u) - 40u;\n    return true;\n}\n\nvoid CmdFill_write(Alloc a, CmdFillRef ref, CmdFill s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = uint(s.backdrop);\n    write_mem(param_3, param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 2u;\n    uint param_8 = s.rgba_color;\n    write_mem(param_6, param_7, param_8);\n}\n\nvoid Cmd_Fill_write(Alloc a, CmdRef ref, CmdFill s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 3u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdFillRef param_4 = CmdFillRef(ref.offset + 4u);\n    CmdFill param_5 = s;\n    CmdFill_write(param_3, param_4, param_5);\n}\n\nvoid CmdSolid_write(Alloc a, CmdSolidRef ref, CmdSolid s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.rgba_color;\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_Solid_write(Alloc a, CmdRef ref, CmdSolid s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 9u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdSolidRef param_4 = CmdSolidRef(ref.offset + 4u);\n    CmdSolid param_5 = s;\n    CmdSolid_write(param_3, param_4, param_5);\n}\n\nAnnoFillImage AnnoFillImage_read(Alloc a, AnnoFillImageRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    Alloc param_10 = a;\n    uint param_11 = ix + 5u;\n    uint raw5 = read_mem(param_10, param_11);\n    AnnoFillImage s;\n    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.index = raw4;\n    s.offset = ivec2(int(raw5 << uint(16)) >> 16, int(raw5) >> 16);\n    return s;\n}\n\nAnnoFillImage Annotated_FillImage_read(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    AnnoFillImageRef param_1 = AnnoFillImageRef(ref.offset + 4u);\n    return AnnoFillImage_read(param, param_1);\n}\n\nvoid CmdFillImage_write(Alloc a, CmdFillImageRef ref, CmdFillImage s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = uint(s.backdrop);\n    write_mem(param_3, param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 2u;\n    uint param_8 = s.index;\n    write_mem(param_6, param_7, param_8);\n    Alloc param_9 = a;\n    uint param_10 = ix + 3u;\n    uint param_11 = (uint(s.offset.x) & 65535u) | (uint(s.offset.y) << uint(16));\n    write_mem(param_9, param_10, param_11);\n}\n\nvoid Cmd_FillImage_write(Alloc a, CmdRef ref, CmdFillImage s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 4u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdFillImageRef param_4 = CmdFillImageRef(ref.offset + 4u);\n    CmdFillImage param_5 = s;\n    CmdFillImage_write(param_3, param_4, param_5);\n}\n\nvoid CmdSolidImage_write(Alloc a, CmdSolidImageRef ref, CmdSolidImage s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.index;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = (uint(s.offset.x) & 65535u) | (uint(s.offset.y) << uint(16));\n    write_mem(param_3, param_4, param_5);\n}\n\nvoid Cmd_SolidImage_write(Alloc a, CmdRef ref, CmdSolidImage s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 10u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdSolidImageRef param_4 = CmdSolidImageRef(ref.offset + 4u);\n    CmdSolidImage param_5 = s;\n    CmdSolidImage_write(param_3, param_4, param_5);\n}\n\nvoid CmdBeginClip_write(Alloc a, CmdBeginClipRef ref, CmdBeginClip s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = uint(s.backdrop);\n    write_mem(param_3, param_4, param_5);\n}\n\nvoid Cmd_BeginClip_write(Alloc a, CmdRef ref, CmdBeginClip s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 5u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdBeginClipRef param_4 = CmdBeginClipRef(ref.offset + 4u);\n    CmdBeginClip param_5 = s;\n    CmdBeginClip_write(param_3, param_4, param_5);\n}\n\nvoid CmdBeginSolidClip_write(Alloc a, CmdBeginSolidClipRef ref, CmdBeginSolidClip s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = floatBitsToUint(s.alpha);\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_BeginSolidClip_write(Alloc a, CmdRef ref, CmdBeginSolidClip s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 6u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdBeginSolidClipRef param_4 = CmdBeginSolidClipRef(ref.offset + 4u);\n    CmdBeginSolidClip param_5 = s;\n    CmdBeginSolidClip_write(param_3, param_4, param_5);\n}\n\nvoid CmdEndClip_write(Alloc a, CmdEndClipRef ref, CmdEndClip s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = floatBitsToUint(s.alpha);\n    write_mem(param, param_1, param_2);\n}\n\nvoid Cmd_EndClip_write(Alloc a, CmdRef ref, CmdEndClip s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 7u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdEndClipRef param_4 = CmdEndClipRef(ref.offset + 4u);\n    CmdEndClip param_5 = s;\n    CmdEndClip_write(param_3, param_4, param_5);\n}\n\nAnnoStroke AnnoStroke_read(Alloc a, AnnoStrokeRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    Alloc param_10 = a;\n    uint param_11 = ix + 5u;\n    uint raw5 = read_mem(param_10, param_11);\n    AnnoStroke s;\n    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.rgba_color = raw4;\n    s.linewidth = uintBitsToFloat(raw5);\n    return s;\n}\n\nAnnoStroke Annotated_Stroke_read(Alloc a, AnnotatedRef ref)\n{\n    Alloc param = a;\n    AnnoStrokeRef param_1 = AnnoStrokeRef(ref.offset + 4u);\n    return AnnoStroke_read(param, param_1);\n}\n\nvoid CmdStroke_write(Alloc a, CmdStrokeRef ref, CmdStroke s)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint param_2 = s.tile_ref;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    uint param_4 = ix + 1u;\n    uint param_5 = floatBitsToUint(s.half_width);\n    write_mem(param_3, param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 2u;\n    uint param_8 = s.rgba_color;\n    write_mem(param_6, param_7, param_8);\n}\n\nvoid Cmd_Stroke_write(Alloc a, CmdRef ref, CmdStroke s)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 8u;\n    write_mem(param, param_1, param_2);\n    Alloc param_3 = a;\n    CmdStrokeRef param_4 = CmdStrokeRef(ref.offset + 4u);\n    CmdStroke param_5 = s;\n    CmdStroke_write(param_3, param_4, param_5);\n}\n\nvoid Cmd_End_write(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    uint param_2 = 0u;\n    write_mem(param, param_1, param_2);\n}\n\nvoid main()\n{\n    if (_307.mem_error != 0u)\n    {\n        return;\n    }\n    uint width_in_bins = ((_1178.conf.width_in_tiles + 16u) - 1u) / 16u;\n    uint bin_ix = (width_in_bins * gl_WorkGroupID.y) + gl_WorkGroupID.x;\n    uint partition_ix = 0u;\n    uint n_partitions = ((_1178.conf.n_elements + 128u) - 1u) / 128u;\n    uint th_ix = gl_LocalInvocationID.x;\n    uint bin_tile_x = 16u * gl_WorkGroupID.x;\n    uint bin_tile_y = 8u * gl_WorkGroupID.y;\n    uint tile_x = gl_LocalInvocationID.x % 16u;\n    uint tile_y = gl_LocalInvocationID.x / 16u;\n    uint this_tile_ix = (((bin_tile_y + tile_y) * _1178.conf.width_in_tiles) + bin_tile_x) + tile_x;\n    Alloc param;\n    param.offset = _1178.conf.ptcl_alloc.offset;\n    uint param_1 = this_tile_ix * 1024u;\n    uint param_2 = 1024u;\n    Alloc cmd_alloc = slice_mem(param, param_1, param_2);\n    CmdRef cmd_ref = CmdRef(cmd_alloc.offset);\n    uint cmd_limit = (cmd_ref.offset + 1024u) - 40u;\n    uint clip_depth = 0u;\n    uint clip_zero_depth = 0u;\n    uint clip_one_mask = 0u;\n    uint rd_ix = 0u;\n    uint wr_ix = 0u;\n    uint part_start_ix = 0u;\n    uint ready_ix = 0u;\n    Alloc param_3;\n    Alloc param_5;\n    uint _1454;\n    uint element_ix;\n    AnnotatedRef ref;\n    Alloc param_13;\n    Alloc param_15;\n    uint tile_count;\n    Alloc param_21;\n    uint _1766;\n    bool include_tile;\n    Alloc param_26;\n    Tile tile_1;\n    Alloc param_31;\n    CmdFill cmd_fill;\n    Alloc param_45;\n    CmdFillImage cmd_fill_img;\n    CmdSolidImage cmd_solid_img;\n    CmdBeginClip cmd_begin_clip;\n    Alloc param_77;\n    CmdStroke cmd_stroke;\n    while (true)\n    {\n        for (uint i = 0u; i < 4u; i++)\n        {\n            sh_bitmaps[i][th_ix] = 0u;\n        }\n        bool _1506;\n        for (;;)\n        {\n            if ((ready_ix == wr_ix) && (partition_ix < n_partitions))\n            {\n                part_start_ix = ready_ix;\n                uint count = 0u;\n                bool _1304 = th_ix < 128u;\n                bool _1312;\n                if (_1304)\n                {\n                    _1312 = (partition_ix + th_ix) < n_partitions;\n                }\n                else\n                {\n                    _1312 = _1304;\n                }\n                if (_1312)\n                {\n                    uint in_ix = (_1178.conf.bin_alloc.offset >> uint(2)) + ((((partition_ix + th_ix) * 128u) + bin_ix) * 2u);\n                    param_3.offset = _1178.conf.bin_alloc.offset;\n                    uint param_4 = in_ix;\n                    count = read_mem(param_3, param_4);\n                    param_5.offset = _1178.conf.bin_alloc.offset;\n                    uint param_6 = in_ix + 1u;\n                    uint offset = read_mem(param_5, param_6);\n                    uint param_7 = offset;\n                    uint param_8 = count * 4u;\n                    sh_part_elements[th_ix] = new_alloc(param_7, param_8);\n                }\n                for (uint i_1 = 0u; i_1 < 7u; i_1++)\n                {\n                    if (th_ix < 128u)\n                    {\n                        sh_part_count[th_ix] = count;\n                    }\n                    barrier();\n                    if (th_ix < 128u)\n                    {\n                        if (th_ix >= uint(1 << int(i_1)))\n                        {\n                            count += sh_part_count[th_ix - uint(1 << int(i_1))];\n                        }\n                    }\n                    barrier();\n                }\n                if (th_ix < 128u)\n                {\n                    sh_part_count[th_ix] = part_start_ix + count;\n                }\n                barrier();\n                ready_ix = sh_part_count[127];\n                partition_ix += 128u;\n            }\n            uint ix = rd_ix + th_ix;\n            if ((ix >= wr_ix) && (ix < ready_ix))\n            {\n                uint part_ix = 0u;\n                for (uint i_2 = 0u; i_2 < 7u; i_2++)\n                {\n                    uint probe = part_ix + uint(64 >> int(i_2));\n                    if (ix >= sh_part_count[probe - 1u])\n                    {\n                        part_ix = probe;\n                    }\n                }\n                if (part_ix > 0u)\n                {\n                    _1454 = sh_part_count[part_ix - 1u];\n                }\n                else\n                {\n                    _1454 = part_start_ix;\n                }\n                ix -= _1454;\n                Alloc bin_alloc = sh_part_elements[part_ix];\n                BinInstanceRef inst_ref = BinInstanceRef(bin_alloc.offset);\n                BinInstanceRef param_9 = inst_ref;\n                uint param_10 = ix;\n                Alloc param_11 = bin_alloc;\n                BinInstanceRef param_12 = BinInstance_index(param_9, param_10);\n                BinInstance inst = BinInstance_read(param_11, param_12);\n                sh_elements[th_ix] = inst.element_ix;\n            }\n            barrier();\n            wr_ix = min((rd_ix + 128u), ready_ix);\n            bool _1496 = (wr_ix - rd_ix) < 128u;\n            if (_1496)\n            {\n                _1506 = (wr_ix < ready_ix) || (partition_ix < n_partitions);\n            }\n            else\n            {\n                _1506 = _1496;\n            }\n            if (_1506)\n            {\n                continue;\n            }\n            else\n            {\n                break;\n            }\n        }\n        uint tag = 0u;\n        if ((th_ix + rd_ix) < wr_ix)\n        {\n            element_ix = sh_elements[th_ix];\n            ref = AnnotatedRef(_1178.conf.anno_alloc.offset + (element_ix * 28u));\n            param_13.offset = _1178.conf.anno_alloc.offset;\n            AnnotatedRef param_14 = ref;\n            tag = Annotated_tag(param_13, param_14);\n        }\n        switch (tag)\n        {\n            case 2u:\n            case 3u:\n            case 1u:\n            case 4u:\n            case 5u:\n            {\n                uint path_ix = element_ix;\n                param_15.offset = _1178.conf.tile_alloc.offset;\n                PathRef param_16 = PathRef(_1178.conf.tile_alloc.offset + (path_ix * 12u));\n                Path path = Path_read(param_15, param_16);\n                uint stride = path.bbox.z - path.bbox.x;\n                sh_tile_stride[th_ix] = stride;\n                int dx = int(path.bbox.x) - int(bin_tile_x);\n                int dy = int(path.bbox.y) - int(bin_tile_y);\n                int x0 = clamp(dx, 0, 16);\n                int y0 = clamp(dy, 0, 8);\n                int x1 = clamp(int(path.bbox.z) - int(bin_tile_x), 0, 16);\n                int y1 = clamp(int(path.bbox.w) - int(bin_tile_y), 0, 8);\n                sh_tile_width[th_ix] = uint(x1 - x0);\n                sh_tile_x0[th_ix] = uint(x0);\n                sh_tile_y0[th_ix] = uint(y0);\n                tile_count = uint(x1 - x0) * uint(y1 - y0);\n                uint base = path.tiles.offset - (((uint(dy) * stride) + uint(dx)) * 8u);\n                sh_tile_base[th_ix] = base;\n                uint param_17 = path.tiles.offset;\n                uint param_18 = ((path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y)) * 8u;\n                Alloc path_alloc = new_alloc(param_17, param_18);\n                uint param_19 = th_ix;\n                Alloc param_20 = path_alloc;\n                write_tile_alloc(param_19, param_20);\n                break;\n            }\n            default:\n            {\n                tile_count = 0u;\n                break;\n            }\n        }\n        sh_tile_count[th_ix] = tile_count;\n        for (uint i_3 = 0u; i_3 < 7u; i_3++)\n        {\n            barrier();\n            if (th_ix >= uint(1 << int(i_3)))\n            {\n                tile_count += sh_tile_count[th_ix - uint(1 << int(i_3))];\n            }\n            barrier();\n            sh_tile_count[th_ix] = tile_count;\n        }\n        barrier();\n        uint total_tile_count = sh_tile_count[127];\n        for (uint ix_1 = th_ix; ix_1 < total_tile_count; ix_1 += 128u)\n        {\n            uint el_ix = 0u;\n            for (uint i_4 = 0u; i_4 < 7u; i_4++)\n            {\n                uint probe_1 = el_ix + uint(64 >> int(i_4));\n                if (ix_1 >= sh_tile_count[probe_1 - 1u])\n                {\n                    el_ix = probe_1;\n                }\n            }\n            AnnotatedRef ref_1 = AnnotatedRef(_1178.conf.anno_alloc.offset + (sh_elements[el_ix] * 28u));\n            param_21.offset = _1178.conf.anno_alloc.offset;\n            AnnotatedRef param_22 = ref_1;\n            uint tag_1 = Annotated_tag(param_21, param_22);\n            if (el_ix > 0u)\n            {\n                _1766 = sh_tile_count[el_ix - 1u];\n            }\n            else\n            {\n                _1766 = 0u;\n            }\n            uint seq_ix = ix_1 - _1766;\n            uint width = sh_tile_width[el_ix];\n            uint x = sh_tile_x0[el_ix] + (seq_ix % width);\n            uint y = sh_tile_y0[el_ix] + (seq_ix / width);\n            if ((tag_1 == 4u) || (tag_1 == 5u))\n            {\n                include_tile = true;\n            }\n            else\n            {\n                uint param_23 = el_ix;\n                Alloc param_24 = read_tile_alloc(param_23);\n                TileRef param_25 = TileRef(sh_tile_base[el_ix] + (((sh_tile_stride[el_ix] * y) + x) * 8u));\n                Tile tile = Tile_read(param_24, param_25);\n                bool _1827 = tile.tile.offset != 0u;\n                bool _1834;\n                if (!_1827)\n                {\n                    _1834 = tile.backdrop != 0;\n                }\n                else\n                {\n                    _1834 = _1827;\n                }\n                include_tile = _1834;\n            }\n            if (include_tile)\n            {\n                uint el_slice = el_ix / 32u;\n                uint el_mask = uint(1 << int(el_ix & 31u));\n                uint _1855 = atomicOr(sh_bitmaps[el_slice][(y * 16u) + x], el_mask);\n            }\n        }\n        barrier();\n        uint slice_ix = 0u;\n        uint bitmap = sh_bitmaps[0][th_ix];\n        while (true)\n        {\n            if (bitmap == 0u)\n            {\n                slice_ix++;\n                if (slice_ix == 4u)\n                {\n                    break;\n                }\n                bitmap = sh_bitmaps[slice_ix][th_ix];\n                if (bitmap == 0u)\n                {\n                    continue;\n                }\n            }\n            uint element_ref_ix = (slice_ix * 32u) + uint(findLSB(bitmap));\n            uint element_ix_1 = sh_elements[element_ref_ix];\n            bitmap &= (bitmap - 1u);\n            ref = AnnotatedRef(_1178.conf.anno_alloc.offset + (element_ix_1 * 28u));\n            param_26.offset = _1178.conf.anno_alloc.offset;\n            AnnotatedRef param_27 = ref;\n            tag = Annotated_tag(param_26, param_27);\n            if (clip_zero_depth == 0u)\n            {\n                switch (tag)\n                {\n                    case 2u:\n                    {\n                        uint param_28 = element_ref_ix;\n                        Alloc param_29 = read_tile_alloc(param_28);\n                        TileRef param_30 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_29, param_30);\n                        param_31.offset = _1178.conf.anno_alloc.offset;\n                        AnnotatedRef param_32 = ref;\n                        AnnoFill fill = Annotated_Fill_read(param_31, param_32);\n                        Alloc param_33 = cmd_alloc;\n                        CmdRef param_34 = cmd_ref;\n                        uint param_35 = cmd_limit;\n                        bool _1963 = alloc_cmd(param_33, param_34, param_35);\n                        cmd_alloc = param_33;\n                        cmd_ref = param_34;\n                        cmd_limit = param_35;\n                        if (!_1963)\n                        {\n                            break;\n                        }\n                        if (tile_1.tile.offset != 0u)\n                        {\n                            cmd_fill.tile_ref = tile_1.tile.offset;\n                            cmd_fill.backdrop = tile_1.backdrop;\n                            cmd_fill.rgba_color = fill.rgba_color;\n                            Alloc param_36 = cmd_alloc;\n                            CmdRef param_37 = cmd_ref;\n                            CmdFill param_38 = cmd_fill;\n                            Cmd_Fill_write(param_36, param_37, param_38);\n                        }\n                        else\n                        {\n                            Alloc param_39 = cmd_alloc;\n                            CmdRef param_40 = cmd_ref;\n                            CmdSolid param_41 = CmdSolid(fill.rgba_color);\n                            Cmd_Solid_write(param_39, param_40, param_41);\n                        }\n                        cmd_ref.offset += 20u;\n                        break;\n                    }\n                    case 3u:\n                    {\n                        uint param_42 = element_ref_ix;\n                        Alloc param_43 = read_tile_alloc(param_42);\n                        TileRef param_44 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_43, param_44);\n                        param_45.offset = _1178.conf.anno_alloc.offset;\n                        AnnotatedRef param_46 = ref;\n                        AnnoFillImage fill_img = Annotated_FillImage_read(param_45, param_46);\n                        Alloc param_47 = cmd_alloc;\n                        CmdRef param_48 = cmd_ref;\n                        uint param_49 = cmd_limit;\n                        bool _2043 = alloc_cmd(param_47, param_48, param_49);\n                        cmd_alloc = param_47;\n                        cmd_ref = param_48;\n                        cmd_limit = param_49;\n                        if (!_2043)\n                        {\n                            break;\n                        }\n                        if (tile_1.tile.offset != 0u)\n                        {\n                            cmd_fill_img.tile_ref = tile_1.tile.offset;\n                            cmd_fill_img.backdrop = tile_1.backdrop;\n                            cmd_fill_img.index = fill_img.index;\n                            cmd_fill_img.offset = fill_img.offset;\n                            Alloc param_50 = cmd_alloc;\n                            CmdRef param_51 = cmd_ref;\n                            CmdFillImage param_52 = cmd_fill_img;\n                            Cmd_FillImage_write(param_50, param_51, param_52);\n                        }\n                        else\n                        {\n                            cmd_solid_img.index = fill_img.index;\n                            cmd_solid_img.offset = fill_img.offset;\n                            Alloc param_53 = cmd_alloc;\n                            CmdRef param_54 = cmd_ref;\n                            CmdSolidImage param_55 = cmd_solid_img;\n                            Cmd_SolidImage_write(param_53, param_54, param_55);\n                        }\n                        cmd_ref.offset += 20u;\n                        break;\n                    }\n                    case 4u:\n                    {\n                        uint param_56 = element_ref_ix;\n                        Alloc param_57 = read_tile_alloc(param_56);\n                        TileRef param_58 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_57, param_58);\n                        bool _2117 = tile_1.tile.offset == 0u;\n                        bool _2123;\n                        if (_2117)\n                        {\n                            _2123 = tile_1.backdrop == 0;\n                        }\n                        else\n                        {\n                            _2123 = _2117;\n                        }\n                        if (_2123)\n                        {\n                            clip_zero_depth = clip_depth + 1u;\n                        }\n                        else\n                        {\n                            if ((tile_1.tile.offset == 0u) && (clip_depth < 32u))\n                            {\n                                clip_one_mask |= uint(1 << int(clip_depth));\n                            }\n                            else\n                            {\n                                Alloc param_59 = cmd_alloc;\n                                CmdRef param_60 = cmd_ref;\n                                uint param_61 = cmd_limit;\n                                bool _2149 = alloc_cmd(param_59, param_60, param_61);\n                                cmd_alloc = param_59;\n                                cmd_ref = param_60;\n                                cmd_limit = param_61;\n                                if (!_2149)\n                                {\n                                    break;\n                                }\n                                if (tile_1.tile.offset != 0u)\n                                {\n                                    cmd_begin_clip.tile_ref = tile_1.tile.offset;\n                                    cmd_begin_clip.backdrop = tile_1.backdrop;\n                                    Alloc param_62 = cmd_alloc;\n                                    CmdRef param_63 = cmd_ref;\n                                    CmdBeginClip param_64 = cmd_begin_clip;\n                                    Cmd_BeginClip_write(param_62, param_63, param_64);\n                                }\n                                else\n                                {\n                                    float alpha = (tile_1.backdrop == 0) ? 0.0 : 1.0;\n                                    Alloc param_65 = cmd_alloc;\n                                    CmdRef param_66 = cmd_ref;\n                                    CmdBeginSolidClip param_67 = CmdBeginSolidClip(alpha);\n                                    Cmd_BeginSolidClip_write(param_65, param_66, param_67);\n                                }\n                                cmd_ref.offset += 20u;\n                                if (clip_depth < 32u)\n                                {\n                                    clip_one_mask &= uint(~(1 << int(clip_depth)));\n                                }\n                            }\n                        }\n                        clip_depth++;\n                        break;\n                    }\n                    case 5u:\n                    {\n                        clip_depth--;\n                        bool _2212 = clip_depth >= 32u;\n                        bool _2222;\n                        if (!_2212)\n                        {\n                            _2222 = (clip_one_mask & uint(1 << int(clip_depth))) == 0u;\n                        }\n                        else\n                        {\n                            _2222 = _2212;\n                        }\n                        if (_2222)\n                        {\n                            Alloc param_68 = cmd_alloc;\n                            CmdRef param_69 = cmd_ref;\n                            uint param_70 = cmd_limit;\n                            bool _2231 = alloc_cmd(param_68, param_69, param_70);\n                            cmd_alloc = param_68;\n                            cmd_ref = param_69;\n                            cmd_limit = param_70;\n                            if (!_2231)\n                            {\n                                break;\n                            }\n                            Alloc param_71 = cmd_alloc;\n                            CmdRef param_72 = cmd_ref;\n                            CmdEndClip param_73 = CmdEndClip(1.0);\n                            Cmd_EndClip_write(param_71, param_72, param_73);\n                            cmd_ref.offset += 20u;\n                        }\n                        break;\n                    }\n                    case 1u:\n                    {\n                        uint param_74 = element_ref_ix;\n                        Alloc param_75 = read_tile_alloc(param_74);\n                        TileRef param_76 = TileRef(sh_tile_base[element_ref_ix] + (((sh_tile_stride[element_ref_ix] * tile_y) + tile_x) * 8u));\n                        tile_1 = Tile_read(param_75, param_76);\n                        param_77.offset = _1178.conf.anno_alloc.offset;\n                        AnnotatedRef param_78 = ref;\n                        AnnoStroke stroke = Annotated_Stroke_read(param_77, param_78);\n                        cmd_stroke.tile_ref = tile_1.tile.offset;\n                        cmd_stroke.half_width = 0.5 * stroke.linewidth;\n                        cmd_stroke.rgba_color = stroke.rgba_color;\n                        Alloc param_79 = cmd_alloc;\n                        CmdRef param_80 = cmd_ref;\n                        uint param_81 = cmd_limit;\n                        bool _2297 = alloc_cmd(param_79, param_80, param_81);\n                        cmd_alloc = param_79;\n                        cmd_ref = param_80;\n                        cmd_limit = param_81;\n                        if (!_2297)\n                        {\n                            break;\n                        }\n                        Alloc param_82 = cmd_alloc;\n                        CmdRef param_83 = cmd_ref;\n                        CmdStroke param_84 = cmd_stroke;\n                        Cmd_Stroke_write(param_82, param_83, param_84);\n                        cmd_ref.offset += 20u;\n                        break;\n                    }\n                }\n            }\n            else\n            {\n                switch (tag)\n                {\n                    case 4u:\n                    {\n                        clip_depth++;\n                        break;\n                    }\n                    case 5u:\n                    {\n                        if (clip_depth == clip_zero_depth)\n                        {\n                            clip_zero_depth = 0u;\n                        }\n                        clip_depth--;\n                        break;\n                    }\n                }\n            }\n        }\n        barrier();\n        rd_ix += 128u;\n        if ((rd_ix >= ready_ix) && (partition_ix >= n_partitions))\n        {\n            break;\n        }\n    }\n    bool _2352 = (bin_tile_x + tile_x) < _1178.conf.width_in_tiles;\n    bool _2361;\n    if (_2352)\n    {\n        _2361 = (bin_tile_y + tile_y) < _1178.conf.height_in_tiles;\n    }\n    else\n    {\n        _2361 = _2352;\n    }\n    if (_2361)\n    {\n        Alloc param_85 = cmd_alloc;\n        CmdRef param_86 = cmd_ref;\n        Cmd_End_write(param_85, param_86);\n    }\n}\n\n",
	}
	shader_copy_frag = backend.ShaderSources{
		Name:      "copy.frag",


@@ 732,7 732,7 @@ var (
	}
	shader_kernel4_comp = backend.ShaderSources{
		Name:      "kernel4.comp",
		GLSL310ES: "#version 310 es\nlayout(local_size_x = 32, local_size_y = 4, local_size_z = 1) in;\n\nstruct Alloc\n{\n    uint offset;\n};\n\nstruct MallocResult\n{\n    Alloc alloc;\n    bool failed;\n};\n\nstruct CmdCircleRef\n{\n    uint offset;\n};\n\nstruct CmdCircle\n{\n    vec2 center;\n    float radius;\n    uint rgba_color;\n};\n\nstruct CmdStrokeRef\n{\n    uint offset;\n};\n\nstruct CmdStroke\n{\n    uint tile_ref;\n    float half_width;\n    uint rgba_color;\n};\n\nstruct CmdFillRef\n{\n    uint offset;\n};\n\nstruct CmdFill\n{\n    uint tile_ref;\n    int backdrop;\n    uint rgba_color;\n};\n\nstruct CmdFillImageRef\n{\n    uint offset;\n};\n\nstruct CmdFillImage\n{\n    uint tile_ref;\n    int backdrop;\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdBeginClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginClip\n{\n    uint tile_ref;\n    int backdrop;\n};\n\nstruct CmdBeginSolidClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginSolidClip\n{\n    float alpha;\n};\n\nstruct CmdEndClipRef\n{\n    uint offset;\n};\n\nstruct CmdEndClip\n{\n    float alpha;\n};\n\nstruct CmdSolidRef\n{\n    uint offset;\n};\n\nstruct CmdSolid\n{\n    uint rgba_color;\n};\n\nstruct CmdSolidImageRef\n{\n    uint offset;\n};\n\nstruct CmdSolidImage\n{\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdSolidMaskRef\n{\n    uint offset;\n};\n\nstruct CmdSolidMask\n{\n    float mask;\n};\n\nstruct CmdJumpRef\n{\n    uint offset;\n};\n\nstruct CmdJump\n{\n    uint new_ref;\n};\n\nstruct CmdRef\n{\n    uint offset;\n};\n\nstruct TileSegRef\n{\n    uint offset;\n};\n\nstruct TileSeg\n{\n    vec2 origin;\n    vec2 vector;\n    float y_edge;\n    TileSegRef next;\n};\n\nstruct Config\n{\n    uint n_elements;\n    uint n_pathseg;\n    uint width_in_tiles;\n    uint height_in_tiles;\n    Alloc tile_alloc;\n    Alloc bin_alloc;\n    Alloc ptcl_alloc;\n    Alloc pathseg_alloc;\n    Alloc anno_alloc;\n};\n\nlayout(binding = 0, std430) buffer Memory\n{\n    uint mem_offset;\n    uint mem_error;\n    uint memory[];\n} _263;\n\nlayout(binding = 1, std430) readonly buffer ConfigBuf\n{\n    Config conf;\n} _1251;\n\nlayout(binding = 3, rgba8) uniform readonly highp image2D images[1];\nlayout(binding = 2, rgba8) uniform writeonly highp image2D image;\n\nshared MallocResult sh_clip_alloc;\n\nAlloc new_alloc(uint offset, uint size)\n{\n    Alloc a;\n    a.offset = offset;\n    return a;\n}\n\nAlloc slice_mem(Alloc a, uint offset, uint size)\n{\n    uint param = a.offset + offset;\n    uint param_1 = size;\n    return new_alloc(param, param_1);\n}\n\nbool touch_mem(Alloc alloc, uint offset)\n{\n    return true;\n}\n\nuint read_mem(Alloc alloc, uint offset)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return 0u;\n    }\n    uint v = _263.memory[offset];\n    return v;\n}\n\nuint Cmd_tag(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    return read_mem(param, param_1);\n}\n\nCmdCircle CmdCircle_read(Alloc a, CmdCircleRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    CmdCircle s;\n    s.center = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));\n    s.radius = uintBitsToFloat(raw2);\n    s.rgba_color = raw3;\n    return s;\n}\n\nCmdCircle Cmd_Circle_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdCircleRef param_1 = CmdCircleRef(ref.offset + 4u);\n    return CmdCircle_read(param, param_1);\n}\n\nvec3 fromsRGB(vec3 srgb)\n{\n    bvec3 cutoff = greaterThanEqual(srgb, vec3(0.040449999272823333740234375));\n    vec3 below = srgb / vec3(12.9200000762939453125);\n    vec3 above = pow((srgb + vec3(0.054999999701976776123046875)) / vec3(1.05499994754791259765625), vec3(2.400000095367431640625));\n    return mix(below, above, cutoff);\n}\n\nvec4 unpacksRGB(uint srgba)\n{\n    vec4 color = unpackUnorm4x8(srgba).wzyx;\n    vec3 param = color.xyz;\n    return vec4(fromsRGB(param), color.w);\n}\n\nCmdStroke CmdStroke_read(Alloc a, CmdStrokeRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    CmdStroke s;\n    s.tile_ref = raw0;\n    s.half_width = uintBitsToFloat(raw1);\n    s.rgba_color = raw2;\n    return s;\n}\n\nCmdStroke Cmd_Stroke_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdStrokeRef param_1 = CmdStrokeRef(ref.offset + 4u);\n    return CmdStroke_read(param, param_1);\n}\n\nTileSeg TileSeg_read(Alloc a, TileSegRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    Alloc param_10 = a;\n    uint param_11 = ix + 5u;\n    uint raw5 = read_mem(param_10, param_11);\n    TileSeg s;\n    s.origin = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));\n    s.vector = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.y_edge = uintBitsToFloat(raw4);\n    s.next = TileSegRef(raw5);\n    return s;\n}\n\nCmdFill CmdFill_read(Alloc a, CmdFillRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    CmdFill s;\n    s.tile_ref = raw0;\n    s.backdrop = int(raw1);\n    s.rgba_color = raw2;\n    return s;\n}\n\nCmdFill Cmd_Fill_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdFillRef param_1 = CmdFillRef(ref.offset + 4u);\n    return CmdFill_read(param, param_1);\n}\n\nfloat[8] computeArea(vec2 xy, int backdrop, uint tile_ref)\n{\n    float area[8];\n    for (uint k = 0u; k < 8u; k++)\n    {\n        area[k] = float(backdrop);\n    }\n    TileSegRef tile_seg_ref = TileSegRef(tile_ref);\n    do\n    {\n        uint param = tile_seg_ref.offset;\n        uint param_1 = 24u;\n        Alloc param_2 = new_alloc(param, param_1);\n        TileSegRef param_3 = tile_seg_ref;\n        TileSeg seg = TileSeg_read(param_2, param_3);\n        for (uint k_1 = 0u; k_1 < 8u; k_1++)\n        {\n            vec2 my_xy = vec2(xy.x, xy.y + float(k_1 * 4u));\n            vec2 start = seg.origin - my_xy;\n            vec2 end = start + seg.vector;\n            vec2 window = clamp(vec2(start.y, end.y), vec2(0.0), vec2(1.0));\n            if (!(window.x == window.y))\n            {\n                vec2 t = (window - vec2(start.y)) / vec2(seg.vector.y);\n                vec2 xs = vec2(mix(start.x, end.x, t.x), mix(start.x, end.x, t.y));\n                float xmin = min(min(xs.x, xs.y), 1.0) - 9.9999999747524270787835121154785e-07;\n                float xmax = max(xs.x, xs.y);\n                float b = min(xmax, 1.0);\n                float c = max(b, 0.0);\n                float d = max(xmin, 0.0);\n                float a = ((b + (0.5 * ((d * d) - (c * c)))) - xmin) / (xmax - xmin);\n                area[k_1] += (a * (window.x - window.y));\n            }\n            area[k_1] += (sign(seg.vector.x) * clamp((my_xy.y - seg.y_edge) + 1.0, 0.0, 1.0));\n        }\n        tile_seg_ref = seg.next;\n    } while (tile_seg_ref.offset != 0u);\n    for (uint k_2 = 0u; k_2 < 8u; k_2++)\n    {\n        area[k_2] = min(abs(area[k_2]), 1.0);\n    }\n    return area;\n}\n\nCmdFillImage CmdFillImage_read(Alloc a, CmdFillImageRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    CmdFillImage s;\n    s.tile_ref = raw0;\n    s.backdrop = int(raw1);\n    s.index = raw2;\n    s.offset = ivec2(int(raw3 << uint(16)) >> 16, int(raw3) >> 16);\n    return s;\n}\n\nCmdFillImage Cmd_FillImage_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdFillImageRef param_1 = CmdFillImageRef(ref.offset + 4u);\n    return CmdFillImage_read(param, param_1);\n}\n\nvec4[8] fillImage(uvec2 xy, CmdSolidImage cmd_img)\n{\n    vec4 rgba[8];\n    for (uint i = 0u; i < 8u; i++)\n    {\n        ivec2 uv = ivec2(int(xy.x), int(xy.y + (i * 4u))) + cmd_img.offset;\n        vec4 fg_rgba = imageLoad(images[0], uv);\n        vec3 param = fg_rgba.xyz;\n        vec3 _1224 = fromsRGB(param);\n        fg_rgba = vec4(_1224.x, _1224.y, _1224.z, fg_rgba.w);\n        rgba[i] = fg_rgba;\n    }\n    return rgba;\n}\n\nMallocResult malloc(uint size)\n{\n    MallocResult r;\n    r.failed = false;\n    uint _269 = atomicAdd(_263.mem_offset, size);\n    uint offset = _269;\n    uint param = offset;\n    uint param_1 = size;\n    r.alloc = new_alloc(param, param_1);\n    if ((offset + size) > uint(int(uint(_263.memory.length())) * 4))\n    {\n        r.failed = true;\n        uint _290 = atomicMax(_263.mem_error, 1u);\n        return r;\n    }\n    return r;\n}\n\nvoid write_mem(Alloc alloc, uint offset, uint val)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return;\n    }\n    _263.memory[offset] = val;\n}\n\nMallocResult alloc_clip_buf(uint link)\n{\n    bool _868 = gl_LocalInvocationID.x == 0u;\n    bool _874;\n    if (_868)\n    {\n        _874 = gl_LocalInvocationID.y == 0u;\n    }\n    else\n    {\n        _874 = _868;\n    }\n    if (_874)\n    {\n        uint param = 4100u;\n        MallocResult _880 = malloc(param);\n        MallocResult m = _880;\n        if (!m.failed)\n        {\n            Alloc param_1 = m.alloc;\n            uint param_2 = (m.alloc.offset >> uint(2)) + 1024u;\n            uint param_3 = link;\n            write_mem(param_1, param_2, param_3);\n        }\n        sh_clip_alloc = m;\n    }\n    barrier();\n    return sh_clip_alloc;\n}\n\nCmdBeginClip CmdBeginClip_read(Alloc a, CmdBeginClipRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    CmdBeginClip s;\n    s.tile_ref = raw0;\n    s.backdrop = int(raw1);\n    return s;\n}\n\nCmdBeginClip Cmd_BeginClip_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdBeginClipRef param_1 = CmdBeginClipRef(ref.offset + 4u);\n    return CmdBeginClip_read(param, param_1);\n}\n\nvec3 tosRGB(vec3 rgb)\n{\n    bvec3 cutoff = greaterThanEqual(rgb, vec3(0.003130800090730190277099609375));\n    vec3 below = vec3(12.9200000762939453125) * rgb;\n    vec3 above = (vec3(1.05499994754791259765625) * pow(rgb, vec3(0.416660010814666748046875))) - vec3(0.054999999701976776123046875);\n    return mix(below, above, cutoff);\n}\n\nuint packsRGB(inout vec4 rgba)\n{\n    vec3 param = rgba.xyz;\n    rgba = vec4(tosRGB(param), rgba.w);\n    return packUnorm4x8(rgba.wzyx);\n}\n\nCmdBeginSolidClip CmdBeginSolidClip_read(Alloc a, CmdBeginSolidClipRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdBeginSolidClip s;\n    s.alpha = uintBitsToFloat(raw0);\n    return s;\n}\n\nCmdBeginSolidClip Cmd_BeginSolidClip_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdBeginSolidClipRef param_1 = CmdBeginSolidClipRef(ref.offset + 4u);\n    return CmdBeginSolidClip_read(param, param_1);\n}\n\nCmdEndClip CmdEndClip_read(Alloc a, CmdEndClipRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdEndClip s;\n    s.alpha = uintBitsToFloat(raw0);\n    return s;\n}\n\nCmdEndClip Cmd_EndClip_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdEndClipRef param_1 = CmdEndClipRef(ref.offset + 4u);\n    return CmdEndClip_read(param, param_1);\n}\n\nCmdSolid CmdSolid_read(Alloc a, CmdSolidRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdSolid s;\n    s.rgba_color = raw0;\n    return s;\n}\n\nCmdSolid Cmd_Solid_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdSolidRef param_1 = CmdSolidRef(ref.offset + 4u);\n    return CmdSolid_read(param, param_1);\n}\n\nCmdSolidImage CmdSolidImage_read(Alloc a, CmdSolidImageRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    CmdSolidImage s;\n    s.index = raw0;\n    s.offset = ivec2(int(raw1 << uint(16)) >> 16, int(raw1) >> 16);\n    return s;\n}\n\nCmdSolidImage Cmd_SolidImage_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdSolidImageRef param_1 = CmdSolidImageRef(ref.offset + 4u);\n    return CmdSolidImage_read(param, param_1);\n}\n\nCmdSolidMask CmdSolidMask_read(Alloc a, CmdSolidMaskRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdSolidMask s;\n    s.mask = uintBitsToFloat(raw0);\n    return s;\n}\n\nCmdSolidMask Cmd_SolidMask_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdSolidMaskRef param_1 = CmdSolidMaskRef(ref.offset + 4u);\n    return CmdSolidMask_read(param, param_1);\n}\n\nCmdJump CmdJump_read(Alloc a, CmdJumpRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdJump s;\n    s.new_ref = raw0;\n    return s;\n}\n\nCmdJump Cmd_Jump_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdJumpRef param_1 = CmdJumpRef(ref.offset + 4u);\n    return CmdJump_read(param, param_1);\n}\n\nvoid main()\n{\n    if (_263.mem_error != 0u)\n    {\n        return;\n    }\n    uint tile_ix = (gl_WorkGroupID.y * _1251.conf.width_in_tiles) + gl_WorkGroupID.x;\n    Alloc param;\n    param.offset = _1251.conf.ptcl_alloc.offset;\n    uint param_1 = tile_ix * 1024u;\n    uint param_2 = 1024u;\n    Alloc cmd_alloc = slice_mem(param, param_1, param_2);\n    CmdRef cmd_ref = CmdRef(cmd_alloc.offset);\n    uvec2 xy_uint = uvec2(gl_GlobalInvocationID.x, gl_LocalInvocationID.y + (32u * gl_WorkGroupID.y));\n    vec2 xy = vec2(xy_uint);\n    uint blend_spill = 0u;\n    uint blend_sp = 0u;\n    uint param_3 = 0u;\n    uint param_4 = 0u;\n    Alloc clip_tos = new_alloc(param_3, param_4);\n    vec3 rgb[8];\n    float mask[8];\n    for (uint i = 0u; i < 8u; i++)\n    {\n        rgb[i] = vec3(0.5);\n        mask[i] = 1.0;\n    }\n    vec4 fg_rgba;\n    float df[8];\n    float area[8];\n    vec4 rgba[8];\n    uint blend_slot;\n    uint blend_stack[4][8];\n    while (true)\n    {\n        Alloc param_5 = cmd_alloc;\n        CmdRef param_6 = cmd_ref;\n        uint tag = Cmd_tag(param_5, param_6);\n        if (tag == 0u)\n        {\n            break;\n        }\n        switch (tag)\n        {\n            case 1u:\n            {\n                Alloc param_7 = cmd_alloc;\n                CmdRef param_8 = cmd_ref;\n                CmdCircle circle = Cmd_Circle_read(param_7, param_8);\n                uint param_9 = circle.rgba_color;\n                fg_rgba = unpacksRGB(param_9);\n                for (uint i_1 = 0u; i_1 < 8u; i_1++)\n                {\n                    float dy = float(i_1 * 4u);\n                    float r = length((vec2(xy.x, xy.y + dy) + vec2(0.5)) - circle.center);\n                    float alpha = clamp((0.5 + circle.radius) - r, 0.0, 1.0);\n                    rgb[i_1] = mix(rgb[i_1], fg_rgba.xyz, vec3((mask[i_1] * alpha) * fg_rgba.w));\n                }\n                break;\n            }\n            case 8u:\n            {\n                Alloc param_10 = cmd_alloc;\n                CmdRef param_11 = cmd_ref;\n                CmdStroke stroke = Cmd_Stroke_read(param_10, param_11);\n                for (uint k = 0u; k < 8u; k++)\n                {\n                    df[k] = 1000000000.0;\n                }\n                TileSegRef tile_seg_ref = TileSegRef(stroke.tile_ref);\n                do\n                {\n                    uint param_12 = tile_seg_ref.offset;\n                    uint param_13 = 24u;\n                    Alloc param_14 = new_alloc(param_12, param_13);\n                    TileSegRef param_15 = tile_seg_ref;\n                    TileSeg seg = TileSeg_read(param_14, param_15);\n                    vec2 line_vec = seg.vector;\n                    for (uint k_1 = 0u; k_1 < 8u; k_1++)\n                    {\n                        vec2 dpos = (xy + vec2(0.5)) - seg.origin;\n                        dpos.y += float(k_1 * 4u);\n                        float t = clamp(dot(line_vec, dpos) / dot(line_vec, line_vec), 0.0, 1.0);\n                        df[k_1] = min(df[k_1], length((line_vec * t) - dpos));\n                    }\n                    tile_seg_ref = seg.next;\n                } while (tile_seg_ref.offset != 0u);\n                uint param_16 = stroke.rgba_color;\n                fg_rgba = unpacksRGB(param_16);\n                for (uint k_2 = 0u; k_2 < 8u; k_2++)\n                {\n                    float alpha_1 = clamp((stroke.half_width + 0.5) - df[k_2], 0.0, 1.0);\n                    rgb[k_2] = mix(rgb[k_2], fg_rgba.xyz, vec3((mask[k_2] * alpha_1) * fg_rgba.w));\n                }\n                break;\n            }\n            case 3u:\n            {\n                Alloc param_17 = cmd_alloc;\n                CmdRef param_18 = cmd_ref;\n                CmdFill fill = Cmd_Fill_read(param_17, param_18);\n                vec2 param_19 = xy;\n                int param_20 = fill.backdrop;\n                uint param_21 = fill.tile_ref;\n                area = computeArea(param_19, param_20, param_21);\n                uint param_22 = fill.rgba_color;\n                fg_rgba = unpacksRGB(param_22);\n                for (uint k_3 = 0u; k_3 < 8u; k_3++)\n                {\n                    rgb[k_3] = mix(rgb[k_3], fg_rgba.xyz, vec3((mask[k_3] * area[k_3]) * fg_rgba.w));\n                }\n                break;\n            }\n            case 4u:\n            {\n                Alloc param_23 = cmd_alloc;\n                CmdRef param_24 = cmd_ref;\n                CmdFillImage fill_img = Cmd_FillImage_read(param_23, param_24);\n                vec2 param_25 = xy;\n                int param_26 = fill_img.backdrop;\n                uint param_27 = fill_img.tile_ref;\n                area = computeArea(param_25, param_26, param_27);\n                uvec2 param_28 = xy_uint;\n                CmdSolidImage param_29 = CmdSolidImage(fill_img.index, fill_img.offset);\n                rgba = fillImage(param_28, param_29);\n                for (uint k_4 = 0u; k_4 < 8u; k_4++)\n                {\n                    rgb[k_4] = mix(rgb[k_4], rgba[k_4].xyz, vec3((mask[k_4] * area[k_4]) * rgba[k_4].w));\n                }\n                break;\n            }\n            case 5u:\n            case 6u:\n            {\n                blend_slot = blend_sp % 4u;\n                if (blend_sp == (blend_spill + 4u))\n                {\n                    uint param_30 = clip_tos.offset;\n                    MallocResult _1659 = alloc_clip_buf(param_30);\n                    MallocResult m = _1659;\n                    if (m.failed)\n                    {\n                        return;\n                    }\n                    clip_tos = m.alloc;\n                    uint base_ix = ((clip_tos.offset >> uint(2)) + gl_LocalInvocationID.x) + (32u * gl_LocalInvocationID.y);\n                    for (uint k_5 = 0u; k_5 < 8u; k_5++)\n                    {\n                        Alloc param_31 = clip_tos;\n                        uint param_32 = base_ix + ((k_5 * 32u) * 4u);\n                        uint param_33 = blend_stack[blend_slot][k_5];\n                        write_mem(param_31, param_32, param_33);\n                    }\n                    blend_spill++;\n                }\n                if (tag == 5u)\n                {\n                    Alloc param_34 = cmd_alloc;\n                    CmdRef param_35 = cmd_ref;\n                    CmdBeginClip begin_clip = Cmd_BeginClip_read(param_34, param_35);\n                    vec2 param_36 = xy;\n                    int param_37 = begin_clip.backdrop;\n                    uint param_38 = begin_clip.tile_ref;\n                    area = computeArea(param_36, param_37, param_38);\n                    for (uint k_6 = 0u; k_6 < 8u; k_6++)\n                    {\n                        vec4 param_39 = vec4(rgb[k_6], clamp(abs(area[k_6]), 0.0, 1.0));\n                        uint _1750 = packsRGB(param_39);\n                        blend_stack[blend_slot][k_6] = _1750;\n                    }\n                }\n                else\n                {\n                    Alloc param_40 = cmd_alloc;\n                    CmdRef param_41 = cmd_ref;\n                    CmdBeginSolidClip begin_solid_clip = Cmd_BeginSolidClip_read(param_40, param_41);\n                    float solid_alpha = begin_solid_clip.alpha;\n                    for (uint k_7 = 0u; k_7 < 8u; k_7++)\n                    {\n                        vec4 param_42 = vec4(rgb[k_7], solid_alpha);\n                        uint _1783 = packsRGB(param_42);\n                        blend_stack[blend_slot][k_7] = _1783;\n                    }\n                }\n                blend_sp++;\n                break;\n            }\n            case 7u:\n            {\n                Alloc param_43 = cmd_alloc;\n                CmdRef param_44 = cmd_ref;\n                CmdEndClip end_clip = Cmd_EndClip_read(param_43, param_44);\n                blend_slot = (blend_sp - 1u) % 4u;\n                if (blend_sp == blend_spill)\n                {\n                    uint base_ix_1 = ((clip_tos.offset >> uint(2)) + gl_LocalInvocationID.x) + (32u * gl_LocalInvocationID.y);\n                    for (uint k_8 = 0u; k_8 < 8u; k_8++)\n                    {\n                        Alloc param_45 = clip_tos;\n                        uint param_46 = base_ix_1 + ((k_8 * 32u) * 4u);\n                        blend_stack[blend_slot][k_8] = read_mem(param_45, param_46);\n                    }\n                    Alloc param_47 = clip_tos;\n                    uint param_48 = (clip_tos.offset >> uint(2)) + 1024u;\n                    clip_tos.offset = read_mem(param_47, param_48);\n                    blend_spill--;\n                }\n                blend_sp--;\n                for (uint k_9 = 0u; k_9 < 8u; k_9++)\n                {\n                    uint param_49 = blend_stack[blend_slot][k_9];\n                    vec4 rgba_1 = unpacksRGB(param_49);\n                    rgb[k_9] = mix(rgba_1.xyz, rgb[k_9], vec3(end_clip.alpha * rgba_1.w));\n                }\n                break;\n            }\n            case 9u:\n            {\n                Alloc param_50 = cmd_alloc;\n                CmdRef param_51 = cmd_ref;\n                CmdSolid solid = Cmd_Solid_read(param_50, param_51);\n                uint param_52 = solid.rgba_color;\n                fg_rgba = unpacksRGB(param_52);\n                for (uint k_10 = 0u; k_10 < 8u; k_10++)\n                {\n                    rgb[k_10] = mix(rgb[k_10], fg_rgba.xyz, vec3(mask[k_10] * fg_rgba.w));\n                }\n                break;\n            }\n            case 11u:\n            {\n                Alloc param_53 = cmd_alloc;\n                CmdRef param_54 = cmd_ref;\n                CmdSolidImage solid_img = Cmd_SolidImage_read(param_53, param_54);\n                uvec2 param_55 = xy_uint;\n                CmdSolidImage param_56 = solid_img;\n                rgba = fillImage(param_55, param_56);\n                for (uint k_11 = 0u; k_11 < 8u; k_11++)\n                {\n                    rgb[k_11] = mix(rgb[k_11], rgba[k_11].xyz, vec3(mask[k_11] * rgba[k_11].w));\n                }\n                break;\n            }\n            case 10u:\n            {\n                Alloc param_57 = cmd_alloc;\n                CmdRef param_58 = cmd_ref;\n                CmdSolidMask solid_mask = Cmd_SolidMask_read(param_57, param_58);\n                for (uint k_12 = 0u; k_12 < 8u; k_12++)\n                {\n                    mask[k_12] = solid_mask.mask;\n                }\n                break;\n            }\n            case 12u:\n            {\n                Alloc param_59 = cmd_alloc;\n                CmdRef param_60 = cmd_ref;\n                cmd_ref = CmdRef(Cmd_Jump_read(param_59, param_60).new_ref);\n                cmd_alloc.offset = cmd_ref.offset;\n                continue;\n            }\n        }\n        cmd_ref.offset += 20u;\n    }\n    for (uint i_2 = 0u; i_2 < 8u; i_2++)\n    {\n        vec3 param_61 = rgb[i_2];\n        imageStore(image, ivec2(int(xy_uint.x), int(xy_uint.y + (4u * i_2))), vec4(tosRGB(param_61), 1.0));\n    }\n}\n\n",
		GLSL310ES: "#version 310 es\nlayout(local_size_x = 32, local_size_y = 4, local_size_z = 1) in;\n\nstruct Alloc\n{\n    uint offset;\n};\n\nstruct MallocResult\n{\n    Alloc alloc;\n    bool failed;\n};\n\nstruct CmdCircleRef\n{\n    uint offset;\n};\n\nstruct CmdCircle\n{\n    vec2 center;\n    float radius;\n    uint rgba_color;\n};\n\nstruct CmdStrokeRef\n{\n    uint offset;\n};\n\nstruct CmdStroke\n{\n    uint tile_ref;\n    float half_width;\n    uint rgba_color;\n};\n\nstruct CmdFillRef\n{\n    uint offset;\n};\n\nstruct CmdFill\n{\n    uint tile_ref;\n    int backdrop;\n    uint rgba_color;\n};\n\nstruct CmdFillImageRef\n{\n    uint offset;\n};\n\nstruct CmdFillImage\n{\n    uint tile_ref;\n    int backdrop;\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdBeginClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginClip\n{\n    uint tile_ref;\n    int backdrop;\n};\n\nstruct CmdBeginSolidClipRef\n{\n    uint offset;\n};\n\nstruct CmdBeginSolidClip\n{\n    float alpha;\n};\n\nstruct CmdEndClipRef\n{\n    uint offset;\n};\n\nstruct CmdEndClip\n{\n    float alpha;\n};\n\nstruct CmdSolidRef\n{\n    uint offset;\n};\n\nstruct CmdSolid\n{\n    uint rgba_color;\n};\n\nstruct CmdSolidImageRef\n{\n    uint offset;\n};\n\nstruct CmdSolidImage\n{\n    uint index;\n    ivec2 offset;\n};\n\nstruct CmdJumpRef\n{\n    uint offset;\n};\n\nstruct CmdJump\n{\n    uint new_ref;\n};\n\nstruct CmdRef\n{\n    uint offset;\n};\n\nstruct TileSegRef\n{\n    uint offset;\n};\n\nstruct TileSeg\n{\n    vec2 origin;\n    vec2 vector;\n    float y_edge;\n    TileSegRef next;\n};\n\nstruct Config\n{\n    uint n_elements;\n    uint n_pathseg;\n    uint width_in_tiles;\n    uint height_in_tiles;\n    Alloc tile_alloc;\n    Alloc bin_alloc;\n    Alloc ptcl_alloc;\n    Alloc pathseg_alloc;\n    Alloc anno_alloc;\n};\n\nlayout(binding = 0, std430) buffer Memory\n{\n    uint mem_offset;\n    uint mem_error;\n    uint memory[];\n} _250;\n\nlayout(binding = 1, std430) readonly buffer ConfigBuf\n{\n    Config conf;\n} _1209;\n\nlayout(binding = 3, rgba8) uniform readonly highp image2D images[1];\nlayout(binding = 2, rgba8) uniform writeonly highp image2D image;\n\nshared MallocResult sh_clip_alloc;\n\nAlloc new_alloc(uint offset, uint size)\n{\n    Alloc a;\n    a.offset = offset;\n    return a;\n}\n\nAlloc slice_mem(Alloc a, uint offset, uint size)\n{\n    uint param = a.offset + offset;\n    uint param_1 = size;\n    return new_alloc(param, param_1);\n}\n\nbool touch_mem(Alloc alloc, uint offset)\n{\n    return true;\n}\n\nuint read_mem(Alloc alloc, uint offset)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return 0u;\n    }\n    uint v = _250.memory[offset];\n    return v;\n}\n\nuint Cmd_tag(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    uint param_1 = ref.offset >> uint(2);\n    return read_mem(param, param_1);\n}\n\nCmdCircle CmdCircle_read(Alloc a, CmdCircleRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    CmdCircle s;\n    s.center = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));\n    s.radius = uintBitsToFloat(raw2);\n    s.rgba_color = raw3;\n    return s;\n}\n\nCmdCircle Cmd_Circle_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdCircleRef param_1 = CmdCircleRef(ref.offset + 4u);\n    return CmdCircle_read(param, param_1);\n}\n\nvec3 fromsRGB(vec3 srgb)\n{\n    bvec3 cutoff = greaterThanEqual(srgb, vec3(0.040449999272823333740234375));\n    vec3 below = srgb / vec3(12.9200000762939453125);\n    vec3 above = pow((srgb + vec3(0.054999999701976776123046875)) / vec3(1.05499994754791259765625), vec3(2.400000095367431640625));\n    return mix(below, above, cutoff);\n}\n\nvec4 unpacksRGB(uint srgba)\n{\n    vec4 color = unpackUnorm4x8(srgba).wzyx;\n    vec3 param = color.xyz;\n    return vec4(fromsRGB(param), color.w);\n}\n\nCmdStroke CmdStroke_read(Alloc a, CmdStrokeRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    CmdStroke s;\n    s.tile_ref = raw0;\n    s.half_width = uintBitsToFloat(raw1);\n    s.rgba_color = raw2;\n    return s;\n}\n\nCmdStroke Cmd_Stroke_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdStrokeRef param_1 = CmdStrokeRef(ref.offset + 4u);\n    return CmdStroke_read(param, param_1);\n}\n\nTileSeg TileSeg_read(Alloc a, TileSegRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    Alloc param_8 = a;\n    uint param_9 = ix + 4u;\n    uint raw4 = read_mem(param_8, param_9);\n    Alloc param_10 = a;\n    uint param_11 = ix + 5u;\n    uint raw5 = read_mem(param_10, param_11);\n    TileSeg s;\n    s.origin = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));\n    s.vector = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));\n    s.y_edge = uintBitsToFloat(raw4);\n    s.next = TileSegRef(raw5);\n    return s;\n}\n\nCmdFill CmdFill_read(Alloc a, CmdFillRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    CmdFill s;\n    s.tile_ref = raw0;\n    s.backdrop = int(raw1);\n    s.rgba_color = raw2;\n    return s;\n}\n\nCmdFill Cmd_Fill_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdFillRef param_1 = CmdFillRef(ref.offset + 4u);\n    return CmdFill_read(param, param_1);\n}\n\nfloat[8] computeArea(vec2 xy, int backdrop, uint tile_ref)\n{\n    float area[8];\n    for (uint k = 0u; k < 8u; k++)\n    {\n        area[k] = float(backdrop);\n    }\n    TileSegRef tile_seg_ref = TileSegRef(tile_ref);\n    do\n    {\n        uint param = tile_seg_ref.offset;\n        uint param_1 = 24u;\n        Alloc param_2 = new_alloc(param, param_1);\n        TileSegRef param_3 = tile_seg_ref;\n        TileSeg seg = TileSeg_read(param_2, param_3);\n        for (uint k_1 = 0u; k_1 < 8u; k_1++)\n        {\n            vec2 my_xy = vec2(xy.x, xy.y + float(k_1 * 4u));\n            vec2 start = seg.origin - my_xy;\n            vec2 end = start + seg.vector;\n            vec2 window = clamp(vec2(start.y, end.y), vec2(0.0), vec2(1.0));\n            if (!(window.x == window.y))\n            {\n                vec2 t = (window - vec2(start.y)) / vec2(seg.vector.y);\n                vec2 xs = vec2(mix(start.x, end.x, t.x), mix(start.x, end.x, t.y));\n                float xmin = min(min(xs.x, xs.y), 1.0) - 9.9999999747524270787835121154785e-07;\n                float xmax = max(xs.x, xs.y);\n                float b = min(xmax, 1.0);\n                float c = max(b, 0.0);\n                float d = max(xmin, 0.0);\n                float a = ((b + (0.5 * ((d * d) - (c * c)))) - xmin) / (xmax - xmin);\n                area[k_1] += (a * (window.x - window.y));\n            }\n            area[k_1] += (sign(seg.vector.x) * clamp((my_xy.y - seg.y_edge) + 1.0, 0.0, 1.0));\n        }\n        tile_seg_ref = seg.next;\n    } while (tile_seg_ref.offset != 0u);\n    for (uint k_2 = 0u; k_2 < 8u; k_2++)\n    {\n        area[k_2] = min(abs(area[k_2]), 1.0);\n    }\n    return area;\n}\n\nCmdFillImage CmdFillImage_read(Alloc a, CmdFillImageRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    Alloc param_4 = a;\n    uint param_5 = ix + 2u;\n    uint raw2 = read_mem(param_4, param_5);\n    Alloc param_6 = a;\n    uint param_7 = ix + 3u;\n    uint raw3 = read_mem(param_6, param_7);\n    CmdFillImage s;\n    s.tile_ref = raw0;\n    s.backdrop = int(raw1);\n    s.index = raw2;\n    s.offset = ivec2(int(raw3 << uint(16)) >> 16, int(raw3) >> 16);\n    return s;\n}\n\nCmdFillImage Cmd_FillImage_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdFillImageRef param_1 = CmdFillImageRef(ref.offset + 4u);\n    return CmdFillImage_read(param, param_1);\n}\n\nvec4[8] fillImage(uvec2 xy, CmdSolidImage cmd_img)\n{\n    vec4 rgba[8];\n    for (uint i = 0u; i < 8u; i++)\n    {\n        ivec2 uv = ivec2(int(xy.x), int(xy.y + (i * 4u))) + cmd_img.offset;\n        vec4 fg_rgba = imageLoad(images[0], uv);\n        vec3 param = fg_rgba.xyz;\n        vec3 _1182 = fromsRGB(param);\n        fg_rgba = vec4(_1182.x, _1182.y, _1182.z, fg_rgba.w);\n        rgba[i] = fg_rgba;\n    }\n    return rgba;\n}\n\nMallocResult malloc(uint size)\n{\n    MallocResult r;\n    r.failed = false;\n    uint _256 = atomicAdd(_250.mem_offset, size);\n    uint offset = _256;\n    uint param = offset;\n    uint param_1 = size;\n    r.alloc = new_alloc(param, param_1);\n    if ((offset + size) > uint(int(uint(_250.memory.length())) * 4))\n    {\n        r.failed = true;\n        uint _277 = atomicMax(_250.mem_error, 1u);\n        return r;\n    }\n    return r;\n}\n\nvoid write_mem(Alloc alloc, uint offset, uint val)\n{\n    Alloc param = alloc;\n    uint param_1 = offset;\n    if (!touch_mem(param, param_1))\n    {\n        return;\n    }\n    _250.memory[offset] = val;\n}\n\nMallocResult alloc_clip_buf(uint link)\n{\n    bool _826 = gl_LocalInvocationID.x == 0u;\n    bool _832;\n    if (_826)\n    {\n        _832 = gl_LocalInvocationID.y == 0u;\n    }\n    else\n    {\n        _832 = _826;\n    }\n    if (_832)\n    {\n        uint param = 4100u;\n        MallocResult _838 = malloc(param);\n        MallocResult m = _838;\n        if (!m.failed)\n        {\n            Alloc param_1 = m.alloc;\n            uint param_2 = (m.alloc.offset >> uint(2)) + 1024u;\n            uint param_3 = link;\n            write_mem(param_1, param_2, param_3);\n        }\n        sh_clip_alloc = m;\n    }\n    barrier();\n    return sh_clip_alloc;\n}\n\nCmdBeginClip CmdBeginClip_read(Alloc a, CmdBeginClipRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    CmdBeginClip s;\n    s.tile_ref = raw0;\n    s.backdrop = int(raw1);\n    return s;\n}\n\nCmdBeginClip Cmd_BeginClip_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdBeginClipRef param_1 = CmdBeginClipRef(ref.offset + 4u);\n    return CmdBeginClip_read(param, param_1);\n}\n\nvec3 tosRGB(vec3 rgb)\n{\n    bvec3 cutoff = greaterThanEqual(rgb, vec3(0.003130800090730190277099609375));\n    vec3 below = vec3(12.9200000762939453125) * rgb;\n    vec3 above = (vec3(1.05499994754791259765625) * pow(rgb, vec3(0.416660010814666748046875))) - vec3(0.054999999701976776123046875);\n    return mix(below, above, cutoff);\n}\n\nuint packsRGB(inout vec4 rgba)\n{\n    vec3 param = rgba.xyz;\n    rgba = vec4(tosRGB(param), rgba.w);\n    return packUnorm4x8(rgba.wzyx);\n}\n\nCmdBeginSolidClip CmdBeginSolidClip_read(Alloc a, CmdBeginSolidClipRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdBeginSolidClip s;\n    s.alpha = uintBitsToFloat(raw0);\n    return s;\n}\n\nCmdBeginSolidClip Cmd_BeginSolidClip_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdBeginSolidClipRef param_1 = CmdBeginSolidClipRef(ref.offset + 4u);\n    return CmdBeginSolidClip_read(param, param_1);\n}\n\nCmdEndClip CmdEndClip_read(Alloc a, CmdEndClipRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdEndClip s;\n    s.alpha = uintBitsToFloat(raw0);\n    return s;\n}\n\nCmdEndClip Cmd_EndClip_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdEndClipRef param_1 = CmdEndClipRef(ref.offset + 4u);\n    return CmdEndClip_read(param, param_1);\n}\n\nCmdSolid CmdSolid_read(Alloc a, CmdSolidRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdSolid s;\n    s.rgba_color = raw0;\n    return s;\n}\n\nCmdSolid Cmd_Solid_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdSolidRef param_1 = CmdSolidRef(ref.offset + 4u);\n    return CmdSolid_read(param, param_1);\n}\n\nCmdSolidImage CmdSolidImage_read(Alloc a, CmdSolidImageRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    Alloc param_2 = a;\n    uint param_3 = ix + 1u;\n    uint raw1 = read_mem(param_2, param_3);\n    CmdSolidImage s;\n    s.index = raw0;\n    s.offset = ivec2(int(raw1 << uint(16)) >> 16, int(raw1) >> 16);\n    return s;\n}\n\nCmdSolidImage Cmd_SolidImage_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdSolidImageRef param_1 = CmdSolidImageRef(ref.offset + 4u);\n    return CmdSolidImage_read(param, param_1);\n}\n\nCmdJump CmdJump_read(Alloc a, CmdJumpRef ref)\n{\n    uint ix = ref.offset >> uint(2);\n    Alloc param = a;\n    uint param_1 = ix + 0u;\n    uint raw0 = read_mem(param, param_1);\n    CmdJump s;\n    s.new_ref = raw0;\n    return s;\n}\n\nCmdJump Cmd_Jump_read(Alloc a, CmdRef ref)\n{\n    Alloc param = a;\n    CmdJumpRef param_1 = CmdJumpRef(ref.offset + 4u);\n    return CmdJump_read(param, param_1);\n}\n\nvoid main()\n{\n    if (_250.mem_error != 0u)\n    {\n        return;\n    }\n    uint tile_ix = (gl_WorkGroupID.y * _1209.conf.width_in_tiles) + gl_WorkGroupID.x;\n    Alloc param;\n    param.offset = _1209.conf.ptcl_alloc.offset;\n    uint param_1 = tile_ix * 1024u;\n    uint param_2 = 1024u;\n    Alloc cmd_alloc = slice_mem(param, param_1, param_2);\n    CmdRef cmd_ref = CmdRef(cmd_alloc.offset);\n    uvec2 xy_uint = uvec2(gl_GlobalInvocationID.x, gl_LocalInvocationID.y + (32u * gl_WorkGroupID.y));\n    vec2 xy = vec2(xy_uint);\n    uint blend_spill = 0u;\n    uint blend_sp = 0u;\n    uint param_3 = 0u;\n    uint param_4 = 0u;\n    Alloc clip_tos = new_alloc(param_3, param_4);\n    vec3 rgb[8];\n    float mask[8];\n    for (uint i = 0u; i < 8u; i++)\n    {\n        rgb[i] = vec3(0.5);\n        mask[i] = 1.0;\n    }\n    vec4 fg_rgba;\n    float df[8];\n    float area[8];\n    vec4 rgba[8];\n    uint blend_slot;\n    uint blend_stack[4][8];\n    while (true)\n    {\n        Alloc param_5 = cmd_alloc;\n        CmdRef param_6 = cmd_ref;\n        uint tag = Cmd_tag(param_5, param_6);\n        if (tag == 0u)\n        {\n            break;\n        }\n        switch (tag)\n        {\n            case 1u:\n            {\n                Alloc param_7 = cmd_alloc;\n                CmdRef param_8 = cmd_ref;\n                CmdCircle circle = Cmd_Circle_read(param_7, param_8);\n                uint param_9 = circle.rgba_color;\n                fg_rgba = unpacksRGB(param_9);\n                for (uint i_1 = 0u; i_1 < 8u; i_1++)\n                {\n                    float dy = float(i_1 * 4u);\n                    float r = length((vec2(xy.x, xy.y + dy) + vec2(0.5)) - circle.center);\n                    float alpha = clamp((0.5 + circle.radius) - r, 0.0, 1.0);\n                    rgb[i_1] = mix(rgb[i_1], fg_rgba.xyz, vec3((mask[i_1] * alpha) * fg_rgba.w));\n                }\n                break;\n            }\n            case 8u:\n            {\n                Alloc param_10 = cmd_alloc;\n                CmdRef param_11 = cmd_ref;\n                CmdStroke stroke = Cmd_Stroke_read(param_10, param_11);\n                for (uint k = 0u; k < 8u; k++)\n                {\n                    df[k] = 1000000000.0;\n                }\n                TileSegRef tile_seg_ref = TileSegRef(stroke.tile_ref);\n                do\n                {\n                    uint param_12 = tile_seg_ref.offset;\n                    uint param_13 = 24u;\n                    Alloc param_14 = new_alloc(param_12, param_13);\n                    TileSegRef param_15 = tile_seg_ref;\n                    TileSeg seg = TileSeg_read(param_14, param_15);\n                    vec2 line_vec = seg.vector;\n                    for (uint k_1 = 0u; k_1 < 8u; k_1++)\n                    {\n                        vec2 dpos = (xy + vec2(0.5)) - seg.origin;\n                        dpos.y += float(k_1 * 4u);\n                        float t = clamp(dot(line_vec, dpos) / dot(line_vec, line_vec), 0.0, 1.0);\n                        df[k_1] = min(df[k_1], length((line_vec * t) - dpos));\n                    }\n                    tile_seg_ref = seg.next;\n                } while (tile_seg_ref.offset != 0u);\n                uint param_16 = stroke.rgba_color;\n                fg_rgba = unpacksRGB(param_16);\n                for (uint k_2 = 0u; k_2 < 8u; k_2++)\n                {\n                    float alpha_1 = clamp((stroke.half_width + 0.5) - df[k_2], 0.0, 1.0);\n                    rgb[k_2] = mix(rgb[k_2], fg_rgba.xyz, vec3((mask[k_2] * alpha_1) * fg_rgba.w));\n                }\n                break;\n            }\n            case 3u:\n            {\n                Alloc param_17 = cmd_alloc;\n                CmdRef param_18 = cmd_ref;\n                CmdFill fill = Cmd_Fill_read(param_17, param_18);\n                vec2 param_19 = xy;\n                int param_20 = fill.backdrop;\n                uint param_21 = fill.tile_ref;\n                area = computeArea(param_19, param_20, param_21);\n                uint param_22 = fill.rgba_color;\n                fg_rgba = unpacksRGB(param_22);\n                for (uint k_3 = 0u; k_3 < 8u; k_3++)\n                {\n                    rgb[k_3] = mix(rgb[k_3], fg_rgba.xyz, vec3((mask[k_3] * area[k_3]) * fg_rgba.w));\n                }\n                break;\n            }\n            case 4u:\n            {\n                Alloc param_23 = cmd_alloc;\n                CmdRef param_24 = cmd_ref;\n                CmdFillImage fill_img = Cmd_FillImage_read(param_23, param_24);\n                vec2 param_25 = xy;\n                int param_26 = fill_img.backdrop;\n                uint param_27 = fill_img.tile_ref;\n                area = computeArea(param_25, param_26, param_27);\n                uvec2 param_28 = xy_uint;\n                CmdSolidImage param_29 = CmdSolidImage(fill_img.index, fill_img.offset);\n                rgba = fillImage(param_28, param_29);\n                for (uint k_4 = 0u; k_4 < 8u; k_4++)\n                {\n                    rgb[k_4] = mix(rgb[k_4], rgba[k_4].xyz, vec3((mask[k_4] * area[k_4]) * rgba[k_4].w));\n                }\n                break;\n            }\n            case 5u:\n            case 6u:\n            {\n                blend_slot = blend_sp % 4u;\n                if (blend_sp == (blend_spill + 4u))\n                {\n                    uint param_30 = clip_tos.offset;\n                    MallocResult _1616 = alloc_clip_buf(param_30);\n                    MallocResult m = _1616;\n                    if (m.failed)\n                    {\n                        return;\n                    }\n                    clip_tos = m.alloc;\n                    uint base_ix = ((clip_tos.offset >> uint(2)) + gl_LocalInvocationID.x) + (32u * gl_LocalInvocationID.y);\n                    for (uint k_5 = 0u; k_5 < 8u; k_5++)\n                    {\n                        Alloc param_31 = clip_tos;\n                        uint param_32 = base_ix + ((k_5 * 32u) * 4u);\n                        uint param_33 = blend_stack[blend_slot][k_5];\n                        write_mem(param_31, param_32, param_33);\n                    }\n                    blend_spill++;\n                }\n                if (tag == 5u)\n                {\n                    Alloc param_34 = cmd_alloc;\n                    CmdRef param_35 = cmd_ref;\n                    CmdBeginClip begin_clip = Cmd_BeginClip_read(param_34, param_35);\n                    vec2 param_36 = xy;\n                    int param_37 = begin_clip.backdrop;\n                    uint param_38 = begin_clip.tile_ref;\n                    area = computeArea(param_36, param_37, param_38);\n                    for (uint k_6 = 0u; k_6 < 8u; k_6++)\n                    {\n                        vec4 param_39 = vec4(rgb[k_6], clamp(abs(area[k_6]), 0.0, 1.0));\n                        uint _1707 = packsRGB(param_39);\n                        blend_stack[blend_slot][k_6] = _1707;\n                    }\n                }\n                else\n                {\n                    Alloc param_40 = cmd_alloc;\n                    CmdRef param_41 = cmd_ref;\n                    CmdBeginSolidClip begin_solid_clip = Cmd_BeginSolidClip_read(param_40, param_41);\n                    float solid_alpha = begin_solid_clip.alpha;\n                    for (uint k_7 = 0u; k_7 < 8u; k_7++)\n                    {\n                        vec4 param_42 = vec4(rgb[k_7], solid_alpha);\n                        uint _1740 = packsRGB(param_42);\n                        blend_stack[blend_slot][k_7] = _1740;\n                    }\n                }\n                blend_sp++;\n                break;\n            }\n            case 7u:\n            {\n                Alloc param_43 = cmd_alloc;\n                CmdRef param_44 = cmd_ref;\n                CmdEndClip end_clip = Cmd_EndClip_read(param_43, param_44);\n                blend_slot = (blend_sp - 1u) % 4u;\n                if (blend_sp == blend_spill)\n                {\n                    uint base_ix_1 = ((clip_tos.offset >> uint(2)) + gl_LocalInvocationID.x) + (32u * gl_LocalInvocationID.y);\n                    for (uint k_8 = 0u; k_8 < 8u; k_8++)\n                    {\n                        Alloc param_45 = clip_tos;\n                        uint param_46 = base_ix_1 + ((k_8 * 32u) * 4u);\n                        blend_stack[blend_slot][k_8] = read_mem(param_45, param_46);\n                    }\n                    Alloc param_47 = clip_tos;\n                    uint param_48 = (clip_tos.offset >> uint(2)) + 1024u;\n                    clip_tos.offset = read_mem(param_47, param_48);\n                    blend_spill--;\n                }\n                blend_sp--;\n                for (uint k_9 = 0u; k_9 < 8u; k_9++)\n                {\n                    uint param_49 = blend_stack[blend_slot][k_9];\n                    vec4 rgba_1 = unpacksRGB(param_49);\n                    rgb[k_9] = mix(rgba_1.xyz, rgb[k_9], vec3(end_clip.alpha * rgba_1.w));\n                }\n                break;\n            }\n            case 9u:\n            {\n                Alloc param_50 = cmd_alloc;\n                CmdRef param_51 = cmd_ref;\n                CmdSolid solid = Cmd_Solid_read(param_50, param_51);\n                uint param_52 = solid.rgba_color;\n                fg_rgba = unpacksRGB(param_52);\n                for (uint k_10 = 0u; k_10 < 8u; k_10++)\n                {\n                    rgb[k_10] = mix(rgb[k_10], fg_rgba.xyz, vec3(mask[k_10] * fg_rgba.w));\n                }\n                break;\n            }\n            case 10u:\n            {\n                Alloc param_53 = cmd_alloc;\n                CmdRef param_54 = cmd_ref;\n                CmdSolidImage solid_img = Cmd_SolidImage_read(param_53, param_54);\n                uvec2 param_55 = xy_uint;\n                CmdSolidImage param_56 = solid_img;\n                rgba = fillImage(param_55, param_56);\n                for (uint k_11 = 0u; k_11 < 8u; k_11++)\n                {\n                    rgb[k_11] = mix(rgb[k_11], rgba[k_11].xyz, vec3(mask[k_11] * rgba[k_11].w));\n                }\n                break;\n            }\n            case 11u:\n            {\n                Alloc param_57 = cmd_alloc;\n                CmdRef param_58 = cmd_ref;\n                cmd_ref = CmdRef(Cmd_Jump_read(param_57, param_58).new_ref);\n                cmd_alloc.offset = cmd_ref.offset;\n                continue;\n            }\n        }\n        cmd_ref.offset += 20u;\n    }\n    for (uint i_2 = 0u; i_2 < 8u; i_2++)\n    {\n        vec3 param_59 = rgb[i_2];\n        imageStore(image, ivec2(int(xy_uint.x), int(xy_uint.y + (4u * i_2))), vec4(tosRGB(param_59), 1.0));\n    }\n}\n\n",
	}
	shader_material_frag = backend.ShaderSources{
		Name:      "material.frag",

M gpu/shaders/kernel4.comp => gpu/shaders/kernel4.comp +0 -6
@@ 278,12 278,6 @@ void main() {
                rgb[k] = mix(rgb[k], rgba[k].rgb, mask[k] * rgba[k].a);
            }
            break;
        case Cmd_SolidMask:
            CmdSolidMask solid_mask = Cmd_SolidMask_read(cmd_alloc, cmd_ref);
            for (uint k = 0; k < CHUNK; k++) {
                mask[k] = solid_mask.mask;
            }
            break;
        case Cmd_Jump:
            cmd_ref = CmdRef(Cmd_Jump_read(cmd_alloc, cmd_ref).new_ref);
            cmd_alloc.offset = cmd_ref.offset;

M gpu/shaders/ptcl.h => gpu/shaders/ptcl.h +2 -39
@@ 42,10 42,6 @@ struct CmdSolidImageRef {
    uint offset;
};

struct CmdSolidMaskRef {
    uint offset;
};

struct CmdJumpRef {
    uint offset;
};


@@ 166,16 162,6 @@ CmdSolidImageRef CmdSolidImage_index(CmdSolidImageRef ref, uint index) {
    return CmdSolidImageRef(ref.offset + index * CmdSolidImage_size);
}

struct CmdSolidMask {
    float mask;
};

#define CmdSolidMask_size 4

CmdSolidMaskRef CmdSolidMask_index(CmdSolidMaskRef ref, uint index) {
    return CmdSolidMaskRef(ref.offset + index * CmdSolidMask_size);
}

struct CmdJump {
    uint new_ref;
};


@@ 196,9 182,8 @@ CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) {
#define Cmd_EndClip 7
#define Cmd_Stroke 8
#define Cmd_Solid 9
#define Cmd_SolidMask 10
#define Cmd_SolidImage 11
#define Cmd_Jump 12
#define Cmd_SolidImage 10
#define Cmd_Jump 11
#define Cmd_size 20

CmdRef Cmd_index(CmdRef ref, uint index) {


@@ 377,19 362,6 @@ void CmdSolidImage_write(Alloc a, CmdSolidImageRef ref, CmdSolidImage s) {
    write_mem(a, ix + 1, (uint(s.offset.x) & 0xffff) | (uint(s.offset.y) << 16));
}

CmdSolidMask CmdSolidMask_read(Alloc a, CmdSolidMaskRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = read_mem(a, ix + 0);
    CmdSolidMask s;
    s.mask = uintBitsToFloat(raw0);
    return s;
}

void CmdSolidMask_write(Alloc a, CmdSolidMaskRef ref, CmdSolidMask s) {
    uint ix = ref.offset >> 2;
    write_mem(a, ix + 0, floatBitsToUint(s.mask));
}

CmdJump CmdJump_read(Alloc a, CmdJumpRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = read_mem(a, ix + 0);


@@ 443,10 415,6 @@ CmdSolid Cmd_Solid_read(Alloc a, CmdRef ref) {
    return CmdSolid_read(a, CmdSolidRef(ref.offset + 4));
}

CmdSolidMask Cmd_SolidMask_read(Alloc a, CmdRef ref) {
    return CmdSolidMask_read(a, CmdSolidMaskRef(ref.offset + 4));
}

CmdSolidImage Cmd_SolidImage_read(Alloc a, CmdRef ref) {
    return CmdSolidImage_read(a, CmdSolidImageRef(ref.offset + 4));
}


@@ 504,11 472,6 @@ void Cmd_Solid_write(Alloc a, CmdRef ref, CmdSolid s) {
    CmdSolid_write(a, CmdSolidRef(ref.offset + 4), s);
}

void Cmd_SolidMask_write(Alloc a, CmdRef ref, CmdSolidMask s) {
    write_mem(a, ref.offset >> 2, Cmd_SolidMask);
    CmdSolidMask_write(a, CmdSolidMaskRef(ref.offset + 4), s);
}

void Cmd_SolidImage_write(Alloc a, CmdRef ref, CmdSolidImage s) {
    write_mem(a, ref.offset >> 2, Cmd_SolidImage);
    CmdSolidImage_write(a, CmdSolidImageRef(ref.offset + 4), s);