From c67696714b519f3c74957978caf0be72462ea2ac Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 18 Dec 2020 00:29:25 +0100 Subject: [PATCH] coarse.comp: don't write Cmd_End to tiles out of bounds If WIDTH_IN_TILES or HEIGHT_IN_TILES are not divisible by N_TILE_X or N_TILE_Y respectively, the previously unconditional Cmd_End_write would write out of bounds. Signed-off-by: Elias Naur --- piet-gpu/shader/coarse.comp | 4 +++- piet-gpu/shader/coarse.spv | Bin 39376 -> 39668 bytes piet-gpu/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/piet-gpu/shader/coarse.comp b/piet-gpu/shader/coarse.comp index a70318a..f835c2b 100644 --- a/piet-gpu/shader/coarse.comp +++ b/piet-gpu/shader/coarse.comp @@ -370,5 +370,7 @@ void main() { rd_ix += N_TILE; if (rd_ix >= ready_ix && partition_ix >= n_partitions) break; } - Cmd_End_write(cmd_ref); + if (bin_tile_x + tile_x < WIDTH_IN_TILES && bin_tile_y + tile_y < HEIGHT_IN_TILES) { + Cmd_End_write(cmd_ref); + } } diff --git a/piet-gpu/shader/coarse.spv b/piet-gpu/shader/coarse.spv index 260db69611077342550fa9a7e16b49fd67f0cc46..e0d89e5607670266959fadf3d08093111a327ae2 100644 GIT binary patch delta 401 zcmYk1y)Hyi6ouD4!=1?_Q;UgCf&>qsKqC>o|KB^q)q8@GXh^gkz#EVgl|rFVl86V; zs)?V0=((Y>pt zHL%YY9{yY9n)^_waPnSpk8^7RX zy$A4M9by{Hnu2T2gBAJg&(_B%b|IfAo}s7P&NjJt3Vk$24;p3ARENDWME|g3NeHM**!oyWb@i0cMSj- CZ56Tr diff --git a/piet-gpu/src/lib.rs b/piet-gpu/src/lib.rs index 0272664..c1ab974 100644 --- a/piet-gpu/src/lib.rs +++ b/piet-gpu/src/lib.rs @@ -404,7 +404,7 @@ impl Renderer { cmd_buf.dispatch( &self.coarse_pipeline, &self.coarse_ds, - (WIDTH as u32 / 256, HEIGHT as u32 / 256, 1), + ((WIDTH as u32 + 255) / 256, (HEIGHT as u32 + 255) / 256, 1), ); cmd_buf.write_timestamp(&query_pool, 6); cmd_buf.memory_barrier();