-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[naga wgsl-in] Add support for unsigned types when calling textureLoad with the level parameter. #7058
[naga wgsl-in] Add support for unsigned types when calling textureLoad with the level parameter. #7058
Conversation
FYI To test I used
|
@ygdrasil-io: Sounds like you don't have |
The texelFetch function in GLSL does not support unsigned integers. Should we cast the value to an integer? |
@cwfitzgerald suggested doing casting on matrix, so I implemented it with commit 546497b. |
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.
Nice, looks generally good, a few comments
naga/tests/out/hlsl/image.hlsl
Outdated
@@ -37,6 +37,7 @@ void main(uint3 local_id : SV_GroupThreadID) | |||
uint2 dim = NagaRWDimensions2D(image_storage_src); | |||
int2 itc = (int2((dim * local_id.xy)) % int2(10, 20)); | |||
uint4 value1_ = image_mipmapped_src.Load(int3(itc, int(local_id.z))); | |||
uint4 value1_2_ = image_mipmapped_src.Load(int3(itc, uint(local_id.z))); |
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.
I feel like there's an implicit conversion here, and we should also wrap the argument in int
as well, like we do glsl.
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.
This is done. I also did some refactoring on wgpu/naga/src/back/hlsl/writer.rs
to break up the monolithic function write_expr
.
eb51db5
to
dcc3a54
Compare
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.
I think we're g2g after jimb's comment is addressed.
this is fixed |
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!
Got a conflict on |
Improve the validation logic for image level indices by matching against specific scalar types (Sint or Uint). This change ensures accurate error handling for invalid index types.
Moved HLSL image load logic into a dedicated `write_image_load` function to improve modularity and readability. Additionally, added explicit type casting for certain scalar values to ensure correctness in generated HLSL code. Updated tests to reflect these changes and added related utility updates.
Update parameter types in `write_expr` for consistency and add `#[allow(clippy::too_many_arguments)]` to suppress linter warnings. This improves readability and maintains compatibility with existing code conventions.
c94b7b4
to
00dbdf8
Compare
Connections
Fix #5433
Description
In WSGL, the Naga frontend returns an error when using a u32 as the level parameter in textureLoad, although this is acceptable according to the specification at https://www.w3.org/TR/WGSL/#textureload.
Testing
This issue was tested by updating the image.wsgl file, which is executed as part of the unit test suite. The test includes a call to textureLoad with a u32 parameter.
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.