这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@dj2
Copy link
Member

@dj2 dj2 commented Oct 26, 2020

This CL adds the ability to provide an access(read|read_write) to a
buffer type. This is only available for storage variables.

Issue #1159

@dj2 dj2 added the wgsl WebGPU Shading Language Issues label Oct 26, 2020
@dj2 dj2 added this to the MVP milestone Oct 26, 2020
@dj2 dj2 requested a review from dneto0 October 26, 2020 19:46
@dj2 dj2 self-assigned this Oct 26, 2020
@dj2
Copy link
Member Author

dj2 commented Oct 26, 2020

Note this uses a slightly different access_type then the texture CL. We can either unify them and just limit storage to use read, read_write while texture uses read, write or we can have two productions.

Copy link
Contributor

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dj2 dj2 requested a review from kvark October 27, 2020 13:28
@grorg
Copy link
Contributor

grorg commented Nov 3, 2020

Discussed at 2020-11-03 meeting.

@dneto0
Copy link
Contributor

dneto0 commented Nov 11, 2020

I'll take one more crack at this. It goes back to the distinction between values (which are mathematical things) and variables (which are storage constructs in a computer).

From the spec, section Variable and const:

A variable is a named reference to storage that can contain a value of a particular storable type.

Two types are associated with a variable: its store type (the type of value that may be placed in the referenced storage) and its reference type (the type of the variable itself). If a variable has store type T and storage class S, then its reference type is pointer-to-T-in-S.

The store type is the thing we write after the colon. So in

    var foo :  i32;      

What we have is that foo is a named reference to (unique) storage, where that storage can hold an i32.

For a buffer variable, the store type describes the contents of the storage. We describe it with a struct with members (including layout. #1215).
The fact that you can write to those contents is a property of the thing that references the storage, not the values in the storage. We use the ordinary expressions in the language to do that reading and writing.

Contrast that with textures and samplers, which are opaque: they have no internal structure that we can poke at with WGSL expressions. There is no internal structure to the "store type".
We can only operate on textures and samplers via builtin functions. The only thing the type of a sampler or texture conveys is which builtin functions can operate on it. It's the builtins which determine whether they read or write.

So in sum:

  • the struct type for a buffer is the store type: describes values. It doesn't capture the access kinds (readonly, readwrite)
  • the texture or sampler has no internal structure to talk about, so everything, including access kinds is bound up into the type itself.

Copy link
Contributor

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad we can make forward progress.

@grorg
Copy link
Contributor

grorg commented Nov 17, 2020

Discussed at 2020-11-17 meeting.

dj2 and others added 8 commits November 17, 2020 16:38
@dj2
Copy link
Member Author

dj2 commented Nov 17, 2020

Updated to remove the access, read and read_write token. Uses the variable_declaration_list instead.

@kvark kvark merged commit 3603800 into gpuweb:main Nov 17, 2020
@dj2 dj2 deleted the buf_access branch November 18, 2020 01:42
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This PR creates a shader/validation/parse folder and moves the WGSL
parsing tests into the folder. The tests are split out by type to
make the test files more targeted.

For the var/let cases half of them are in the shader_io folder where
they relate to IO sharable types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wgsl WebGPU Shading Language Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants