Playtest for binding a group

This commit is contained in:
Dzmitry Malyshau 2020-09-04 23:45:00 -04:00
parent 1886149cae
commit eed8bf84ef
8 changed files with 99 additions and 11 deletions

View File

@ -2,6 +2,7 @@
backends: (bits: 0x7), backends: (bits: 0x7),
tests: [ tests: [
"buffer-copy.ron", "buffer-copy.ron",
"bind-group.ron",
"quad.ron", "quad.ron",
], ],
) )

View File

@ -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: [],
),
),
]),
],
)

View File

@ -0,0 +1,5 @@
#version 450
layout(local_size_x = 1) in;
void main() {
}

Binary file not shown.

View File

@ -3,7 +3,7 @@
expectations: [ expectations: [
( (
name: "Quad", name: "Quad",
buffer: (index: 1, epoch: 1), buffer: (index: 0, epoch: 1),
offset: 0, offset: 0,
data: File("quad.bin", 16384), data: File("quad.bin", 16384),
) )
@ -38,7 +38,7 @@
desc: (), desc: (),
), ),
CreateBuffer( CreateBuffer(
Id(1, 1, Empty), Id(0, 1, Empty),
( (
label: Some("Output Buffer"), label: Some("Output Buffer"),
size: 16384, size: 16384,
@ -135,7 +135,7 @@
array_layer: 0, array_layer: 0,
), ),
dst: ( dst: (
buffer: Id(1, 1, Empty), buffer: Id(0, 1, Empty),
layout: ( layout: (
offset: 0, offset: 0,
bytes_per_row: 256, bytes_per_row: 256,
@ -149,7 +149,5 @@
), ),
), ),
]), ]),
DestroyShaderModule(Id(0, 1, Empty)),
DestroyShaderModule(Id(1, 1, Empty)),
], ],
) )

View File

@ -142,6 +142,8 @@ impl Test<'_> {
assert_eq!(&expected_data[..], contents); assert_eq!(&expected_data[..], contents);
} }
gfx_select!(device => global.clear_backend(()));
} }
} }

View File

@ -520,7 +520,7 @@ impl<B: GfxBackend, F: GlobalIdentityHandlerFactory> Hub<B, F> {
} }
impl<B: GfxBackend, F: GlobalIdentityHandlerFactory> Hub<B, F> { impl<B: GfxBackend, F: GlobalIdentityHandlerFactory> Hub<B, F> {
fn clear(&mut self, surface_guard: &mut Storage<Surface, SurfaceId>) { fn clear(&self, surface_guard: &mut Storage<Surface, SurfaceId>) {
use crate::resource::TextureViewInner; use crate::resource::TextureViewInner;
use hal::{device::Device as _, window::PresentationSurface as _}; use hal::{device::Device as _, window::PresentationSurface as _};
@ -688,6 +688,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
hubs: Hubs::new(&factory), hubs: Hubs::new(&factory),
} }
} }
pub fn clear_backend<B: GfxBackend>(&self, _dummy: ()) {
let mut surface_guard = self.surfaces.data.write();
let hub = B::hub(self);
hub.clear(&mut *surface_guard);
}
} }
impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> { impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {

View File

@ -202,16 +202,16 @@ struct PrivateFeatures {
#[macro_export] #[macro_export]
macro_rules! gfx_select { macro_rules! gfx_select {
($id:expr => $global:ident.$method:ident( $($param:expr),+ )) => { ($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {
match $id.backend() { match $id.backend() {
#[cfg(any(not(any(target_os = "ios", target_os = "macos")), feature = "gfx-backend-vulkan"))] #[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"))] #[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)] #[cfg(windows)]
wgt::Backend::Dx12 => $global.$method::<$crate::backend::Dx12>( $($param),+ ), wgt::Backend::Dx12 => $global.$method::<$crate::backend::Dx12>( $($param),* ),
#[cfg(windows)] #[cfg(windows)]
wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),+ ), wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),* ),
_ => unreachable!() _ => unreachable!()
} }
}; };