Skip to content

Fix grammar inconsistency in read-only storage textures - #1059

Closed
dneto0 wants to merge 1 commit into
gpuweb:mainfrom
dneto0:1085-inconsistent-ro-storage
Closed

dneto0 wants to merge 1 commit into
gpuweb:mainfrom
dneto0:1085-inconsistent-ro-storage

Conversation

@dneto0

@dneto0 dneto0 commented Sep 8, 2020

Copy link
Copy Markdown
Contributor

Fixes #1056

Also, remove ReadOnly and WriteOnly literals in the SPIR-V examples
for declaring image types. Those optional literal qualifiers are only
used for Kernel modules, not Shader modules.

Fixes gpuweb#1056

Also, remove ReadOnly and WriteOnly literals in the SPIR-V examples
for declaring image types. Those optional literal qualifiers are only
used for Kernel modules, not Shader modules.
@dneto0
dneto0 requested review from kvark and litherum September 8, 2020 17:02

@kvark kvark left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The first half of the change is great!
This half, however, is not:

Also, remove ReadOnly and WriteOnly literals in the SPIR-V examples
for declaring image types. Those optional literal qualifiers are only
used for Kernel modules, not Shader modules.

We still need to specify that these are read-only or write only.
So instead of stripping them away, we should fix them, i.e. "ReadOnly" -> "NonWritable", and "WriteOnly" -> "NonReadable"

actually: not sure how exactly to write this down in this syntax, but we must say that these decorations apply somehow

@dj2 dj2 added the wgsl WebGPU Shading Language Issues label Sep 14, 2020
@dj2

dj2 commented Sep 14, 2020

Copy link
Copy Markdown
Member

It doesn't look like there is a way to specify Read/Write only in the SPIR-V? At least not that I see.

@kvark

kvark commented Sep 14, 2020

Copy link
Copy Markdown
Contributor

In SPIR-V the read/write is done via NonWritable and NonReadable decorations on the global variable.

@dj2

dj2 commented Sep 14, 2020

Copy link
Copy Markdown
Member

Right, so not relevant for OpImageType, but for when the variable is created later. Is the suggestion to make that update here as well?

@kvark kvark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suppose this is where the 1:1 correspondence of WGSL to SPIR-V starts to crack a little bit. Saying that texture_ro_1d is just an OpTypeImage is correct, but it doesn't provide the full picture.
Where do you see it being specified that this will put the NonWritable decoration on any global variable of this image type?

@dj2

dj2 commented Sep 14, 2020

Copy link
Copy Markdown
Member

That's a good question. I think in the variable section where we define things we'll need a blurb on wo and ro textures that says they get NonWritable and NonReadable annotations in SPIR-V? @dneto0 does that make sense to you?

@dneto0

dneto0 commented Sep 19, 2020

Copy link
Copy Markdown
Contributor Author

That's a good question. I think in the variable section where we define things we'll need a blurb on wo and ro textures that says they get NonWritable and NonReadable annotations in SPIR-V? @dneto0 does that make sense to you?

Yes. Exactly.
This is a place where Kernel and Shader differ. I don't know why this is the case for images. (??)

Related is what to do for buffers. SPIR-V for Shader had to match the flexibility in GLSL, where the readonly attribute can apply to individual struct members.
WebGPU doesn't have that flexibility: read-only-ness or write-only-ness applies to the entire buffer or not at all.

We'll restrict the readonly/writeonly attribute to the whole variable, as suggested.

(This was on my TODO list!)

@dneto0

dneto0 commented Sep 25, 2020

Copy link
Copy Markdown
Contributor Author

Closing, as this is superceded by #1089 and #1110

@dneto0 dneto0 closed this Sep 25, 2020
ben-clayton added a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
Promote the builtin test runner to `src/webgpu/shader/execution/expression.ts`,  and tweak the interface so it can be used for any kind of expression.

Move comparision utilities out to `src/webgpu/util/compare.ts`.
Move constants out to `src/webgpu/util/constants.ts`.
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.

read-only image storage type declarations: examples inconsistent with grammar

3 participants