Skip to content

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

Closed
gingertonik wants to merge 2 commits into
Marvisak:mainfrom
gingertonik:test/image-atomic-annotation
Closed

gingertonik wants to merge 2 commits into
Marvisak:mainfrom
gingertonik:test/image-atomic-annotation

Conversation

@gingertonik

Copy link
Copy Markdown

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:

Synthetic words only; no game data.

AI-assisted (Hermes).

Ortomanic and others added 2 commits November 24, 2026 02:06
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.
…notated twice

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.
AntoninMichelq pushed a commit to AntoninMichelq/VIctory that referenced this pull request Nov 24, 2026
…used by an atomic is annotated twice) into the integration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
@upipibi upipibi mentioned this pull request Nov 24, 2026
@jeremygold02

Copy link
Copy Markdown
Contributor

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.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…rol flow; waterfall loops proven)

Marvisak#566 is stacked on Marvisak#307, which this tree holds as its first two commits
(the tree's resource.rs was identical to ffa6635's). The merge so also
brings Marvisak#307's last two commits, 077ec8b and 6285e19. Git found upstream
main as the base, which sets Marvisak#307's own lines against themselves; each
file was merged with ffa6635 as the base instead.

- crates/victory-shader/src/resource.rs: Marvisak#566's, unchanged (the tree had
  no edits of its own there).
- crates/victory-shader/src/emit/lower.rs: no conflict on that base. The
  tree's lowering is kept (Marvisak#307's waterfall arm of v_readfirstlane before
  the console-flow form, fetched_index through Marvisak#483's heap guard), with
  Marvisak#566's Source::LanePhi arms and tests. lane_heap_index joins the
  indices heap_index and fetched_index return, so each is already
  guarded. Marvisak#226's annotation test passes the per-lane form to track.
- crates/victory-shader/src/structure.rs: both sides' additions kept:
  MAX_MEMO (Marvisak#288) with MAX_MEET, and in Structured the wave64 stack's
  execs, others and pairs with Marvisak#566's reach and paired_masks.
  paired_masks is filled last, since it takes the masks pairs reads.
- crates/victory-shader/src/emit/mod.rs: translate keeps Marvisak#309's spill
  forwarding and Marvisak#223's target, structures first and passes the per-lane
  form to track as Marvisak#566 does. The threading retry of emit passes its
  own. The tests' helpers (Marvisak#223's, Marvisak#306's, Marvisak#459's, Marvisak#48's) pass it too.
- apps/victory/src/translate.rs: Marvisak#566's arm (Source::LanePhi is no
  leaf); the tree's fix already counted Fetched as loaded, as 077ec8b
  does.
- docs/architecture.md: no conflict on that base; Marvisak#566's text.
- emit/image_tests.rs (Marvisak#160), emit/lane_read_loop_tests.rs (Marvisak#439),
  sgpr_spill.rs (Marvisak#309, Marvisak#320): track takes the per-lane form. Helpers
  that return the error keep the order of failures (resources, I/O,
  then structure).
- emit/waterfall_tests.rs (new, Marvisak#566): lower::Parts gets the tree's
  target, console_cf and per_lane_only; the dispatch fills Marvisak#483's guard
  dwords.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
…isak#306 Marvisak#333 Marvisak#105 Marvisak#288 Marvisak#343 Marvisak#353 Marvisak#326 Marvisak#259 Marvisak#179 Marvisak#176 Marvisak#226 Marvisak#286)

Conflicts:
- emit/lower.rs: shader-opcodes and shader-tracking each keyed heap
  handles by the resource properties (a tuple vs two flattened words);
  the same key, shader-tracking's form and comment kept. Lowered's
  test-only fields, test imports and tests of both sides kept.
- emit/wave.rs: tests of both sides kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Marvisak

Copy link
Copy Markdown
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants