Skip to content

Commit

Permalink
Fix bind group initialization in benchmarks (#6916)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald authored Jan 14, 2025
1 parent 90a97a1 commit 2cfea40
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
74 changes: 37 additions & 37 deletions benches/benches/bind_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,52 +62,52 @@ impl BindGroupState {
fn run_bench(ctx: &mut Criterion) {
let state = LazyLock::new(BindGroupState::new);

if !state
.device_state
.device
.features()
.contains(wgpu::Features::TEXTURE_BINDING_ARRAY)
{
return;
}

let mut group = ctx.benchmark_group("Bind Group Creation");

for count in [5, 50, 500, 5_000, 50_000] {
if count
> state
.device_state
.device
.limits()
.max_sampled_textures_per_shader_stage
{
continue;
}

let bind_group_layout =
state
.device_state
.device
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None,
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Texture {
sample_type: wgpu::TextureSampleType::Float { filterable: true },
view_dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: Some(NonZeroU32::new(count).unwrap()),
}],
});

group.throughput(Throughput::Elements(count as u64));
group.bench_with_input(
format!("{} Element Bind Group", count),
&count,
|b, &count| {
b.iter_custom(|iters| {
if !state
.device_state
.device
.features()
.contains(wgpu::Features::TEXTURE_BINDING_ARRAY)
{
return Duration::ZERO;
}

if count
> state
.device_state
.device
.limits()
.max_sampled_textures_per_shader_stage
{
return Duration::ZERO;
}

let bind_group_layout = state.device_state.device.create_bind_group_layout(
&wgpu::BindGroupLayoutDescriptor {
label: None,
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Texture {
sample_type: wgpu::TextureSampleType::Float {
filterable: true,
},
view_dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: Some(NonZeroU32::new(count).unwrap()),
}],
},
);

let texture_view_refs: Vec<_> =
state.texture_views.iter().take(count as usize).collect();

Expand Down
2 changes: 1 addition & 1 deletion benches/benches/computepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ fn run_bench(ctx: &mut Criterion) {

// Need bindless to run this benchmark
if state.bindless_bind_group.is_none() {
return Duration::from_secs_f32(1.0);
return Duration::from_secs(1);
}

let mut duration = Duration::ZERO;
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/renderpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ fn run_bench(ctx: &mut Criterion) {

// This benchmark hangs on Apple Paravirtualized GPUs. No idea why.
if state.device_state.adapter_info.name.contains("Paravirtual") {
return Duration::from_secs_f32(1.0);
return Duration::from_secs(1);
}

let mut duration = Duration::ZERO;
Expand Down

0 comments on commit 2cfea40

Please sign in to comment.