Shaders: an address with two computed terms is lowered, not refused (#773) #809
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/809"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by xiepeixuan on 2026-11-28T06:34:42Z.
Fixes #773
What it changes
A load was refused when its tracked base had a computed index and its scalar or VGPR offset was also computed. The run in #773 reported about 913 refused shader hashes and 200–270 dropped draws per frame.
Fix as described by @traeb0n in #773
The tracer now keeps the computed base index and the computed instruction offset separately, and lowering adds both to the static byte offset. PC-relative tables and shortcuts that prove a single computed term keep their existing restrictions.
Rebased on
d4b5d517; the only conflict was in emit/lower.rs (kept main's new tests next to this PR's test hook). The new Address uses on main (emit/lds.rs, wave64_tests.rs) need no change.Workspace audit
dynamic2is present only whendynamicis present. I found three direct arithmetic consumers ofAddress::dynamic, all in lowering; heap indexing is arithmetic on the original instruction operands, not on those fields.resource.rs:Address,Source::Built,Resources::scalar,trackresource.rs:Tracer::address,flat_address,smem_address,by_address,classify, test helperatSumstill represents one input expression; its.dynamicreads (including base diagnosis and the PC-join recognizer) are notAddressreads. Thes_getpc_b64path still refuses two terms,MEMORYand static test addresses have neither, and classification of a built descriptor passes no extra term.resource.rs:root_indexed_view,first_lane_offset,fetched(param, dynamic, dynamic2)as well as line up at their byte offsets.resource.rs:anywhere(BuiltandLoaded) andlane_copiesdynamic.is_none()for the constant-address shortcuts; that excludesdynamic2. Lane-copy equality also sees both terms. Existing single-term and static test assertions retain their original meaning.emit/lower.rs:flat,code_smem,built_offsetflatadds both byte terms.code_smemkeeps the single-term code-table arithmetic and explicitly refuses a second term.built_offsetadds both terms and then any root-view bias;smemandbufferconsume the combined result once.emit/lower.rs:heap_index,fetched_index,lane_heap_indexsoffset; the fetched path uses its SGPR/VGPR address operands and immediate. Both shift the resulting byte address for the descriptor size.Addressis used for the root-kind check only; the lane dispatcher combines these real indices.emit/lower.rs:entry,sized_view,view_address,descriptor_datadescriptor_datacompares whole addresses for equivalent loads; its static lane-copy branch is guarded by the tracer’s proof.emit/lower.rs:code_dword,smemandflatdispatch,memory_smem,memory_flatcode_dwordfinds the start of the code table from the static offsets; the code-table path still cannot carry two terms.CODE/MEMORYchecks select the lowering route, and raw-memory lowering reconstructs the address from the real operands.emit/lower.rs:used_kind,root_address,root_memory,handle,raw_twin,slot_wordused_kinduses the existing static table-range anchor, not the run-time index. Root-memory lowering receives the already-combined offset; heap handles, twins and slot words use operand-derived indices.apps/victory/src/translate.rs:tally_resources(scalar andBuilt).dynamicuses count dynamic addresses, not terms, so the invariant makes the old predicates correct. I changed the root-layout lookup to skip both sentinels: an accepted two-computation load with no traced base can useMEMORYand still be classified as a descriptor source before lowering.victory-gpu/src/picked.rs:stores_picked; downstreamRootIndexedViewconsumersRootIndexedViewonly after the one-term guard. Other workspaceAddressnames and.dynamicfields (descriptor allocation and tally counters) are unrelated.How it was tested
mainatd4b5d517: Linux 249 passed and Windows 348 passed, zero failures.3b864508: Linux 255 passed and Windows 354 passed, zero failures. The ignored counts stayed at two on Linux and eight on Windows.cargo testpassed for the crates it touches: Yes —cargo test -p victory-shader --lib(Linux, Windows). Windowscargo check --workspace --lockedalso passed.The six synthetic cases check the scalar table index, the global root-SRV byte offset, PC-relative refusal, both one-term shape guards, and raw-memory fallback. The offset tests evaluate emitted operands with known user-data inputs. Full CI hit the same two Clippy diagnostics in
lower.rsas plain main.Checked for overlap
AI-assisted (Codex). Not run in the game here. Unit-tested in victory-shader.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T07:08:28Z.
Review: APPROVED
Tested locally merged onto
main(63b902f).cargo xtask policypassed (294 files ok).cargo test -p victory-shader --lib emit::lower::tests::passed (17 passed; 0 failed; 1 ignored, includingglobal_load_adds_the_root_view_index_and_computed_vgpr_offsetandscalar_table_load_uses_the_base_index_and_computed_soffset).cargo test -p victory-shader --lib emit::tests::passed (22 passed; 0 failed; 1 ignored).cargo test -p victory-shader --lib resource::passed (42 passed; 0 failed, includinga_pc_relative_address_still_refuses_two_computed_termsanda_first_lane_offset_does_not_prove_a_two_term_address).cargo clippy -p victory-shader --lib -- -D warningspassed with 0 warnings;cargo check -p victory --testssucceeded cleanly.Solid generalization of two-term computed address lowering while preserving the strict PC-relative and first-lane guards. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jptorres96 on 2026-11-28T09:16:12Z.
Tested on top of main:
cargo test -p victory-shader --lib→ 299 passed, 0 failed, 5 ignored. No regressions.Env: RTX 4080 SUPER (driver 621.01), Ryzen 5 5600X, Windows build 26300, rustc 1.98.1, DXC 1.9.2609.5 (
VICTORY_DXIL),--test-threads=1.VICTORY_INDIRECT_REST=1set to sidestep main's two indirect budget-test failures (fixed in #67), unrelated to this PR.