mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Added player test with compute shader reading & writing an uninitialized buffer
This commit is contained in:
parent
780637eec0
commit
5e488d4fea
@ -2,7 +2,8 @@
|
||||
backends: (bits: 0xF),
|
||||
tests: [
|
||||
"buffer-copy.ron",
|
||||
"buffer-zero-init.ron",
|
||||
"buffer-zero-init-for-mapping-and-writing.ron",
|
||||
"buffer-zero-init-for-binding.ron",
|
||||
"bind-group.ron",
|
||||
"quad.ron",
|
||||
],
|
||||
|
99
player/tests/data/buffer-zero-init-for-binding.ron
Normal file
99
player/tests/data/buffer-zero-init-for-binding.ron
Normal file
@ -0,0 +1,99 @@
|
||||
(
|
||||
features: (bits: 0x0),
|
||||
expectations: [
|
||||
(
|
||||
name: "buffer has correct values",
|
||||
buffer: (index: 0, epoch: 1),
|
||||
offset: 0,
|
||||
data: Raw([0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00]),
|
||||
)
|
||||
],
|
||||
actions: [
|
||||
CreateShaderModule(
|
||||
id: Id(0, 1, Empty),
|
||||
desc: (
|
||||
label: None,
|
||||
experimental_translation: true,
|
||||
),
|
||||
data: "buffer-zero-init-for-binding.wgsl",
|
||||
),
|
||||
CreateBuffer(Id(0, 1, Empty), (
|
||||
label: None,
|
||||
size: 16,
|
||||
usage: (
|
||||
bits: 129, // STORAGE + MAP_READ
|
||||
),
|
||||
mapped_at_creation: false,
|
||||
)),
|
||||
CreateBindGroupLayout(Id(0, 1, Empty), (
|
||||
label: None,
|
||||
entries: [
|
||||
(
|
||||
binding: 0,
|
||||
visibility: (
|
||||
bits: 4,
|
||||
),
|
||||
ty: Buffer(
|
||||
ty: Storage(
|
||||
read_only: false,
|
||||
),
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: Some(16),
|
||||
),
|
||||
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: Some(16),
|
||||
)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
CreatePipelineLayout(Id(0, 1, Empty), (
|
||||
label: None,
|
||||
bind_group_layouts: [
|
||||
Id(0, 1, Empty),
|
||||
],
|
||||
push_constant_ranges: [],
|
||||
)),
|
||||
CreateComputePipeline(Id(0, 1, Empty), (
|
||||
label: None,
|
||||
layout: Some(Id(0, 1, Empty)),
|
||||
stage: (
|
||||
module: Id(0, 1, Empty),
|
||||
entry_point: "main",
|
||||
),
|
||||
)),
|
||||
Submit(1, [
|
||||
RunComputePass(
|
||||
base: (
|
||||
label: None,
|
||||
commands: [
|
||||
SetPipeline(Id(0, 1, Empty)),
|
||||
SetBindGroup(
|
||||
index: 0,
|
||||
num_dynamic_offsets: 0,
|
||||
bind_group_id: Id(0, 1, Empty),
|
||||
),
|
||||
Dispatch((4, 1, 1)),
|
||||
],
|
||||
dynamic_offsets: [],
|
||||
string_data: [],
|
||||
push_constant_data: [],
|
||||
),
|
||||
)
|
||||
]),
|
||||
]
|
||||
)
|
15
player/tests/data/buffer-zero-init-for-binding.wgsl
Normal file
15
player/tests/data/buffer-zero-init-for-binding.wgsl
Normal file
@ -0,0 +1,15 @@
|
||||
[[builtin(global_invocation_id)]]
|
||||
var global_id: vec3<u32>;
|
||||
|
||||
[[block]]
|
||||
struct InOutBuffer {
|
||||
data: [[stride(4)]] array<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
var<storage> buffer: [[access(read_write)]] InOutBuffer;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
buffer.data[global_id.x] = buffer.data[global_id.x] + global_id.x;
|
||||
}
|
Loading…
Reference in New Issue
Block a user