Address review comments Set resolution in params for test scene. Add comments explaining division of work.
diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index 2e36a39..e03792a 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs
@@ -1523,11 +1523,12 @@ ] } -fn many_draw_objects(scene: &mut Scene, _: &mut SceneParams) { +fn many_draw_objects(scene: &mut Scene, params: &mut SceneParams) { const N_WIDE: usize = 300; const N_HIGH: usize = 300; const SCENE_WIDTH: f64 = 2000.0; const SCENE_HEIGHT: f64 = 1500.0; + params.resolution = Some((SCENE_WIDTH, SCENE_HEIGHT).into()); for j in 0..N_HIGH { let y = (j as f64 + 0.5) * (SCENE_HEIGHT / N_HIGH as f64); for i in 0..N_WIDE {
diff --git a/shader/draw_leaf.wgsl b/shader/draw_leaf.wgsl index e512661..e041a51 100644 --- a/shader/draw_leaf.wgsl +++ b/shader/draw_leaf.wgsl
@@ -74,7 +74,8 @@ workgroupBarrier(); var prefix = sh_scratch[0]; - let num_blocks_total = (config.n_drawobj + (WG_SIZE - 1u)) / WG_SIZE; + // This is the same division of work as draw_reduce. + let num_blocks_total = (config.n_drawobj + WG_SIZE - 1u) / WG_SIZE; let n_blocks_base = num_blocks_total / WG_SIZE; let remainder = num_blocks_total % WG_SIZE; let first_block = n_blocks_base * wg_id.x + min(wg_id.x, remainder);
diff --git a/shader/draw_reduce.wgsl b/shader/draw_reduce.wgsl index 4a7fb6d..7a12b81 100644 --- a/shader/draw_reduce.wgsl +++ b/shader/draw_reduce.wgsl
@@ -25,6 +25,9 @@ @builtin(workgroup_id) wg_id: vec3<u32>, ) { let num_blocks_total = (config.n_drawobj + (WG_SIZE - 1u)) / WG_SIZE; + // When the number of blocks exceeds the workgroup size, divide + // the work evenly so each workgroup handles n_blocks / wg, with + // the low workgroups doing one more each to handle the remainder. let n_blocks_base = num_blocks_total / WG_SIZE; let remainder = num_blocks_total % WG_SIZE; let first_block = n_blocks_base * wg_id.x + min(wg_id.x, remainder);