Shaders: texture reads at a computed table entry keep their read mark (#2722) #2722
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2724"
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?
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T18:50:45Z.
What's wrong
Since
2d6c0df,Lower::handlenotes a texture read's read mark only when the descriptor comes from the resource heap itself (is_heap_direct). A read through a table sets none, on the grounds that "the host makes table slots for the draw".The host only makes the entries the used-resource list names:
draw::State::tablesmakes onetable_entryper entry, and fresh tables only up to the last listed entry. A table read at a computed entry reaches a slot that may lie past those. Examples are a descriptor array indexed by data,s_load_dwordx8with an SGPRsoffset, or a per-lane or waterfall descriptor load.If that slot holds a placed texture the host left null (
52d14b1), nothing makes it, and the view reads null. Before2d6c0dfevery texture read set its mark, so the slot was made after the first submission that read it.What the fix does
A texture read keeps its mark unless its descriptor is a table entry at a fixed offset on every path. That is the case
2d6c0dfmeant to skip, and the newLower::fixed_table_entrytests it with the existingentry_address. Heap-direct reads mark as before, and fixed-entry table reads still emit no bitmap access. The "Read marks" module note inemit/mod.rsis updated to match.Tests
emit::memory_tests::heap_direct_texture_reads_mark_their_heap_indexgains a table read at a computed entry:v_readfirstlane_b32 s6, v0, thens_lshl_b32 s6, s6, 5as the load'ssoffset.Results, run on Linux with
cargo xwinunder Wine and vkd3d-proton:lower.rschange, the test fails atmemory_tests.rs:703("a read at a computed table entry is marked"). With it, the test passes.emit::memory_testsmodule passes 4/4.victory-shaderlib suite was run one test per process, on this head and with onlylower.rsreverted. The results are identical except for this test: 254 ok, 14 failed, 2 crashed and 3 ignored with the fix.stub_pipeline_is_created, and a few synthetic DPP or gather tests.Not tested
Fixes #2722
No game data. Found and written with AI assistance (Claude Code), reviewed and run locally.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T18:55:22Z.
Windows run of this head (
569aa6a) onwindows-latest, WARP,cargo test --workspace --locked --no-fail-fast -- --test-threads=1: https://github.com/BastienRodz/VIctory/actions/runs/45679288906victory-shaderlib: 270 passed, 0 failed, 3 ignored, includingemit::memory_tests::heap_direct_texture_reads_mark_their_heap_index.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:58:58Z.
Correct carve-out: the mark is now skipped only for the case
2d6c0dfactually meant - a table entry at a fixed offset on every path, which is exactly what the used-resource list enumerates and the host makes. fixed_table_entry via leaves()+entry_address()+root==Table covers descriptor arrays and per-lane loads (whose leaves aren't Loaded-with-fixed-address). The test's SGPR-soffset variant reproduces #2722's shape precisely.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:33:04Z.
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP +
dxil.dllverification and code review of569aa6a(on13f91ca):Verification (
rustc 1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warnings: 0 warnings.VICTORY_WARP=1,dxil.dllactive):cargo test --locked -p victory-shader --lib emit::memory_tests-> 4 passed, 0 failed (including updatedheap_direct_texture_reads_mark_their_heap_index).root_views_read_their_copy_and_zeros_past_it,title_memory_is_read_and_written_at_computed_addresses, andwrites_through_views_mark_their_pagesall pass (heap_direct_texture_reads_mark_their_heap_indexhits the pre-existing13f91caNVIDIA0xc0000005crash from #2571).victory-gpu: 198 passed, 0 failed, 1 ignored.Review & Merge-Ordering Notes
is_heap_direct(src)with!fixed_table_entry(src)cleanly preservesVIEW_READSmarks for computed table entries (dynamicsoffset, waterfall, or mixedPhi/Selectleaves) while still skipping fixedUsedResourcetable slots;heap_index/fetched_indexhandleRootType::Tableoffsets accurately.12fdbc9e):git merge-treemergescrates/victory-shader/src/emit/lower.rscleanly with zero conflicts so computed table-entry read marks automatically inherit #2668's per-laneEXECguard (onlymemory_tests.rshas a small conflict aroundlower_withinheap_direct_texture_reads_mark_their_heap_index).Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-25T19:41:13Z.
AMD/RADV offline check of the head commit (no game run).
origin/main13f91caee.victory-shader --example retranslate, then dxil-spirv (master),spirv-val --target-env vulkan1.3, and a realvkCreateCompute/GraphicsPipelineson RADV (vkpipe, one process per program, so a driver crash or hang is recorded per program rather than stopping the batch).Result, base
13f91caeevs head569aa6ad5: both translate 749 / 751 (the same 2 refused in both:a lane mask read as data is not supported). 0 of the 751 programs' DXIL bytes change, and no pipeline result or time differs.So the dump set does not exercise the path this PR changes (none of these 751 world shaders reads a texture through a computed table entry with a read mark to keep), which means the offline check can neither confirm nor refute the fix — the unit test in the branch is the only evidence, and
victory-shader's test target does not build on Linux (its tests use the Windows validator module), so I could not run it here. No objection from this side; a Windows/WARP CI run plus that test is what should decide.Not tested in a game run; not tested on NVIDIA.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T19:41:33Z.
Independent WARP/CPU verification for head
569aa6ad51against origin/main13f91caee2. State check: open, non-draft, clean merge-tree; no oni-swr comment found.Environment: Windows x64, Rust 1.98.1 (48a229cea 2026-09-01), Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11); WARP/D3D12 WARP env vars set; CARGO_TARGET_DIR=D:\victory-warp-2720-target.
Commands/results:
Review: no additional correctness issue found in the changed fixed-table-entry carve-out.
Not tested: physical GPU, retail title/game behavior, release build. AI disclosure: Codex (gpt-6-luna).
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T19:43:01Z.
Thanks, both of you.
@pablogonz12, that measurement cuts both ways, and both halves are worth having:
2d6c0dfwas about not loading the bitmap word after every table read, and that saving is fully kept: no extra bitmap access in any of the 751.What the PR guards is the case 2d6c0df's message rules out ("a view read through a table cannot be a slot left null"), which a descriptor array read at a computed table entry still hits. It goes back to the marking main did before
2d6c0dffor that case only.Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-25T20:34:08Z.
I ran the computed-entry shader itself on a GeForce RTX 4090 Laptop GPU (621.14) and on Microsoft WARP. Both adapters gave identical readbacks. With the same computed PSO and the table starting at slot 2, entry 0 read red and set only
VIEW_READS + 2. Entry 1 read blue and set onlyVIEW_READS + 3. Keeping entry 1 and moving the table base to slot 1 gave red andVIEW_READS + 2. The fixed-entry shader read the correct color with no read marks. A zero-group dispatch left both outputs clear.With the identical fixture and only
lower.rsrestored from13f91ca, all colors stayed correct on both adapters but every computed-entry read mark was missing. The test failed on the first expected bit. This verifies executed shader marking. Runtime materialization and game workloads were outside the test.Reproducer and command against this PR’s branch. Test code and hardware verification assisted by Codex.
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T20:36:21Z.
Thank you, this is the evidence the PR was missing: the translated shader actually running on hardware and WARP. Entry 0 sets
VIEW_READS + 2, entry 1 sets+ 3, moving the base moves the bit, and the fixed entry sets none. With onlylower.rsreverted, the colors stay right and the computed-entry marks are gone.I'll keep this PR at its current size (+48/−23, with the lowering-level test). Your readback test is +212 lines in a new module, so it reviews better on its own or as a follow-up. It is linked here for the maintainer either way. If they'd rather have it in this PR, I'll merge your fork PR with your authorship kept.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:20:20Z.
Automated triage for the maintainers.
In
crates/victory-shader/src/emit/lower.rsLower::handle, a texture read now skips its read mark only when every leaf of the descriptor is a table entry at a fixed offset (fixed_table_entry, using the existingentry_address). Before, it was marked only when heap-direct (is_heap_direct). I checked the premise againstmain:draw::State::tables/table_entryincrates/victory-gpu/src/draw.rsmake only the entries named in the used-resource list, so a descriptor array read at a computed table entry can reach a slot left null that nothing would ever make. Fixed-entry table reads still emit no bitmap access. The extendedheap_direct_texture_reads_mark_their_heap_indextest covers the computed case, and a reviewer's hardware/WARP readback confirmed the marks land on the right bits. CI (check) passes. Note that this and #2668 edit the same test, so whichever lands second needs a small rebase.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:21:55Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (dxil.dllvalidator active):VICTORY_WARP=1 cargo test -p victory-shader --lib emit::memory_tests: 5 passed, 0 failed (includingheap_direct_texture_reads_mark_their_heap_indexwith the computed table entry case; WARP used due to pre-existing#2571on NVIDIA hardware).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:32:01Z.
Review: APPROVED
LGTM — verified locally at
569aa6ad:fixed_table_entry(crates/victory-shader/src/emit/lower.rs:5588) accurately distinguishes fixed root-table entries (entry_address(*load)withRootType::Table) from computed-offset table loads, waterfalls,Source::Built, and heap/dynamic paths, ensuring computed-table texture reads emitview_marksread bits while fixed-table reads stay unmarked.cargo xtask policy(191 files ok),cargo clippy --all-targets --all-features(0 warnings), andrustfmt --check --edition 2024(0 new diffs overHEAD) all pass.emit::memory_testspasses 5/5 on WARP (VICTORY_WARP=1) and 4/5 on RTX 5090 (excluding the pre-existing baseline access violation inheap_direct_texture_reads_mark_their_heap_index); an isolated runtime probe of the computed-tableimage_loadcase also passesdxil.dllvalidation, RTX 5090, and WARP with the expectedVIEW_READS + 2bit set.Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-27T17:13:32Z.
I repeated an offline pipeline check on head
569aa6adwith an RX 9070 XT / RADV. Of 751 programs, 730 reached successful pipeline creation, 18 failed SPIR-V validation, one failed DXIL-to-SPIR-V conversion, and two failed translation. This run does not execute the shaders or establish whether the computed-table read-mark path works; it also has no matching baseline for a regression comparison. Not tested on NVIDIA hardware.Imported from Marvisak/VIctory. Originally posted by dux14 on 2026-11-29T06:14:21Z.
#2724 is the better fix:
fixed_table_entry(lower.rs:5349) keeps the skip only when every leaf is a fixed-offset table entry, so any other shape (computed offset, waterfall, built source) is marked by default. #2822'smarks_its_readsinstead lists the computed shapes it knows (Loaded/Fetched leaf withdynamicor waterfall), so other non-fixed shapes stay unmarked, and it conflicts with main in memory_tests.rs. Both compile on the msvc cross-check; the lowering tests were not run on my side (dxil/Windows only). Neither covers the case where both phi inputs are fixed table entries, as the comparison in #2722 shows.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.