-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WGSL examples to documentation #2888
Conversation
Hm. Comparing the WGSL and GLSL specs, it seems that WGSL is far more restrictive than GLSL in terms of access modes. For example, according to this table, I don't think it's possible to define a read-write or write-only uniform, texture, or sampler. However, I see no such restrictions in this rather minimal explanation of access modes offered by the GLSL spec. If my understanding is correct, then some documentation items may be necessarily devoid of a WGSL example due to the limitations of the language. In particular, I think this is the case with |
|
GLSL may allow you to put the keywords there, but uniform buffers, textures, and samplers are always read-only, there is no way to actually write to them. In those examples, I think it's perfectly fine to do normal wgsl declarations. We offer read-write and read storage texture support as a native extension, so using a wgsl example (using the extension) is totally fine. |
Ah. I will remove the explicit
Hm. naga accepts that? I don't think the WGSL syntax technically permits that, even if it is possible hardware-wise. Should it be noted somewhere that that's not an official WGSL extension (the only one I see is |
As an aside: I think some of my confusion arose from storage textures, as defined by the WGSL spec, being write-only, but their handles being read-only. Apparently there is an issue to clarify this already: gpuweb/gpuweb#3047. |
Wouldn't hurt, though we already do this to an extent by separating "native" and "webgpu" extensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By and large looks great, thank you! Some nits
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
It seems |
Yeah that would work - sorry for the delay in responding. |
Head branch was pushed to by a user without write access
Checklist
cargo clippy
.RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown
if applicable.Features
example(s).BufferBindingType
example(s).BindingType
example(s).StorageTextureAccess
example(s).TextureSampleType
example(s).TextureViewDimension
example(s).Connections
Partly addresses #2849.
Description
Adds WGSL examples to wgpu documentation to complement the existing examples written in GLSL.
Testing
Run
cargo doc
to observe that the documentation is updated, and compile the WGSL examples (e.g. with naga) to confirm they are valid.