Repository navigation
Shaders: an address with two computed terms is lowered, not refused (#773) - #809
Open
xiepeixuan wants to merge 1 commit into
Open
xiepeixuan wants to merge 1 commit into
xiepeixuan wants to merge 1 commit into
Conversation
xiepeixuan
marked this pull request as ready for review
November 28, 2026 06:38
Dukestar69
approved these changes
Nov 28, 2026
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto main (63b902f).
- Merge & Policy: Clean merge;
cargo xtask policypassed (294 files ok). - Tests:
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).
- Lint & App Check:
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).
MystifiedSky
pushed a commit
to MystifiedSky/VIctory-NVIDIA-Improved
that referenced
this pull request
Nov 28, 2026
|
Tested on top of main: Env: RTX 4080 SUPER (driver 621.01), Ryzen 5 5600X, Windows build 26300, rustc 1.98.1, DXC 1.9.2609.5 ( |
Fix as described by @traeb0n in trustno1-coder#773. Keep code-table and one-term shape restrictions, and exercise emitted offsets with synthetic shaders.
xiepeixuan
force-pushed
the
codex/shader-two-address-terms-773
branch
from
November 28, 2026 23:03
73d9691 to
3b86450
Compare
trustno1-coder
added a commit
that referenced
this pull request
Nov 29, 2026
trustno1-coder
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5CFykxe6G44cMPrmExrcw
trustno1-coder
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X5CFykxe6G44cMPrmExrcw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 d4b5d51; 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.