mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
coarse,binning: organize bins into width_in_bins x height_in_bins
The binning shader supports up to N_TILE bins. To efficiently cover wide or tall viewports, convert the rigid N_TILE_X x N_TILE_Y bin layout to a variable width_in_bins x height_in_bins layout. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
parent
ef4ec772ad
commit
716517cc04
|
@ -78,16 +78,18 @@ void main() {
|
||||||
// trying to keep divergence low.
|
// trying to keep divergence low.
|
||||||
// Right now, it's just a bbox, but we'll get finer with
|
// Right now, it's just a bbox, but we'll get finer with
|
||||||
// segments.
|
// segments.
|
||||||
x0 = clamp(x0, 0, N_TILE_X);
|
uint width_in_bins = (conf.width_in_tiles + N_TILE_X - 1)/N_TILE_X;
|
||||||
x1 = clamp(x1, x0, N_TILE_X);
|
uint height_in_bins = (conf.height_in_tiles + N_TILE_Y - 1)/N_TILE_Y;
|
||||||
y0 = clamp(y0, 0, N_TILE_Y);
|
x0 = clamp(x0, 0, int(width_in_bins));
|
||||||
y1 = clamp(y1, y0, N_TILE_Y);
|
x1 = clamp(x1, x0, int(width_in_bins));
|
||||||
|
y0 = clamp(y0, 0, int(height_in_bins));
|
||||||
|
y1 = clamp(y1, y0, int(height_in_bins));
|
||||||
if (x0 == x1) y1 = y0;
|
if (x0 == x1) y1 = y0;
|
||||||
int x = x0, y = y0;
|
int x = x0, y = y0;
|
||||||
uint my_slice = gl_LocalInvocationID.x / 32;
|
uint my_slice = gl_LocalInvocationID.x / 32;
|
||||||
uint my_mask = 1 << (gl_LocalInvocationID.x & 31);
|
uint my_mask = 1 << (gl_LocalInvocationID.x & 31);
|
||||||
while (y < y1) {
|
while (y < y1) {
|
||||||
atomicOr(bitmaps[my_slice][y * N_TILE_X + x], my_mask);
|
atomicOr(bitmaps[my_slice][y * width_in_bins + x], my_mask);
|
||||||
x++;
|
x++;
|
||||||
if (x == x1) {
|
if (x == x1) {
|
||||||
x = x0;
|
x = x0;
|
||||||
|
@ -128,7 +130,7 @@ void main() {
|
||||||
x = x0;
|
x = x0;
|
||||||
y = y0;
|
y = y0;
|
||||||
while (y < y1) {
|
while (y < y1) {
|
||||||
uint bin_ix = y * N_TILE_X + x;
|
uint bin_ix = y * width_in_bins + x;
|
||||||
uint out_mask = bitmaps[my_slice][bin_ix];
|
uint out_mask = bitmaps[my_slice][bin_ix];
|
||||||
if ((out_mask & my_mask) != 0) {
|
if ((out_mask & my_mask) != 0) {
|
||||||
uint idx = bitCount(out_mask & (my_mask - 1));
|
uint idx = bitCount(out_mask & (my_mask - 1));
|
||||||
|
|
Binary file not shown.
|
@ -71,7 +71,8 @@ void main() {
|
||||||
|
|
||||||
// Could use either linear or 2d layouts for both dispatch and
|
// Could use either linear or 2d layouts for both dispatch and
|
||||||
// invocations within the workgroup. We'll use variables to abstract.
|
// invocations within the workgroup. We'll use variables to abstract.
|
||||||
uint bin_ix = N_TILE_X * gl_WorkGroupID.y + gl_WorkGroupID.x;
|
uint width_in_bins = (conf.width_in_tiles + N_TILE_X - 1)/N_TILE_X;
|
||||||
|
uint bin_ix = width_in_bins * gl_WorkGroupID.y + gl_WorkGroupID.x;
|
||||||
uint partition_ix = 0;
|
uint partition_ix = 0;
|
||||||
uint n_partitions = (conf.n_elements + N_TILE - 1) / N_TILE;
|
uint n_partitions = (conf.n_elements + N_TILE - 1) / N_TILE;
|
||||||
uint th_ix = gl_LocalInvocationID.x;
|
uint th_ix = gl_LocalInvocationID.x;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue