wgpu/tests/in/binding-buffer-arrays.wgsl
Dzmitry Malyshau 37b3c36a8f
Support array bindings of buffers (#2282)
* Support buffer resource arrays in IR, wgsl-in, and spv-out

* spv-out: refactor non-uniform indexing semantics to support buffers

* Update the doc comment on BindingArray type

* Improve TypeInfo restrictions on binding arrays

* Strip DATA out of binding arrays

* Include suggested documentation, more binding array tests, enforce structs
2023-04-24 21:30:49 -07:00

28 lines
551 B
WebGPU Shading Language

struct UniformIndex {
index: u32
}
struct Foo { x: u32 }
@group(0) @binding(0)
var<storage, read> storage_array: binding_array<Foo, 1>;
@group(0) @binding(10)
var<uniform> uni: UniformIndex;
struct FragmentIn {
@location(0) index: u32,
}
@fragment
fn main(fragment_in: FragmentIn) -> @location(0) u32 {
let uniform_index = uni.index;
let non_uniform_index = fragment_in.index;
var u1 = 0u;
u1 += storage_array[0].x;
u1 += storage_array[uniform_index].x;
u1 += storage_array[non_uniform_index].x;
return u1;
}