fix: emit dimension-correct HLSL texture sample offsets - #9951
Conversation
ErichDonGubler
left a comment
There was a problem hiding this comment.
This looks like a good start, and I like the snapshot test. There are a few things that still need to happen, though, before I'd approve this:
- Handle the feedback I left as individual conversations in the overall diff.
- The OP is verbose to the point of hurting communication (LLM output?), so I edited it down to the useful bits.
- The issue was motivated by CTS tests, and we should prove we're solving it with the same. Please add some CTS test coverage, preferably for all dimensionalities.
LMK if you need anything else!
Addresses @ErichDonGubler's review. writer.rs: use TypeInner::vector_size_and_scalar instead of re-implementing the match, switch debug_assert_eq! to assert_eq!, and hoist the DXC issue comment above the workaround block where it explains the whole thing. CHANGELOG.md: take the suggested wording, imperative and scoped to all non-2D textures rather than just 3D. cts_runner/test.lst: add the 1D and 3D textureSampleLevel execution selectors, the non-2D dimensionalities whose offset constructor was wrong. Verified locally: sampled_3d_coords 3357 pass / 0 fail, sampled_1d_coords 972 pass / 0 fail. Those ran on Metal, so CI's Windows runner is what actually exercises the HLSL backend this fix touches.
|
384870e covers all of it. The three inline notes: On CTS: added the Worth being precise about what that does and does not show: I am on macOS, so those ran on Metal and cannot exercise the HLSL backend this fix touches. The CI matrix includes Windows x86_64, so landing these selectors is what actually puts the fix under CTS on dx12. The naga snapshot test remains the direct check on the generated HLSL. One thing I found while there and did not touch: Full naga suite: 216 pass, 0 fail, with clippy clean. |
|
Okay, this is looking good. However, I just noticed another problem that means we can't merge the current test coverage. 🫠 CTS test times for
We need to fix this, but I don't want to hold up this fix for that. Let's punt that to another issue/PR where we figure that out: #9974 CC @gfx-rs/wgpu ☝🏻 |
ErichDonGubler
left a comment
There was a problem hiding this comment.
Approving because of removed CTS coverage. Sigh. 🫠

Connections
textureSampleLevelof 3d texture with offset #9717.Summary
The HLSL backend wrapped every image-sampling offset in
int2(...)as a DXC overload-resolution workaround. For atextureSampleLevelcall on other-dimensioned sampled textures, that's the wrong type. For example, with 3D textures, the writer emitted a nestedint2(int3(...))expression, which fails to compile.This makes the constructor follow the offset expression's own dimension, emitting
int,int2, orint3as appropriate, while keeping the explicit-constructor workaround DXC needs.Testing
wgsl-9717-texture-sample-level-offset.hlslsnapshot test that emits checks for all dimensions of texture withtextureSampleLevel.Squash or Rebase?
Rebase.
Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.