Shaders: propagate written heap UAVs and mark glc UAV handles globally coherent #1271
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1271
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1271"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@fuzeofficlal on GitHub · 2026-11-24 16:58 UTC · original
fuzeofficlal:fix/shader-uav-globally-coherent-725→main· +667 −36 · 4 files · 1 commits · openFixes #724.
Part of #725.
Summary
#724): Pre-scanRole::Resourcedescriptor leaves by tracked(param, offset + 4 * first, dynamic)address (written_uavs) so any heap descriptor accessed with astoreoratomicoperation lowers consistently as a UAV across vector loads, scalars_buffer_load_dword*,descriptor_data, and separate reloads of the same heap address. Read-only heap descriptors (includingglc-only reads without stores or atomics) remain SRVs.IsGloballyCoherent(0x4000) onglcUAV handles (#725): Set0x1000 | 0x4000indx.types.ResourcePropertiesword 0 wheneveruav && cache.glcacrossbuffer(raw, structured, typed),image(image_load,image_store,image_atomic_*), andsmem(s_buffer_load_dword*).Verification
emit::lower::tests::heap_uav_inference_and_glc_coherence_set_handle_propertiesandglc_only_heap_reads_stay_srv_and_table_uavs_are_globally_coherent(dxil.dllvalidated): verify written-UAV reload propagation,0x500B/0x500C/0x500A/0x5002IsGloballyCoherenthandle properties, and that read-onlyglcheap descriptors stay SRVs (0x000B/0x0002).emit::valu_tests::glc_heap_uav_loads_stores_and_atomics_execute_on_gpu: multi-group ([2, 1, 1]) synthetic compute readback on NVIDIA GeForce RTX 5090 and D3D12 WARP.cargo clippy -p victory-shader --tests --locked -- -D warningsandcargo xtask policy: passed.@pablogonz12 on GitHub · 2026-11-24 17:27 UTC · original
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you handle, so this is a no-regression result only (same 10 SPIR-V validation failures as the base).
Not tested: in-game.
@wildheathen on GitHub · 2026-11-24 18:19 UTC · original
#1271 and #1354 compared: same output on a retail dump, small differences in scope
Both PRs fix #724 and #725 (heap UAV inference,
IsGloballyCoherentonglcUAV access) and both are based on mainffe310e. I'm not the author of either. I measured them the same way so review can pick one.Setup: Windows 11, RTX 5080 (driver 32.0.16.2124), Rust 1.98.1 MSVC, dxil.dll 10.0.26100. Offline translation only (no title run, no world).
Retail dump (
victory translate --validate --list, plusVICTORY_EMIT_DUMPto keep every emitted shader)ffe310edxc -dumpbin): 0 → 310 handles withIsGloballyCoherent(0x4000); 1,306 → 1,474 handles withIsUAV(0x1000), i.e. 168 SRV handles become UAVs; barrier counts unchanged.Tests
cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean on both.cargo test -p victory-shader -p victory-gpu: main 170 passed; #1271 173; #1354 173 (0 failed, 2 ignored each).glc_heap_uav_loads_stores_and_atomics_execute_on_gpuon the GPU): 5 of 5 pass.Differences the dump doesn't show
None of these changes a program in this title. They matter only for code the dump doesn't contain.
glcaccesses count. #1271 infers a UAV fromglcon untyped buffer access,image_load/stores/atomics without a sampler, ands_buffer_load*, and drops any address that is also sampled. #1354 takesglcfrom any buffer, image or SMEM instruction, unless a used-resource entry declares the view SRV or CBV. So aglctyped-buffer load, or a sample withglcon an undeclared heap descriptor, would make a UAV in #1354 and not in #1271.glc) when deciding whether a computes_barriergets the global UAV fence. #1354 leaves that decision as it is on main. In the dump every changed program already had the global fence, so the output is the same. A compute program that only spin-waits on aglcheap load, with no declared UAV, would get the fence from #1271 only.used_kindout to a free function, and its tests are DXIL-only.Taken together: on this title either one gives the same shaders. #1271 was opened first, covers the barrier case and has a hardware test. #1354's refactor of
used_kindis neutral. Merging one and closing the other seems the cleanest; whatever #1354 has that #1271 lacks (typed-bufferglc) can be a follow-up if a title needs it.No game data, shader bytes or shader names are included here; counts come from a local dump. I haven't run either in the world yet. If useful, I can run the
9ef9a9d818b27236loop-hang A/B from #725 on the 5080.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 01:20 UTC · original · edited 2026-11-26 00:25 UTC
Automated triage for the maintainers.
Merge candidate. The written-UAV propagation (
written_uavs/Lower::is_uav) andIsGloballyCoherentonglcUAV handles (uav_bits) incrates/victory-shader/src/emit/lower.rsare unchanged from the head judged sound before. The second-look point is fixed:Shader::heap_handle(emit/shader.rs) now recordstexture_indexfor texture kinds 1-9 whether or not IsUAV is set, andLower::imagesets read marks only for instructions that are notimage_store*/image_atomic_*. As a result, a heap-directimage_loadof a written descriptor keeps its read mark, and a texture that is only stored gets none.heap_direct_image_load_and_store_keeps_view_read_marksin the newemit/lower/glc_tests.rscovers both cases.On your reply: confirmed. The branch merges cleanly with current
main, and with this PR mergedemit/lower.rsis 523,001 bytes, under the 524,288-byte limit inxtask/src/policy.rs. The margin is only about 1.3 KB. #1540 and #1315 also grow this file, so whichever of them lands second will needlower.rssplit first. That is a note for ordering, not a blocker for this PR. A blank line was left before the closing}ofmod tests. It is cosmetic.CI: passing (
check).Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 09:50 UTC · original
Updated in
1db404e0per triage feedback:glc_uavsrule so untyped heap descriptors that are only read withglc(never stored to or used atomically) stay SRVs instead of risking an SRV/UAV descriptor mismatch at runtime (deferred to a separate follow-up once runtime view evidence is available; updated PR link fromFixes #725toPart of #725).written_uavspropagation across reloads of heap descriptors with stores/atomics (#724) andIsGloballyCoherent(0x4000) on UAV handles accessed withglc.glc-only heap test (glc_only_heap_reads_stay_srv_and_table_uavs_are_globally_coherent) to assert that read-onlybuffer_load_dword glc,s_buffer_load_dword glc, andimage_load glcheap handles remain SRVs.@Marvisak on GitHub · 2026-11-25 22:01 UTC · original
Automated triage for the maintainers, second look (a review against
main, with the PR built and tested).This is right (written heap UAVs are propagated, and
glchandles are marked globally coherent). The review was of 1db404e0; at the current head the test expectation is already the onemainneeds. One change is still needed before it can be merged: heap-direct texture loads that now get a UAV handle lose the read markmaingives them (in a probe,view_markswas true onmainand false with this PR). InShader::heap_handle(emit/shader.rs), notetexture_indexfor texture kinds 1-9 whatever the IsUAV bit, or push the mark for UAV texture handles inLower::image's load path, and add a test that a heap-directimage_loadplusimage_storeof one descriptor still setsview_marks.Two more things to know. It conflicts with
mainagain inemit/valu_tests.rsafter today's merges. Andemit/lower.rsis now within a few kilobytes of the repository's 512 KiB file limit (cargo xtask policy), while this PR adds about 12 KB to it, so it can only land once that file has been split.Push the change and it will be reviewed again. Thank you for the contribution.
@fuzeofficlal on GitHub · 2026-11-25 22:35 UTC · original
Updated and rebased onto
main(f3578e3) in0dc4320per second-look feedback:Shader::heap_handle(emit/shader.rs) now recordstexture_indexfor all texture kinds1..=9regardless ofIsUAV, andLower::image(emit/lower.rs) emits read marks for non-store/non-atomic texture operations so heap-directimage_loadon a descriptor that is also stored keepsview_marks = truewhile store-only texture UAVs keepview_marks = false.heap_direct_image_load_and_store_keeps_view_read_marksinemit/lower/glc_tests.rscovering both the load+store (view_marks == true) and store-only (view_marks == false) heap-direct 2D cases with DXIL validation.crates/victory-shader/src/emit/lower/glc_tests.rssoemit/lower.rsstays under the 512 KiB policy cap (523,001bytes;cargo xtask policy: 191 files ok).emit::lower::glc_tests(3/3),--features host glc(4/4 on RTX 5090 + WARP), andcargo clippy -p victory-shader --all-targets -- -D warnings(0 warnings).@catminou4 on GitHub · 2026-11-24 17:06 UTC · original · approved these changes
Heap UAV inference: descriptors written/atomically-modified or accessed with glc (and never sampled) get UAV_PROP, glc ones also GLOBALLY_COHERENT_PROP; sampled descriptors are excluded, image glc counts for stores and image_load only. Same family as #1055/#1015 (descriptor-kind inference) — the three touch neighboring hunks in lower.rs, so merge order will need rebases. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 98 passed, 0 failed (2 lowering tests on macOS; the glc load/store/atomic execution test is Windows-gated).@andrewpozdnakov7-jpg on GitHub · 2026-11-26 14:04 UTC · original
I independently verified
0dc4320combined with current upstream63bcca4. For the baseline I added the same three test bodies and the test-only heap-property recorder tomain.view_marks. A store-only texture stays free of read marks.The tests used synthetic shaders and verified the read-mark case on the current tree.
AI-assisted with Codex.
@Dukestar69 on GitHub · 2026-11-26 19:30 UTC · original · approved these changes
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).glcUAV handles globally coherent (while keepingglc-only heap reads as SRVs and preserving view read marks) validates cleanly and executes accurately on both discrete NVIDIA hardware and WARP.cargo test -p victory-shader --lib emit::lower::glc_tests:: -- --test-threads=1: 3 passed, 0 failed.cargo test -p victory-shader --lib emit::valu_tests::glc_heap_uav_loads_stores_and_atomics_execute_on_gpu -- --test-threads=1: passed on RTX 5090 andVICTORY_WARP=1.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.