Add missing barrier Add barrier for write-after-read hazard in coarse. The loop in question processes 64k draw objects at a time, so the barrier only gets invoked when that limit is exceeded. Also move new test scene so it isn't the first.
diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index fa6f717..2e36a39 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs
@@ -33,7 +33,6 @@ pub fn test_scenes() -> SceneSet { let scenes = vec![ - scene!(many_draw), scene!(splash_with_tiger(), "splash_with_tiger", false), scene!(funky_paths), scene!(stroke_styles(Affine::IDENTITY), "stroke_styles", false), @@ -63,6 +62,7 @@ scene!(longpathdash(Cap::Butt), "longpathdash (butt caps)", false), scene!(longpathdash(Cap::Round), "longpathdash (round caps)", false), scene!(crate::mmark::MMark::new(80_000), "mmark", false), + scene!(many_draw_objects), ]; SceneSet { scenes } @@ -70,21 +70,6 @@ // Scenes -fn many_draw(scene: &mut Scene, _: &mut SceneParams) { - const N_WIDE: usize = 300; - const N_HIGH: usize = 300; - const SCENE_WIDTH: f64 = 2000.0; - const SCENE_HEIGHT: f64 = 1500.0; - 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 { - let x = (i as f64 + 0.5) * (SCENE_WIDTH / N_WIDE as f64); - let c = Circle::new((x, y), 3.0); - scene.fill(Fill::NonZero, Affine::IDENTITY, Color::YELLOW, None, &c); - } - } -} - fn funky_paths(scene: &mut Scene, _: &mut SceneParams) { use PathEl::*; let missing_movetos = [ @@ -1538,6 +1523,21 @@ ] } +fn many_draw_objects(scene: &mut Scene, _: &mut SceneParams) { + const N_WIDE: usize = 300; + const N_HIGH: usize = 300; + const SCENE_WIDTH: f64 = 2000.0; + const SCENE_HEIGHT: f64 = 1500.0; + 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 { + let x = (i as f64 + 0.5) * (SCENE_WIDTH / N_WIDE as f64); + let c = Circle::new((x, y), 3.0); + scene.fill(Fill::NonZero, Affine::IDENTITY, Color::YELLOW, None, &c); + } + } +} + fn splash_screen(scene: &mut Scene, params: &mut SceneParams) { let strings = [ "Vello test",
diff --git a/shader/coarse.wgsl b/shader/coarse.wgsl index 6caa35a..758244c 100644 --- a/shader/coarse.wgsl +++ b/shader/coarse.wgsl
@@ -236,6 +236,7 @@ if wr_ix - rd_ix >= N_TILE || (wr_ix >= ready_ix && partition_ix >= n_partitions) { break; } + workgroupBarrier(); } // At this point, sh_drawobj_ix[0.. wr_ix - rd_ix] contains merged binning results. var tag = DRAWTAG_NOP;