Shaders: test that an image read as float and used by an atomic is annotated twice #226

Closed
github-bot wants to merge 2 commits from gh-pr/226/head into gh-pr/226/base
Owner

@⁠gingertonik on GitHub · 2026-11-24 01:37 UTC · original
gingertonik:test/image-atomic-annotation → main · +107 −2 · 2 files · 2 commits · closed without merging

Stacked on #177 (its commit e55eb69 is the first commit here). This adds only the test that PR was noted to lack; once #177 merges, the diff is the test alone.

What

A synthetic compute program in emit::lower::tests, in the style of the existing ones: it loads a 2D image UAV from a descriptor table as four float channels (image_load) and then runs image_atomic_umin on the same image in the same block. The test asserts that the image is annotated twice: (0x1002, 0x409) for the load and (0x1002, 0x105) for the atomic.

To let the test read the annotations, test builds record each annotation's two property words in Shader and hand them out through Lowered (#[cfg(test)] fields; nothing changes in a normal build).

Why

#177 fixes the heap-handle cache handing an atomic the float handle of an earlier load. The expected values come from DXIL's resource properties, not from the code under test: word 0 is the resource kind (Texture2D = 2) with the UAV bit (0x1000); word 1 carries the component type in its low byte (U32 = 5, F32 = 9 in DxilConstants.h's ComponentType) and the component count above it. D3D12 allows the Interlocked operations on integer UAVs only, so the atomic's annotation has to be the one-u32 form.

Tested

Linux x86_64, pinned toolchain, from the repository root:

  • On d2a4bae (without #177) the test fails: the atomic's annotation: [(d, ffffffff), (1002, 409)]. The load's annotation is present and the atomic's is missing.
  • On #177's e55eb69 it passes. cargo test -p victory-shader: 57 passed, 0 failed.
  • With #177's key edited back to ignore the second word, it fails again with the same message.
  • cargo fmt --all -- --check: no differences in victory-shader. cargo clippy -p victory-shader --tests: only the existing constant_color dead-code warning on Linux.
  • cargo xtask policy: 151 files ok. Windows MSVC release cross-build (xwin SDK, lld-link): clean.

Synthetic words only; no game data.

AI-assisted (Hermes).

**@⁠gingertonik** on GitHub · 2026-11-24 01:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/226) `gingertonik:test/image-atomic-annotation` → `main` · +107 −2 · 2 files · 2 commits · closed without merging Stacked on #177 (its commit `e55eb69` is the first commit here). This adds only the test that PR was noted to lack; once #177 merges, the diff is the test alone. ## What A synthetic compute program in `emit::lower::tests`, in the style of the existing ones: it loads a 2D image UAV from a descriptor table as four float channels (`image_load`) and then runs `image_atomic_umin` on the same image in the same block. The test asserts that the image is annotated twice: `(0x1002, 0x409)` for the load and `(0x1002, 0x105)` for the atomic. To let the test read the annotations, test builds record each annotation's two property words in `Shader` and hand them out through `Lowered` (`#[cfg(test)]` fields; nothing changes in a normal build). ## Why #177 fixes the heap-handle cache handing an atomic the float handle of an earlier load. The expected values come from DXIL's resource properties, not from the code under test: word 0 is the resource kind (Texture2D = 2) with the UAV bit (0x1000); word 1 carries the component type in its low byte (`U32` = 5, `F32` = 9 in `DxilConstants.h`'s `ComponentType`) and the component count above it. D3D12 allows the Interlocked operations on integer UAVs only, so the atomic's annotation has to be the one-`u32` form. ## Tested Linux x86_64, pinned toolchain, from the repository root: - On `d2a4bae` (without #177) the test fails: `the atomic's annotation: [(d, ffffffff), (1002, 409)]`. The load's annotation is present and the atomic's is missing. - On #177's `e55eb69` it passes. `cargo test -p victory-shader`: 57 passed, 0 failed. - With #177's key edited back to ignore the second word, it fails again with the same message. - `cargo fmt --all -- --check`: no differences in `victory-shader`. `cargo clippy -p victory-shader --tests`: only the existing `constant_color` dead-code warning on Linux. - `cargo xtask policy`: 151 files ok. Windows MSVC release cross-build (xwin SDK, `lld-link`): clean. Synthetic words only; no game data. AI-assisted (Hermes).
A texture UAV read as float and used atomically in the same program got
the float handle for its atomic: dxil-spirv then emitted OpAtomicOr on a
float texel pointer (invalid SPIR-V), and the NVIDIA compiler crashed in
vkCreateComputePipelines when GTA VI entered its world (two programs:
c12c1f7296419a5b, 8358f9eef7931421). With the type in the key the atomic
gets its own uint handle; all dumped SPIR-V validates.
A synthetic compute program loads a 2D image UAV as four floats and then
runs image_atomic_umin on it in the same block. The atomic must get its
own one-U32 annotation next to the load's four-float one. Test builds
record each annotation's property words so the test can read them.

Fails on the handle cache keyed on the first property word only; passes
with the element type in the key.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:32 +00:00
github-bot closed this pull request 2026-11-26 03:55:32 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:24 UTC · original

Thanks @⁠gingertonik for adding a focused regression case for the two resource annotations emitted from one image.

I tested commit 6e01ea031553e1bd19b37ffae5cc2facaa18920b with:

cargo test --locked -p victory-shader --lib an_image_read_as_float_and_by_an_atomic_is_annotated_twice -- --test-threads=1

The targeted test passed (1 passed, 0 failed; 69 filtered). an_image_read_as_float_and_by_an_atomic_is_annotated_twice lowers a synthetic compute shader that loads four float channels from a 2D UAV and then performs an unsigned atomic minimum. It asserts both annotations are emitted: the four-component F32 resource for the load and a separate one-component U32 resource for the atomic.

This validates shader IR lowering and annotation generation; it does not compile or execute the shader on a GPU.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/226#issuecomment-7122917190) Thanks @⁠gingertonik for adding a focused regression case for the two resource annotations emitted from one image. I tested commit `6e01ea031553e1bd19b37ffae5cc2facaa18920b` with: ``` cargo test --locked -p victory-shader --lib an_image_read_as_float_and_by_an_atomic_is_annotated_twice -- --test-threads=1 ``` The targeted test passed (1 passed, 0 failed; 69 filtered). [`an_image_read_as_float_and_by_an_atomic_is_annotated_twice`](https://github.com/Marvisak/VIctory/blob/6e01ea031553e1bd19b37ffae5cc2facaa18920b/crates/victory-shader/src/emit/lower.rs#L6671) lowers a synthetic compute shader that loads four float channels from a 2D UAV and then performs an unsigned atomic minimum. It asserts both annotations are emitted: the four-component F32 resource for the load and a separate one-component U32 resource for the atomic. This validates shader IR lowering and annotation generation; it does not compile or execute the shader on a GPU.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:00 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #177.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/226#issuecomment-7148040365) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #177. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!226
No description provided.