Repository navigation
Shaders: lower untracked v_cndmask_b32/carry-in masks via lane_bit and descriptor-only GetDimensions - #585
Shaders: lower untracked v_cndmask_b32/carry-in masks via lane_bit and descriptor-only GetDimensions#585FibbS6 wants to merge 2 commits into
Conversation
…VALU ops via lane_bit
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Tested and verified on Windows 11 x64 (D3D12 WARP + Hardware).
- Confirmed mask_cond correctly handles inline constants (Operand::Const(128) as false, Operand::Const(193) as true), tracked masks from structure, and untracked scalar register masks via lane_bit (handling wave64 low/high dword pairs).
- Confirmed descriptor-only GetDimensions queries fallback to native UsedResource metadata when no instruction uses the loaded descriptor as an image/buffer view directly.
- cargo test -p victory-shader: 69 passed, 0 failed.
- cargo clippy -p victory-shader --lib -- -D warnings: 0 warnings.
- cargo xtask policy: 151 files clean.
|
Tested offline against main
AI-assisted. |
|
Measured on the full retail shader pack (26,503 containers) with
|
|
I tested the mask-operand change from Small integration fix and synthetic regressions: Hiiva@e3da6a2 The new CPU test fails before the fix because SFI0 contains This is a portability/metadata correction, not evidence that the extra flag caused a title crash. I tested the mask change only; the descriptor-only GetDimensions commit is not included in this branch. |
|
Independent test on RDNA4: this PR alone, on Method: count unique
So on this title it removes 439 of 472 refusals here, and both mask reasons disappear from the log entirely. Remaining reasons with this PR: The run itself: world at ~1 fps, 150 draws/frame, 13 black-frame warnings, no device removal in 300 s. Before this PR A later control run on Stacking this PR with #660 gives the same 33, i.e. no further gain here; #660 alone has not produced a world run on this host yet (its first run stayed in the front end), so I will not claim anything about it. Not tested: No game data: counts, shader hashes, driver version and error strings only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine. |
catminou4
left a comment
There was a problem hiding this comment.
Test-merge with current main (ffe310e) is clean and cargo test -p victory-shader --locked passes (macOS arm64, rustc 1.98.1) → 96 passed / 0 failed / 1 ignored — but note this PR adds no new tests, so the new paths are not covered by what I ran. Two points I'd like confirmed before approval:
-
Literal mask mapping (
mask_cond):Operand::Const(128) → false,Operand::Const(193) → true. Where do 128/193 come from — the SP3 disassembly or the bitcode literal encoding? A one-line comment or a test pinning the mapping would make this auditable. (The wave64 hi-pair readReg::S(code + 1)withNone → 0fallback also deserves a mention: silent zero for a missing hi dword.) -
Descriptor fallback for data-only reads: when
use_atisNone, anyused_kindSRV/UAV withdwords != 4is reconstructed as(2 | u, 0x409), Some(2)— i.e. assumed to be an image of kind 2. If a non-4-dword buffer descriptor can reach this path, it would be misclassified as an image. Isdwords == 4guaranteed for buffers, or should the fallback error instead of guessing?
The mask_cond direction (tracked mask → inline consts → lane bit test via lane_bit with flags::WAVE_OPS) and the untracked-mask pre-scan for v_cndmask_b32/*_co_ci_u32 look right; the carry-in swap fix (std::mem::swap before select) matches the subrev semantics.
mercuryVM
left a comment
There was a problem hiding this comment.
Tested f800f1c on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 69 passed, and cargo clippy -p victory-shader --all-targets is clean. victory translate --validate --pipelines on the local title executable reports the same 12 of 12 as main, so neither new path fires in those programs. The PR adds no tests.
mask_cond looks right: inline 0/-1, tracked masks first, then lane_bit of the SGPR pair under console_lanes, with WAVE_OPS set. One concern on the second half:
lower.rs(descriptor-onlyGetDimensions, theuse_at == Nonebranch): when no instruction consumes the descriptor, every image descriptor is annotated as(2 | u, 0x409), i.e. Texture2D, whatever the title'sUsedResourcesays. A 1D, 2D-array, 3D or cube view then getsGetDimensionsfrom a handle annotated as 2D. On D3D12 a handle annotated with the wrong dimension is undefined, which is exactly the class of mismatch #581 is chasing on NVIDIA. Please derive the dimension fromused(it records the view type for table descriptors), or keep refusing when it can't be known.- A synthetic test for each new path, an untracked
v_cndmask_b32mask underconsole_lanesand a descriptor read only bys_buffer_loadfor dimensions, would pin the behaviour. Today nothing in the suite reaches either branch.
AI-assisted (Claude Code).
|
Correction to my earlier comment - the in-game number I quoted is not a valid measure of this PR, and I withdraw it. I re-measured offline with
So this PR emits 21 more vertex/pixel programs and 4 more compute programs, and no change in mesh. That is a real, positive delta. The "472 -> 33 refused pipelines" I reported from game runs is confounded: the runs covered different amounts of world content (a What still holds: with this PR every pixel/vertex/mesh shader of the run translated and the run survived 300 s without a device removal, while Remaining top refusals offline with this PR: a 64-bit image atomic (653 programs), a scalar memory read as data (612), a descriptor read only as data (570), a descriptor neither loaded nor built (298). No game data: counts, driver version and error strings only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine. |
…ons (PR Marvisak#585) Lower untracked scalar mask operands (and inline 0/-1 constants) in v_cndmask_b32 and carry-in VALU ops via lane_bit, and lower descriptor-only GetDimensions loads using native UsedResource metadata.
…t, descriptor-only GetDimensions) Targets 'emit: a select on an untracked mask': 40 -> 37 failing containers in the offline translate (all 3 of that group now translate). One conflict in descriptor_data(): the PR's version of the descriptor-only branch was taken as is. No test dropped or changed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sak#309 on top of Marvisak#233 Brings in three more open upstream PRs, each kept only because the offline translate over the 48 dumped world shaders improved (41 -> 36 failures): Marvisak#709 structured access through a root SRV/UAV raw view (typed root view), Marvisak#585 select on an untracked mask (3 programs), Marvisak#309 SGPR spill forwarding (opaque lane mask). Conflicts with Marvisak#233's wave handling in emit/lower.rs: Marvisak#233's console-lane analysis (swizzle/DPP in-half vs whole-wave reads) is kept, and its instruction iterator now skips the spill moves Marvisak#309 marks dead so they cannot make a program look like it reads lanes or masks; Marvisak#585's mask_cond is added next to Marvisak#233's lane-bit helper. Two tests call emit() with the new Target argument (Target::ANY). Workspace tests pass. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
v_*_co_ci_u32 refused when its carry-in mask was not one structure followed (a plain SGPR number), and v_cndmask_b32 refused inline 0 and -1 masks. A carry-in now fails as an untracked select does, so compute retries it with console lanes and the lane tests its own bit of the register (pair in wave64); inline 0 and -1 masks are constants. Ported from undeadhuman37 fda0c77 (from upstream PR JMAN730#585, the mask part); our selects had the console-lane fallback already. New test runs on Linux: fails before, passes after. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The console compiler spills scalars, lane-mask pairs among them, with
v_writelane_b32 into constant lanes of a VGPR and restores them with
v_readlane_b32 of the same lane. The restored pair was an opaque mask, so
the selects, EXEC writes and joins that used it refused ("a select on an
untracked mask", "an opaque lane mask", "a lane-mask join of an untracked
mask"). structure now follows a constant-lane readlane back through a plain
chain of writelanes to the scalar written to that lane, and gives the
restored pair that scalar pair's mask. A chain with a phi or another write
of the VGPR stays opaque (shortcut noted in code).
Offline corpus, against fix/mask-phi-ballot (neither branch carries Marvisak#585):
vertex/pixel programs emitted 12250 -> 12269, compute 1443 -> 1452,
"a lane-mask join of an untracked mask" 20 -> 0, "an opaque lane mask"
29 -> 8, "a conditional export" 8 -> 0. Synthetic pixel program fails
before, lowers after. Stacked on fix/mask-phi-ballot (shares its test helper).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
v_cndmask_b32 and v_*_co_ci_u32 refused when their scalar mask was not one structure followed (a plain SGPR number). In compute with console lanes the lane now tests its own bit of the register (pair in wave64); inline 0 and -1 masks are constants. Taken from upstream PR Marvisak#585 (mask part only; its descriptor-dimension hunk is left to the resource work). Offline corpus (26148 programs): "a select on an untracked mask" 288 -> 0, no new refusal text; those programs now stop at later refusals (descriptor read as data +205, unknown stride +32, descriptor address/format +33), so compute programs emitted only 1441 -> 1443. Synthetic test on hardware: fails before, passes after. WARP cannot pin a wave size, so the test skips it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
In-game A/B on an RTX 5060 Ti: #585 clears "a select on an untracked mask" in every shader that hit it in the run, with no regression. None of those shaders becomes usable yet: each stops at its next refusal, mostly "a descriptor read only as data". No game data in this comment: counts, shader hashes and offsets only. Setup
Results
Shader by shader, over the 1,991 shaders seen in both runs:
This matches the gap with #1247's offline count (+25 validated programs). In the game, the select is rarely the last blocker: #585 is necessary for these 78 shaders, but not enough on its own. Stacked with #1067, most of the 42 should become measurable. Separately, 5 shaders still fail with "a lane-mask join of an untracked mask". That is a different refusal, the same on both builds. They are The world removes the device with both builds, so nothing here changes that outcome. AI-assisted (Claude Code); everything was run on our machine. |
|
Follow-up: #585 stacked with #1067 adds 563 host pipelines on an RTX 5060 Ti and loses none. 190 of them need both PRs. Counts only; no shader names or dumps. My earlier in-game numbers came from runs that end when the world removes the device, so they depend on how far each run gets. These come from a run that doesn't: Builds:
In the game, the stacked build had 0 regressions: no shader whose pipeline was created on AI-assisted (Claude Code); everything was run on our machine. |
… lane A select or carry-in whose mask operand structure did not track no longer stops the program: it uses the tracked boolean when there is one, inline 0/-1 constants otherwise, or, with console lanes active, this lane's bit of the scalar mask register (its pair in wave64). Ported from Marvisak/VIctory Marvisak#585. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
In-game Linux + Proton + NVIDIA RTX 5080 confirmation alongside
Full A/B table posted in #1067. (AI-assisted log summary; own retail copy, no game files or raw logs attached.) |
…, Marvisak#320, Marvisak#439) onto Marvisak#160 + Marvisak#309 + Marvisak#180 + Marvisak#704 + Marvisak#1511 PR Marvisak#439 head 28aca3b (46 commits over main: Marvisak#223 wave-range targets, Marvisak#233 split halves and the console flow, Marvisak#320 lane reads where lanes branch, Marvisak#439 LDS in one console wave, whole-wave sections across the halves, ds_bpermute, numeric selects), merged onto the Marvisak#160 merge (b821b31), as the wave64 line of integ/next-v3. emit/wave.rs: no conflict on this Marvisak#1511 head. The previous head carried Marvisak#98 (f468457, v_permlane16 modelled next to v_permlanex16, only with every lane active), which conflicted with Marvisak#439's a31c82e (an inactive lane also accepted when fi, opsel bit 0, is set). Marvisak#98 is no longer in the bundle, so the whole-wave simulation is Marvisak#439's: v_permlanex16 only, under `exec == all || v.opsel & 1 != 0`. structure.rs (1 hunk): the bundle only reformatted `paired_masks`; Marvisak#439 moved it after the new `execs`/`others`/`pairs` fields because `pairs` borrows `self.masks` before `paired_masks` moves it. Kept Marvisak#439's order with the bundle's formatting. emit/waterfall_tests.rs (3 hunks): 1-2. The bundle split `build` into `build_with(words, buffers, nonuniform)` (a program with no per-lane handle, whose first-lane read is a wave operation); Marvisak#439 split the same function into `native`, `lower_as` (per-lane or console flow) and `host_shader`. Kept Marvisak#439's helpers and the bundle's `build_with` on top of them (lower_as(.., false), the bundle's two asserts, host_shader). host_shader keeps the stride_table field (Marvisak#704), which git merged outside the hunk. 3. Tests at the end of the file: the bundle's side ends inside the `for` loop of a_descriptor_only_read_as_data_gives_its_views_size, Marvisak#439's inside the `for target` loop of its last test. The bundle's test is closed before Marvisak#439's tests, so none is nested in another. emit/lower.rs (6 hunks): 1, 3. Lower fields and their initializers: the bundle's `mask_scc` (Marvisak#309, SCC of a mask operation read as data) and Marvisak#439's `opaque_open` (stops the recursion of a mask copied dword by dword). Both kept. 2. Which compute programs need the console's lanes. The bundle (Marvisak#309) counts only live instructions (`sgpr_spill::dead`: lane moves forwarding left unread are not lowered); Marvisak#439 split the test into in-half reads, whole reads and masks held as numbers and added the split/console-flow choice. Kept Marvisak#439's structure, reading `live()` for reads_whole and in_half, and for lane_access_outside_sections (the console-flow trigger for lane reads where lanes branch differently). 1ca87f7 (in Marvisak#439) notes that the tester tree's `live()` filter belongs here once Marvisak#309 is in. 4-5. Selects on masks the structure does not follow. The bundle (48a41fb, from Marvisak#585) added `mask_cond` for v_cndmask_b32 and the v_*_co_ci_u32 carry-ins: inline 0/-1 constants, the tracked boolean, else with console lanes this lane's bit of the register's number (pair in wave64). Marvisak#439 (e461457, 1ca87f7, ccd9c44) takes, for v_cndmask only, the structure's boolean for masks held as numbers (`Structured::others`, which also finds the high word written by another instruction), only where the host lane is the console lane (not split in halves without the console flow), and declares console lanes for them only on a second lowering after the first stops on such a select (`lower`). Combined in `mask_cond`: tracked boolean, then Marvisak#439's `others` boolean, then the bundle's register number, both under Marvisak#439's condition (console lanes and not split without the console flow; the bundle's number path called lane_bit, which is wrong in a split program, where Marvisak#439 asserts it is never called). Both instructions use it; v_cndmask now also takes the bundle's inline constants. Without a textual conflict git had also kept the bundle's unconditional rule (any untracked select or carry-in declares console lanes) inside Marvisak#439's masks_held, which undid 1ca87f7 (a select nothing reads made a wave64 program in a group of more than 64 threads untranslatable on a 32-lane host). The rule now counts live instructions and applies only on Marvisak#439's second lowering, which now also follows an untracked carry-in ("a carry-in from an untracked mask", UNTRACKED_CARRY). It covers every untracked selector, not only Marvisak#439's held masks with an opaque or constant atom, since the bundle's number path needs console lanes for selectors outside `others` too; on the first lowering nothing changes. 6. lower.rs test helper: Marvisak#439's three new Parts fields with the bundle's formatting. Not textual, did not compile (test code only): Marvisak#439 gives `emit` a Target and `lower::Parts` target/console_cf/per_lane_only. Tests that came with the bundle, Marvisak#704, Marvisak#309 and Marvisak#160 used the old forms: image_tests.rs `lower`, emit/mod.rs (3 emit calls, the stride-table Parts), lower.rs (2 Parts in the int64 atomics tests), root_view_tests.rs, sgpr_spill.rs tests and victory-gpu raw_view_tests.rs. They pass Target::ANY, console_cf false and per_lane_only false, as Marvisak#439 did for the upstream tests. Not textual, test-only (split_tests.rs): with Marvisak#309 a v_readlane whose result nothing reads is dead (not lowered and, above, not counted). saveexec_scc_tests_new_exec_not_saved_exec and loops_leave_on_the_new_exec_of_saveexec used `v_readlane_b32 s14, v0, 10` with s14 unread only to take the console flow. After the merge the loop test failed on the RTX (per-lane form, lane t counted t + 1 iterations where the console counts 64; it passes on Marvisak#439 alone), and the saveexec test passed without taking the console flow (its per-lane result is also 42). Both now read s14 once (`s_mov_b32 s15, s14`, the branch over the body +4), and a first lowering of each was checked to ask for the console flow again on a 32..32 target. Marvisak#180 interaction: r4tedx's integration (24b3bcc, from Marvisak#180 5ff639e) put `implicit_derivatives` among the in-half reads that make a program need console lanes. The Marvisak#180 merged here is aa69258, whose last commit takes quad gradients out of the console-lanes test altogether ("a quad's four lanes share a host wave of any size"), so there is no such term to place. The quad reads stay inside one host wave in both Marvisak#439 forms (each half is a host wave in the split and in the console flow, and in the console flow samples run in every lane and are kept by a select on EXEC). Checked on the previous Marvisak#1511 head (289f241, with Marvisak#98; this replay was checked with cargo check --workspace --all-targets --all-features and the full suite at the end of the line), on an RTX 4060 Laptop (32..32): cargo test --workspace --locked: 468 passed, 0 failed, 6 ignored (base 427 + 41). The 41 tests Marvisak#439 adds all pass; the GPU ones ran on the RTX in two 32-lane halves ("split true"). VICTORY_WARP=1: 467 passed, 1 failed, 6 ignored; the failure is valu_tests::v_cndmask_on_an_untracked_mask_tests_this_lanes_bit, which fails on the base too (a fixed-WaveSize pipeline on WARP). victory-shader lib tests listed: 204 -> 244 (Marvisak#439 adds 40 there and 1 in victory-gpu). cargo clippy --workspace --all-targets -D warnings and cargo xtask policy clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1084. Its mask half (select and carry-in on an untracked mask test the lane's own bit) was taken over as #1084 with tests. Its other half guesses a descriptor-only load's view kind from the used-resource entry, which carries no dimension; main takes the kind from a twin load instead (75677cb). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
Problem
Two common shader patterns currently fail to lower and get dropped:
v_cndmask_b32and carry-in VALU ops (*_ci_u32) whose scalar mask operand was not tracked as a structured boolean (or uses inline0/-1constants).GetDimensions) where the resource type/layout is already known fromUsedResourcemetadata.Fix
mask_condto handle inline0/-1constants, tracked masks, and untracked scalar masks vialane_bitwhen console lanes are active.GetDimensionsloads using nativeUsedResourcemetadata.Verification
cargo xtask policy— passed (151 files ok)cargo clippy -p victory-shader --lib -- -D warnings— 0 warningscargo test -p victory-shader -- --test-threads=1—69 passed, 0 failed