2022-07-14 05:27:07 +10:00
|
|
|
struct Alloc
|
|
|
|
{
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PathRef
|
|
|
|
{
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TileRef
|
|
|
|
{
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Path
|
|
|
|
{
|
|
|
|
uint4 bbox;
|
|
|
|
TileRef tiles;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Config
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
uint mem_size;
|
2022-07-14 05:27:07 +10:00
|
|
|
uint n_elements;
|
|
|
|
uint n_pathseg;
|
|
|
|
uint width_in_tiles;
|
|
|
|
uint height_in_tiles;
|
|
|
|
Alloc tile_alloc;
|
|
|
|
Alloc bin_alloc;
|
|
|
|
Alloc ptcl_alloc;
|
|
|
|
Alloc pathseg_alloc;
|
|
|
|
Alloc anno_alloc;
|
|
|
|
Alloc trans_alloc;
|
|
|
|
Alloc path_bbox_alloc;
|
|
|
|
Alloc drawmonoid_alloc;
|
|
|
|
Alloc clip_alloc;
|
|
|
|
Alloc clip_bic_alloc;
|
|
|
|
Alloc clip_stack_alloc;
|
|
|
|
Alloc clip_bbox_alloc;
|
|
|
|
Alloc draw_bbox_alloc;
|
|
|
|
Alloc drawinfo_alloc;
|
|
|
|
uint n_trans;
|
|
|
|
uint n_path;
|
|
|
|
uint n_clip;
|
|
|
|
uint trans_offset;
|
|
|
|
uint linewidth_offset;
|
|
|
|
uint pathtag_offset;
|
|
|
|
uint pathseg_offset;
|
|
|
|
uint drawtag_offset;
|
|
|
|
uint drawdata_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const uint3 gl_WorkGroupSize = uint3(256u, 1u, 1u);
|
|
|
|
|
2022-07-15 00:28:45 +10:00
|
|
|
RWByteAddressBuffer _59 : register(u0, space0);
|
|
|
|
ByteAddressBuffer _181 : register(t1, space0);
|
2022-07-14 05:27:07 +10:00
|
|
|
|
|
|
|
static uint3 gl_LocalInvocationID;
|
|
|
|
static uint3 gl_GlobalInvocationID;
|
|
|
|
static uint gl_LocalInvocationIndex;
|
|
|
|
struct SPIRV_Cross_Input
|
|
|
|
{
|
|
|
|
uint3 gl_LocalInvocationID : SV_GroupThreadID;
|
|
|
|
uint3 gl_GlobalInvocationID : SV_DispatchThreadID;
|
|
|
|
uint gl_LocalInvocationIndex : SV_GroupIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
groupshared uint sh_row_width[256];
|
|
|
|
groupshared Alloc sh_row_alloc[256];
|
|
|
|
groupshared uint sh_row_count[256];
|
|
|
|
|
2022-07-15 00:28:45 +10:00
|
|
|
bool check_deps(uint dep_stage)
|
|
|
|
{
|
|
|
|
uint _65;
|
|
|
|
_59.InterlockedOr(4, 0u, _65);
|
|
|
|
return (_65 & dep_stage) == 0u;
|
|
|
|
}
|
|
|
|
|
2022-07-14 05:27:07 +10:00
|
|
|
bool touch_mem(Alloc alloc, uint offset)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint read_mem(Alloc alloc, uint offset)
|
|
|
|
{
|
|
|
|
Alloc param = alloc;
|
|
|
|
uint param_1 = offset;
|
|
|
|
if (!touch_mem(param, param_1))
|
|
|
|
{
|
|
|
|
return 0u;
|
|
|
|
}
|
2022-07-15 00:28:45 +10:00
|
|
|
uint v = _59.Load(offset * 4 + 12);
|
2022-07-14 05:27:07 +10:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
Path Path_read(Alloc a, PathRef ref)
|
|
|
|
{
|
|
|
|
uint ix = ref.offset >> uint(2);
|
|
|
|
Alloc param = a;
|
|
|
|
uint param_1 = ix + 0u;
|
|
|
|
uint raw0 = read_mem(param, param_1);
|
|
|
|
Alloc param_2 = a;
|
|
|
|
uint param_3 = ix + 1u;
|
|
|
|
uint raw1 = read_mem(param_2, param_3);
|
|
|
|
Alloc param_4 = a;
|
|
|
|
uint param_5 = ix + 2u;
|
|
|
|
uint raw2 = read_mem(param_4, param_5);
|
|
|
|
Path s;
|
|
|
|
s.bbox = uint4(raw0 & 65535u, raw0 >> uint(16), raw1 & 65535u, raw1 >> uint(16));
|
2022-07-15 00:28:45 +10:00
|
|
|
TileRef _146 = { raw2 };
|
|
|
|
s.tiles = _146;
|
2022-07-14 05:27:07 +10:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
Alloc new_alloc(uint offset, uint size, bool mem_ok)
|
|
|
|
{
|
|
|
|
Alloc a;
|
|
|
|
a.offset = offset;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void write_mem(Alloc alloc, uint offset, uint val)
|
|
|
|
{
|
|
|
|
Alloc param = alloc;
|
|
|
|
uint param_1 = offset;
|
|
|
|
if (!touch_mem(param, param_1))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-07-15 00:28:45 +10:00
|
|
|
_59.Store(offset * 4 + 12, val);
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void comp_main()
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
uint param = 7u;
|
|
|
|
bool _154 = check_deps(param);
|
|
|
|
if (!_154)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-07-14 05:27:07 +10:00
|
|
|
uint th_ix = gl_LocalInvocationIndex;
|
|
|
|
uint element_ix = gl_GlobalInvocationID.x;
|
|
|
|
uint row_count = 0u;
|
|
|
|
if (gl_LocalInvocationID.y == 0u)
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
if (element_ix < _181.Load(4))
|
2022-07-14 05:27:07 +10:00
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
PathRef _195 = { _181.Load(20) + (element_ix * 12u) };
|
|
|
|
PathRef path_ref = _195;
|
|
|
|
Alloc _200;
|
|
|
|
_200.offset = _181.Load(20);
|
|
|
|
Alloc param_1;
|
|
|
|
param_1.offset = _200.offset;
|
|
|
|
PathRef param_2 = path_ref;
|
|
|
|
Path path = Path_read(param_1, param_2);
|
2022-07-14 05:27:07 +10:00
|
|
|
sh_row_width[th_ix] = path.bbox.z - path.bbox.x;
|
|
|
|
row_count = path.bbox.w - path.bbox.y;
|
2022-07-15 00:28:45 +10:00
|
|
|
bool _225 = row_count == 1u;
|
|
|
|
bool _231;
|
|
|
|
if (_225)
|
2022-07-14 05:27:07 +10:00
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
_231 = path.bbox.y > 0u;
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
_231 = _225;
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
2022-07-15 00:28:45 +10:00
|
|
|
if (_231)
|
2022-07-14 05:27:07 +10:00
|
|
|
{
|
|
|
|
row_count = 0u;
|
|
|
|
}
|
2022-07-15 00:28:45 +10:00
|
|
|
uint param_3 = path.tiles.offset;
|
|
|
|
uint param_4 = ((path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y)) * 8u;
|
|
|
|
bool param_5 = true;
|
|
|
|
Alloc path_alloc = new_alloc(param_3, param_4, param_5);
|
2022-07-14 05:27:07 +10:00
|
|
|
sh_row_alloc[th_ix] = path_alloc;
|
|
|
|
}
|
|
|
|
sh_row_count[th_ix] = row_count;
|
|
|
|
}
|
|
|
|
for (uint i = 0u; i < 8u; i++)
|
|
|
|
{
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
2022-07-15 00:28:45 +10:00
|
|
|
bool _276 = gl_LocalInvocationID.y == 0u;
|
|
|
|
bool _283;
|
|
|
|
if (_276)
|
2022-07-14 05:27:07 +10:00
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
_283 = th_ix >= (1u << i);
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
_283 = _276;
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
2022-07-15 00:28:45 +10:00
|
|
|
if (_283)
|
2022-07-14 05:27:07 +10:00
|
|
|
{
|
|
|
|
row_count += sh_row_count[th_ix - (1u << i)];
|
|
|
|
}
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
|
|
|
if (gl_LocalInvocationID.y == 0u)
|
|
|
|
{
|
|
|
|
sh_row_count[th_ix] = row_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
|
|
|
uint total_rows = sh_row_count[255];
|
2022-07-15 00:28:45 +10:00
|
|
|
uint _360;
|
2022-07-14 05:27:07 +10:00
|
|
|
for (uint row = th_ix; row < total_rows; row += 256u)
|
|
|
|
{
|
|
|
|
uint el_ix = 0u;
|
|
|
|
for (uint i_1 = 0u; i_1 < 8u; i_1++)
|
|
|
|
{
|
|
|
|
uint probe = el_ix + (128u >> i_1);
|
|
|
|
if (row >= sh_row_count[probe - 1u])
|
|
|
|
{
|
|
|
|
el_ix = probe;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint width = sh_row_width[el_ix];
|
2022-07-15 00:28:45 +10:00
|
|
|
if (width > 0u)
|
2022-07-14 05:27:07 +10:00
|
|
|
{
|
|
|
|
Alloc tiles_alloc = sh_row_alloc[el_ix];
|
|
|
|
if (el_ix > 0u)
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
_360 = sh_row_count[el_ix - 1u];
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 00:28:45 +10:00
|
|
|
_360 = 0u;
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
2022-07-15 00:28:45 +10:00
|
|
|
uint seq_ix = row - _360;
|
2022-07-14 05:27:07 +10:00
|
|
|
uint tile_el_ix = ((tiles_alloc.offset >> uint(2)) + 1u) + ((seq_ix * 2u) * width);
|
2022-07-15 00:28:45 +10:00
|
|
|
Alloc param_6 = tiles_alloc;
|
|
|
|
uint param_7 = tile_el_ix;
|
|
|
|
uint sum = read_mem(param_6, param_7);
|
2022-07-14 05:27:07 +10:00
|
|
|
for (uint x = 1u; x < width; x++)
|
|
|
|
{
|
|
|
|
tile_el_ix += 2u;
|
2022-07-15 00:28:45 +10:00
|
|
|
Alloc param_8 = tiles_alloc;
|
|
|
|
uint param_9 = tile_el_ix;
|
|
|
|
sum += read_mem(param_8, param_9);
|
|
|
|
Alloc param_10 = tiles_alloc;
|
|
|
|
uint param_11 = tile_el_ix;
|
|
|
|
uint param_12 = sum;
|
|
|
|
write_mem(param_10, param_11, param_12);
|
2022-07-14 05:27:07 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[numthreads(256, 1, 1)]
|
|
|
|
void main(SPIRV_Cross_Input stage_input)
|
|
|
|
{
|
|
|
|
gl_LocalInvocationID = stage_input.gl_LocalInvocationID;
|
|
|
|
gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID;
|
|
|
|
gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex;
|
|
|
|
comp_main();
|
|
|
|
}
|