Shaders: texture reads at a computed table entry keep their read mark (#2722) #2724
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!2724
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@BastienRodz on GitHub · 2026-11-25 18:50 UTC · original
BastienRodz:shader/computed-table-read-marks→main· +48 −23 · 3 files · 1 commits · openWhat'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
@BastienRodz on GitHub · 2026-11-25 18:55 UTC · original
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.@kotekompotek on GitHub · 2026-11-25 18:58 UTC · original
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.@fuzeofficlal on GitHub · 2026-11-25 19:33 UTC · original
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).@pablogonz12 on GitHub · 2026-11-25 19:41 UTC · original
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.
@oni-swr on GitHub · 2026-11-25 19:41 UTC · original
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).
@BastienRodz on GitHub · 2026-11-25 19:43 UTC · original
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.@passerbyyhx on GitHub · 2026-11-25 20:34 UTC · original
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.
@BastienRodz on GitHub · 2026-11-25 20:36 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 23:20 UTC · original
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
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.