Repository navigation
Shaders: texture reads at a computed table entry keep their read mark (#2722) - #2724
BastienRodz wants to merge 1 commit into
Conversation
What was wrong: since 2d6c0df only texture views the program takes from the resource heap itself set a read mark; reads through a table set none, because "the host makes table slots for the draw". The host makes only the entries the used-resource list names (`draw::State::tables`: one `table_entry` per entry, the whole range only for tables made afresh). A table read at a computed offset (a descriptor array indexed by data: `s_load_dwordx8` with an SGPR soffset, a per-lane or waterfall load) may reach any slot past those, and a slot there holding a placed texture left null was made by its read mark before 2d6c0df; now nothing makes it and the view reads null for good. What changed: a texture read sets its mark unless its descriptor is a table entry at a fixed offset on every path (`Lower::fixed_table_entry`), the case 2d6c0df meant to skip. Heap-direct reads mark as before. Test: `heap_direct_texture_reads_mark_their_heap_index` gains a table read at a computed entry (soffset from `v_readfirstlane`, shifted by 5); it was not marked before, it is now. The fixed-entry table read still marks nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows run of this head (
|
|
Correct carve-out: the mark is now skipped only for the case 2d6c0df actually 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. |
|
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + Verification (
|
|
AMD/RADV offline check of the head commit (no game run).
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 Not tested in a game run; not tested on NVIDIA. |
|
Independent WARP/CPU verification for head 569aa6a against origin/main 13f91ca. 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). |
|
Thanks, both of you. @pablogonz12, that measurement cuts both ways, and both halves are worth having:
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 2d6c0df for that case only. |
|
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 With the identical fixture and only Reproducer and command against this PR’s branch. Test code and hardware verification assisted by Codex. |
|
Thank you, this is the evidence the PR was missing: the translated shader actually running on hardware and WARP. Entry 0 sets 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. |
|
Automated triage for the maintainers. In This is a recommendation for a maintainer to look, not an approval. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (dxil.dll validator 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).
fuzeofficlal
left a comment
There was a problem hiding this comment.
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.
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. Before 2d6c0df every 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 2d6c0df meant to skip, and the new
Lower::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