mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Playtest for binding a group
This commit is contained in:
parent
1886149cae
commit
eed8bf84ef
@ -2,6 +2,7 @@
|
||||
backends: (bits: 0x7),
|
||||
tests: [
|
||||
"buffer-copy.ron",
|
||||
"bind-group.ron",
|
||||
"quad.ron",
|
||||
],
|
||||
)
|
||||
76
player/tests/data/bind-group.ron
Normal file
76
player/tests/data/bind-group.ron
Normal 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: [],
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
)
|
||||
5
player/tests/data/empty.comp
Normal file
5
player/tests/data/empty.comp
Normal file
@ -0,0 +1,5 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
void main() {
|
||||
}
|
||||
BIN
player/tests/data/empty.comp.spv
Normal file
BIN
player/tests/data/empty.comp.spv
Normal file
Binary file not shown.
@ -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)),
|
||||
],
|
||||
)
|
||||
@ -142,6 +142,8 @@ impl Test<'_> {
|
||||
|
||||
assert_eq!(&expected_data[..], contents);
|
||||
}
|
||||
|
||||
gfx_select!(device => global.clear_backend(()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -520,7 +520,7 @@ 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 hal::{device::Device as _, window::PresentationSurface as _};
|
||||
|
||||
@ -688,6 +688,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
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> {
|
||||
|
||||
@ -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!()
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user