Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Store type for buffer does not have to be structure
* Modify an example showing a runtime-sized array as the store type
  for a storage buffer.

Fixes: #2188
  • Loading branch information
dneto0 committed Jan 19, 2022
commit 9338e7a0b89b311db137caaa504963511c79168c
18 changes: 8 additions & 10 deletions wgsl/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,15 +1267,17 @@ Note: Each member type must be a [=plain type=].

Some consequences of the restrictions structure member and array element types are:
* A pointer, texture, or sampler must not appear in any level of nesting within an array or structure.
* A [=runtime-sized=] array must only appear as the last element of a structure, which itself
cannot be part of an enclosing array or structure.
* When a [=runtime-sized=] array is part of a larger type, it may only appear
as the last element of a structure, which itself cannot be part of an enclosing array or structure.

<div class='example wgsl global-scope' heading="Structure">
<xmp highlight='rust'>
// A structure with two members.
// A structure with four members.
struct Data {
a: i32;
b: vec2<f32>;
c: array<i32,10>;
d: array<f32>;
}
</xmp>
</div>
Expand Down Expand Up @@ -3311,11 +3313,11 @@ Variables at [=module scope=] are restricted as follows:
have a storage class decoration. The storage class will always be [=storage classes/handle=].

A variable in the [=storage classes/uniform=] storage class is a <dfn noexport>uniform buffer</dfn> variable.
Its [=store type=] must be a [=host-shareable=] [=constructible=] structure type,
Its [=store type=] must be a [=host-shareable=] [=constructible=] type,
and must satisfy [storage class layout constraints](#storage-class-layout-constraints).

A variable in the [=storage classes/storage=] storage class is a <dfn noexport>storage buffer</dfn> variable.
Its [=store type=] must be a [=host-shareable=] structure type
Its [=store type=] must be a [=host-shareable=] type
and must satisfy [storage class layout constraints](#storage-class-layout-constraints).
The variable may be declared with a [=access/read=] or [=access/read_write=] access mode; the default is [=access/read=].

Expand All @@ -3341,13 +3343,9 @@ Such variables are declared with [=attribute/group=] and [=attribute/binding=] d
@group(0) @binding(2)
var<uniform> param: Params; // A uniform buffer

struct PositionsBuffer {
// TODO: runtime-sized array syntax may have changed
pos: array<vec2<f32>>;
}
// A storage buffer, for reading and writing
@group(0) @binding(0)
var<storage,read_write> pbuf: PositionsBuffer;
var<storage,read_write> pbuf: array<vec2<f32>>;

// Textures and samplers are always in "handle" storage.
@group(0) @binding(1)
Expand Down