Skip to content
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

Implement texture_storage_Xd in WGSL #5158

Merged

Conversation

jkwak-work
Copy link
Collaborator

Closes #5082

This commit implements texture_storage_Xd in WGSL, which is similar to RWTextureXD in HLSL.

It is intresting that texture_storage_Xd doesn't take the shader type as its input argument at all.
Instead, it takes "texel format" enum value as its first template parameter, which can be found here:
https://www.w3.org/TR/WGSL/#storage-texel-formats

As an example, texture_storage_2d<rg32uint, read_write> expects vec4 as a value type for Load and Store, where Z-component will be ignored and treated as zero and W-component will be treated always as 1.

WGSL requires texture_storage_Xd values to always be global variables and they cannot be passed into a function as a function argument.

@jkwak-work jkwak-work added the pr: non-breaking PRs without breaking changes label Sep 25, 2024
@jkwak-work jkwak-work self-assigned this Sep 25, 2024
source/slang/slang-emit-wgsl.cpp Show resolved Hide resolved
source/slang/slang-emit-wgsl.cpp Outdated Show resolved Hide resolved
@jkwak-work
Copy link
Collaborator Author

I rebased to include Yong's change.
But I still need to address the comment.
I need to go over each format more carefully.

csyonghe
csyonghe previously approved these changes Sep 26, 2024
This commit implements `texture_storage_Xd` in WGSL, which is similar
to RWTextureXD in HLSL.

It is intresting that `texture_storage_Xd` doesn't take the shader
type as its input argument at all.
Instead, it takes "texel format" enum value as its first template
parameter, which can be found here:
https://www.w3.org/TR/WGSL/#storage-texel-formats

As an example, `texture_storage_2d<rg32uint, read_write>` expects
vec4<u32> as a value type for `Load` and `Store`, where Z-component
will be ignored and treated as zero and W-component will be treated
always as 1. The type `u32` is inferred from the enum value `rg32uint`.
Note that the number of component is always fixed to 4 regardless how
many components are actually stored.
@jkwak-work jkwak-work merged commit 4730d54 into shader-slang:master Sep 26, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WGSL: Intrinsics: texture
2 participants