diff --git a/player/tests/data/all.ron b/player/tests/data/all.ron index 31d916c79..ee9bd3220 100644 --- a/player/tests/data/all.ron +++ b/player/tests/data/all.ron @@ -2,6 +2,7 @@ backends: (bits: 0x7), tests: [ "buffer-copy.ron", + "bind-group.ron", "quad.ron", ], ) \ No newline at end of file diff --git a/player/tests/data/bind-group.ron b/player/tests/data/bind-group.ron new file mode 100644 index 000000000..18b341ca1 --- /dev/null +++ b/player/tests/data/bind-group.ron @@ -0,0 +1,76 @@ +( + features: (bits: 0x0), + expectations: [], //not crash! + actions: [ + CreatePipelineLayout(Id(0, 1, Empty), ( + label: Some("empty"), + bind_group_layouts: [], + push_constant_ranges: [], + )), + CreateShaderModule( + id: Id(0, 1, Empty), + data: "empty.comp.spv", + ), + CreateComputePipeline(Id(0, 1, Empty), ( + label: None, + layout: Some(Id(0, 1, Empty)), + compute_stage: ( + module: Id(0, 1, Empty), + entry_point: "main", + ), + )), + CreateBuffer(Id(0, 1, Empty), ( + label: None, + size: 16, + usage: ( + bits: 64, + ), + mapped_at_creation: false, + )), + CreateBindGroupLayout(Id(0, 1, Empty), ( + label: None, + entries: [ + ( + binding: 0, + visibility: (bits: 0x3), + ty: UniformBuffer( + dynamic: false, + min_binding_size: None, + ), + count: None, + ), + ], + )), + CreateBindGroup(Id(0, 1, Empty), ( + label: None, + layout: Id(0, 1, Empty), + entries: [ + ( + binding: 0, + resource: Buffer(( + buffer_id: Id(0, 1, Empty), + offset: 0, + size: None, + )), + ) + ], + )), + Submit(1, [ + RunComputePass( + base: ( + commands: [ + SetPipeline(Id(0, 1, Empty)), + SetBindGroup( + index: 0, + num_dynamic_offsets: 0, + bind_group_id: Id(0, 1, Empty), + ), + ], + dynamic_offsets: [], + string_data: [], + push_constant_data: [], + ), + ), + ]), + ], +) \ No newline at end of file diff --git a/player/tests/data/empty.comp b/player/tests/data/empty.comp new file mode 100644 index 000000000..e1ed54725 --- /dev/null +++ b/player/tests/data/empty.comp @@ -0,0 +1,5 @@ +#version 450 +layout(local_size_x = 1) in; + +void main() { +} diff --git a/player/tests/data/empty.comp.spv b/player/tests/data/empty.comp.spv new file mode 100644 index 000000000..484a9bca4 Binary files /dev/null and b/player/tests/data/empty.comp.spv differ diff --git a/player/tests/data/quad.ron b/player/tests/data/quad.ron index 3e23cac1f..9bba47dc7 100644 --- a/player/tests/data/quad.ron +++ b/player/tests/data/quad.ron @@ -3,7 +3,7 @@ expectations: [ ( name: "Quad", - buffer: (index: 1, epoch: 1), + buffer: (index: 0, epoch: 1), offset: 0, data: File("quad.bin", 16384), ) @@ -38,7 +38,7 @@ desc: (), ), CreateBuffer( - Id(1, 1, Empty), + Id(0, 1, Empty), ( label: Some("Output Buffer"), size: 16384, @@ -135,7 +135,7 @@ array_layer: 0, ), dst: ( - buffer: Id(1, 1, Empty), + buffer: Id(0, 1, Empty), layout: ( offset: 0, bytes_per_row: 256, @@ -149,7 +149,5 @@ ), ), ]), - DestroyShaderModule(Id(0, 1, Empty)), - DestroyShaderModule(Id(1, 1, Empty)), ], ) \ No newline at end of file diff --git a/player/tests/test.rs b/player/tests/test.rs index 3d82c0d47..21d83e34f 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -142,6 +142,8 @@ impl Test<'_> { assert_eq!(&expected_data[..], contents); } + + gfx_select!(device => global.clear_backend(())); } } diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 584b4508a..59d7dfc14 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -520,7 +520,7 @@ impl Hub { } impl Hub { - fn clear(&mut self, surface_guard: &mut Storage) { + fn clear(&self, surface_guard: &mut Storage) { use crate::resource::TextureViewInner; use hal::{device::Device as _, window::PresentationSurface as _}; @@ -688,6 +688,12 @@ impl Global { hubs: Hubs::new(&factory), } } + + pub fn clear_backend(&self, _dummy: ()) { + let mut surface_guard = self.surfaces.data.write(); + let hub = B::hub(self); + hub.clear(&mut *surface_guard); + } } impl Drop for Global { diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index 2bfbc0c3e..f111d7ec9 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -202,16 +202,16 @@ struct PrivateFeatures { #[macro_export] macro_rules! gfx_select { - ($id:expr => $global:ident.$method:ident( $($param:expr),+ )) => { + ($id:expr => $global:ident.$method:ident( $($param:expr),* )) => { match $id.backend() { #[cfg(any(not(any(target_os = "ios", target_os = "macos")), feature = "gfx-backend-vulkan"))] - wgt::Backend::Vulkan => $global.$method::<$crate::backend::Vulkan>( $($param),+ ), + wgt::Backend::Vulkan => $global.$method::<$crate::backend::Vulkan>( $($param),* ), #[cfg(any(target_os = "ios", target_os = "macos"))] - wgt::Backend::Metal => $global.$method::<$crate::backend::Metal>( $($param),+ ), + wgt::Backend::Metal => $global.$method::<$crate::backend::Metal>( $($param),* ), #[cfg(windows)] - wgt::Backend::Dx12 => $global.$method::<$crate::backend::Dx12>( $($param),+ ), + wgt::Backend::Dx12 => $global.$method::<$crate::backend::Dx12>( $($param),* ), #[cfg(windows)] - wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),+ ), + wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),* ), _ => unreachable!() } };