From 2cfea40acc60687ab7a8d645815be184e8e4e20b Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Tue, 14 Jan 2025 18:02:05 -0500 Subject: [PATCH] Fix bind group initialization in benchmarks (#6916) --- benches/benches/bind_groups.rs | 74 +++++++++++++++++----------------- benches/benches/computepass.rs | 2 +- benches/benches/renderpass.rs | 2 +- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/benches/benches/bind_groups.rs b/benches/benches/bind_groups.rs index 762f8126bc..0f707db04e 100644 --- a/benches/benches/bind_groups.rs +++ b/benches/benches/bind_groups.rs @@ -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(); diff --git a/benches/benches/computepass.rs b/benches/benches/computepass.rs index 1ac14c092a..300e461f30 100644 --- a/benches/benches/computepass.rs +++ b/benches/benches/computepass.rs @@ -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; diff --git a/benches/benches/renderpass.rs b/benches/benches/renderpass.rs index 5471fb94c4..156a41d0d1 100644 --- a/benches/benches/renderpass.rs +++ b/benches/benches/renderpass.rs @@ -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;