Skip to content

Commit

Permalink
[shaders] Remove unused resource bindings
Browse files Browse the repository at this point in the history
clip_reduce, path_coarse_full, and fine stages declare some resource
bindings that are not used.

These handful of bindings have now been removed and the binding indices
were rearranged to be compact.

This partially helps with the bug reported in #330. The actual fix for
that issue actually makes it so that the unused bindings are no longer
a problem with native integrations of the vello_shader crate, but this
is a reasonable clean up nontheless.
  • Loading branch information
armansito committed Sep 14, 2023
1 parent 8816f27 commit b30617a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
10 changes: 3 additions & 7 deletions shader/clip_reduce.wgsl
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense

#import config
#import bbox
#import clip

@group(0) @binding(0)
var<uniform> config: Config;

@group(0) @binding(1)
var<storage> clip_inp: array<ClipInp>;

@group(0) @binding(2)
@group(0) @binding(1)
var<storage> path_bboxes: array<PathBbox>;

@group(0) @binding(3)
@group(0) @binding(2)
var<storage, read_write> reduced: array<Bic>;

@group(0) @binding(4)
@group(0) @binding(3)
var<storage, read_write> clip_out: array<ClipEl>;

let WG_SIZE = 256u;
Expand Down
13 changes: 5 additions & 8 deletions shader/fine.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ struct Tile {
var<uniform> config: Config;

@group(0) @binding(1)
var<storage> tiles: array<Tile>;

@group(0) @binding(2)
var<storage> segments: array<Segment>;

#ifdef full
Expand All @@ -28,19 +25,19 @@ var<storage> segments: array<Segment>;

let GRADIENT_WIDTH = 512;

@group(0) @binding(2)
var<storage> ptcl: array<u32>;

@group(0) @binding(3)
var output: texture_storage_2d<rgba8unorm, write>;
var<storage> info: array<u32>;

@group(0) @binding(4)
var<storage> ptcl: array<u32>;
var output: texture_storage_2d<rgba8unorm, write>;

@group(0) @binding(5)
var gradients: texture_2d<f32>;

@group(0) @binding(6)
var<storage> info: array<u32>;

@group(0) @binding(7)
var image_atlas: texture_2d<f32>;

fn read_fill(cmd_ix: u32) -> CmdFill {
Expand Down
11 changes: 4 additions & 7 deletions shader/path_coarse_full.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ var<uniform> config: Config;
var<storage> scene: array<u32>;

@group(0) @binding(2)
var<storage> tag_monoids: array<TagMonoid>;

@group(0) @binding(3)
var<storage> cubics: array<Cubic>;

@group(0) @binding(4)
@group(0) @binding(3)
var<storage> paths: array<Path>;

// We don't get this from import as it's the atomic version
Expand All @@ -30,13 +27,13 @@ struct AtomicTile {
segments: atomic<u32>,
}

@group(0) @binding(5)
@group(0) @binding(4)
var<storage, read_write> bump: BumpAllocators;

@group(0) @binding(6)
@group(0) @binding(5)
var<storage, read_write> tiles: array<AtomicTile>;

@group(0) @binding(7)
@group(0) @binding(6)
var<storage, read_write> segments: array<Segment>;

struct SubdivResult {
Expand Down
7 changes: 2 additions & 5 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ impl Render {
shaders.clip_reduce,
wg_counts.clip_reduce,
[
config_buf,
clip_inp_buf,
path_bbox_buf,
clip_bic_buf,
Expand Down Expand Up @@ -320,7 +319,6 @@ impl Render {
[
config_buf,
scene_buf,
tagmonoid_buf,
cubic_buf,
path_buf,
bump_buf,
Expand Down Expand Up @@ -383,12 +381,11 @@ impl Render {
fine_wg_count,
[
fine.config_buf,
fine.tile_buf,
fine.segments_buf,
ResourceProxy::Image(fine.out_image),
fine.ptcl_buf,
fine.gradient_image,
fine.info_bin_data_buf,
ResourceProxy::Image(fine.out_image),
fine.gradient_image,
fine.image_atlas,
],
);
Expand Down
5 changes: 1 addition & 4 deletions src/shaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ pub fn full_shaders(device: &Device, engine: &mut Engine) -> Result<FullShaders,
"clip_reduce",
preprocess::preprocess(shader!("clip_reduce"), &empty, &imports).into(),
&[
BindType::Uniform,
BindType::BufReadOnly,
BindType::BufReadOnly,
BindType::Buffer,
Expand Down Expand Up @@ -228,7 +227,6 @@ pub fn full_shaders(device: &Device, engine: &mut Engine) -> Result<FullShaders,
BindType::BufReadOnly,
BindType::BufReadOnly,
BindType::BufReadOnly,
BindType::BufReadOnly,
BindType::Buffer,
BindType::Buffer,
BindType::Buffer,
Expand Down Expand Up @@ -264,10 +262,9 @@ pub fn full_shaders(device: &Device, engine: &mut Engine) -> Result<FullShaders,
BindType::Uniform,
BindType::BufReadOnly,
BindType::BufReadOnly,
BindType::Image(ImageFormat::Rgba8),
BindType::BufReadOnly,
BindType::Image(ImageFormat::Rgba8),
BindType::ImageRead(ImageFormat::Rgba8),
BindType::BufReadOnly,
BindType::ImageRead(ImageFormat::Rgba8),
],
)?;
Expand Down

0 comments on commit b30617a

Please sign in to comment.