diff --git a/vello_encoding/src/config.rs b/vello_encoding/src/config.rs index 88da7fd46..31d132a7b 100644 --- a/vello_encoding/src/config.rs +++ b/vello_encoding/src/config.rs @@ -143,9 +143,10 @@ pub struct ConfigUniform { pub binning_size: u32, /// Size of tile buffer allocation (in [`Tile`]s). pub tiles_size: u32, - /// Size of segment count buffer allocation (in [`SegmentCount`]s). - pub seg_counts_size: u32, - /// Size of segment buffer allocation (in [`PathSegment`]s). + /// The maximum number of segments we can support. + /// + /// This is the size of the segment count buffer allocation (in [`SegmentCount`]s) + /// *and* the segment buffer allocation (in [`PathSegment`]s). pub segments_size: u32, /// Size of blend spill buffer (in `u32` pixels). // TODO: Maybe store in TILE_WIDTH * TILE_HEIGHT blocks of pixels instead? @@ -175,6 +176,8 @@ impl RenderConfig { let workgroup_counts = WorkgroupCounts::new(layout, width_in_tiles, height_in_tiles, n_path_tags); let buffer_sizes = BufferSizes::new(layout, &workgroup_counts); + let segments_size = buffer_sizes.segments.len(); + debug_assert_eq!(segments_size, buffer_sizes.seg_counts.len()); Self { gpu: ConfigUniform { width_in_tiles, @@ -185,8 +188,7 @@ impl RenderConfig { lines_size: buffer_sizes.lines.len(), binning_size: buffer_sizes.bin_data.len() - layout.bin_data_start, tiles_size: buffer_sizes.tiles.len(), - seg_counts_size: buffer_sizes.seg_counts.len(), - segments_size: buffer_sizes.segments.len(), + segments_size, blend_size: buffer_sizes.blend_spill.len(), ptcl_size: buffer_sizes.ptcl.len(), layout: *layout, @@ -398,8 +400,10 @@ impl BufferSizes { let bin_data = BufferSize::new(1 << 18); let tiles = BufferSize::new(1 << 21); let lines = BufferSize::new(1 << 21); - let seg_counts = BufferSize::new(1 << 21); - let segments = BufferSize::new(1 << 21); + // These two buffer sizes *must* be the same. + let max_segments = 1 << 21; + let seg_counts = BufferSize::new(max_segments); + let segments = BufferSize::new(max_segments); // 16 * 16 (1 << 8) is one blend spill, so this allows for 4096 spills. let blend_spill = BufferSize::new(1 << 20); let ptcl = BufferSize::new(1 << 23); diff --git a/vello_shaders/build.rs b/vello_shaders/build.rs index 79abde655..57930b26a 100644 --- a/vello_shaders/build.rs +++ b/vello_shaders/build.rs @@ -24,7 +24,10 @@ fn main() { let mut shaders = match compile::ShaderInfo::from_default() { Ok(s) => s, Err(err) => { - eprintln!("{err}"); + let formatted = err.to_string(); + for line in formatted.lines() { + println!("cargo:warning={line}"); + } return; } }; diff --git a/vello_shaders/shader/coarse.wgsl b/vello_shaders/shader/coarse.wgsl index d47b43b9b..104868250 100644 --- a/vello_shaders/shader/coarse.wgsl +++ b/vello_shaders/shader/coarse.wgsl @@ -164,7 +164,7 @@ fn main( // we still want to know this workgroup's memory requirement. if local_id.x == 0u { var failed = atomicLoad(&bump.failed) & (STAGE_BINNING | STAGE_TILE_ALLOC | STAGE_FLATTEN); - if atomicLoad(&bump.seg_counts) > config.seg_counts_size { + if atomicLoad(&bump.seg_counts) > config.segments_size { failed |= STAGE_PATH_COUNT; } // Reuse sh_part_count to hold failed flag, shmem is tight diff --git a/vello_shaders/shader/path_count.wgsl b/vello_shaders/shader/path_count.wgsl index 7de89278d..a2c88b99e 100644 --- a/vello_shaders/shader/path_count.wgsl +++ b/vello_shaders/shader/path_count.wgsl @@ -191,7 +191,7 @@ fn main( let counts = (seg_within_slice << 16u) | subix; let seg_count = SegmentCount(line_ix, counts); let seg_ix = seg_base + i - imin; - if seg_ix < config.seg_counts_size { + if seg_ix < config.segments_size { seg_counts[seg_ix] = seg_count; } // Note: since we're iterating, we have a reliable value for diff --git a/vello_shaders/shader/shared/config.wgsl b/vello_shaders/shader/shared/config.wgsl index 3391afd9a..c45908417 100644 --- a/vello_shaders/shader/shared/config.wgsl +++ b/vello_shaders/shader/shared/config.wgsl @@ -36,7 +36,6 @@ struct Config { lines_size: u32, binning_size: u32, tiles_size: u32, - seg_counts_size: u32, segments_size: u32, blend_size: u32, ptcl_size: u32,