Skip to content

Shaders: a select or carry-in on an untracked mask tests this lane's bit - #1084

Open
undeadhuman37 wants to merge 1 commit into
Marvisak:mainfrom
undeadhuman37:fix/untracked-mask-select
Open

undeadhuman37 wants to merge 1 commit into
Marvisak:mainfrom
undeadhuman37:fix/untracked-mask-select

Conversation

@undeadhuman37

Copy link
Copy Markdown

v_cndmask_b32 and v_*_co_ci_u32 were refused when their scalar mask was not one that structure follows (a plain SGPR number). In compute with console lanes, the lane now tests its own bit of the register (the pair in wave64); inline 0 and -1 masks are constants.

Credit: this is taken from #585 (the mask part only). Its descriptor-dimension hunk is left out; that belongs with the resource work. It overlaps #585, so whichever merges first, the other should drop this hunk.

Measured offline over the shader corpus (26148 programs):

  • "a select on an untracked mask": 288 -> 0, with 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 go 1441 -> 1443.

Tests: a synthetic hardware test fails before the change and passes after (run earlier on a GPU, not re-run for this PR). WARP cannot pin a wave size, so the test skips it. cargo clippy -p victory-shader --all-targets -- -D warnings is clean on this rebase.

No game data. AI-assisted: written with Claude Code (Claude Sonnet 5.5).

🤖 Generated with Claude Code

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>
@jeremygold02

Copy link
Copy Markdown
Contributor

I replayed 105 distinct compute shaders that VIctory had refused during one local RTX 5070 mission-loading trace, after a fence-confirmed texture readback. I matched the local inputs to the logged identifiers and compared the same inputs on ffe310e and 48a41fb. The replay ran the translator offline on Windows.

On main, 47 of the 105 stopped at the untracked-mask select. All 47 advanced on this PR. Their next reported reasons were:

Next translator refusal Distinct shaders
Descriptor read only as data 29
Structured buffer of unknown stride 7
Descriptor address or format read as data 6
Scalar memory read as data 4
Lane mask holding lanes elsewhere read as data 1

Both builds still refused all 105 inputs before producing DXIL. This confirms the specific lowering change reaches this mission’s shaders and identifies which refusal appears next. The replay did not execute any of these shaders or measure frame time. AI-assisted.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v_cndmask_b32 and *_ci_u32 no longer hard-fail on untracked scalar masks: inline 0/-1 constants fold to bools, tracked masks keep the structure path, and plain SGPR masks fall back to per-lane bit tests (with wave64 hi dword and WAVE_OPS flag). The added guard extends cross-lane detection to these ops when the mask is untracked. The execution test is Windows-gated; lowering suite green here. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed.

@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 48a41fb: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

@jtrudeau1530

Copy link
Copy Markdown

Tested a local adaptation of 48a41fb together with #660 on an RX 7900 XT under Wine/vkd3d-proton. The adaptation reads the wave64 high word from the consuming instruction, requires it before the tracked-mask shortcut, and uses the exact low/high pair for that shortcut. Missing high-word metadata remains refused rather than becoming zero.

Synthetic GPU readbacks pass for all 128 threads with native wave32 and wave64 for v_cndmask_b32, v_add_co_ci_u32, v_sub_co_ci_u32, and v_subrev_co_ci_u32. The tests use unequal low/high words, rewrite only the high word between two uses, and cover inline 0/-1, root-driven uniform s_cselect, and tracked compares. Numeric masks alone must enable WAVE_OPS and pin the native wave size; no indexing instruction accidentally enables that path. Microsoft DXIL validation is mandatory. The same all-lane fixture on the unchanged parent fails at the original untracked-mask refusal.

Missing-high, rewritten-mask and divergent-carry negatives also remain refused. The latter now propagates the existing lane-mask-as-data refusal at the consuming store; its assertion checks the exact Unsupported location and reason. Hardware tests are explicitly invoked and fail if the physical adapter or validator is unavailable. This is compute-path validation of the adaptation, not a game-rendering or frame-time result, and does not resolve the later refusal groups reported above.

yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
Conflicts kept both sides: the split execute/submit (breadcrumbs cleared at the start of submit), the debug pixel shader and the breadcrumb stage notes, the view-heap-cap and wave keys of the shader cache with the breadcrumb key, and the single-exit block with the breadcrumb loops. Tests added by Marvisak#1084/Marvisak#1130/Marvisak#1269 initialise Parts with crumbs: None.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@justlovett0

Copy link
Copy Markdown

Verified + integrated, with a runtime caveat. Stack: main ffe310e + #175/#994/#747/#302/#193/#704/#309/#953/#1067/#986/#1260/#1267/#1254/#1276/#189 (wave64 emulation), RTX 3080 10 GB / Win10 21H2 (19044.7846) / driver 621.24 (32.0.16.2124). Re-census of captured runtime containers; world stable ~9 min, 0 device removals.

Merged cleanly. Note: the offline untracked-mask gain did not transfer to our captured runtime containers — the "a lane mask read as data" (7) and "a lane mask holding lanes elsewhere read as data" (6) classes persist on the runtime "Wrapped" containers. The fix works on the offline archive; our runtime masks differ (likely loaded from memory rather than the spill/select patterns). Flagging so the offline count isn't read as a runtime guarantee.

AI use: Qwen Code; local measurements. No game data posted.

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…e's bit

Conflicts with our numeric selects (3d3f32e): mask_cond first looks the
selector up in st.masks, then (with console lanes) in st.others, before
testing the lane's bit of the raw SGPR; the raw bit is refused in a wave64
program split into 32-lane halves. The select keeps UNTRACKED_SELECT so
compute still retries with numeric_selects, and #1084's console-lane
trigger counts only live instructions, with selects only on that retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…table names

Brings #193's runtime stride table (#155) with #704's raw view pool.

Conflicts and fitting it to this tree:
- Heap layout is title slots, dynamic slots, the guard slot, then the raw
  view pool (alias_base = count + extra + 1). A heap capped at
  PORTABLE_VIEWS takes a pool of 2^14 (ALIASES_CAPPED), not 2^16, since
  each pool slot is a mirrored title slot less.
- Stride entries follow every slot write of ours: mirror, make_at, the
  bindless buffer and placed-texture slots, typed nulls, null kinds,
  raw_at, bindless CBVs and unmapped nulls.
- viewed_bytes cuts the raw view to its host copy as make does
  (cut_to_copy), so the host never refuses it.
- stride_entry gets the slot through our uniform_heap_index (#1012);
  #704's heap_slot is dropped. handles keeps our props key.
- Our cut_to_copy clamps stay in buffer_srv/uav; #704's are dropped.
- The tests pass the heap guard in its user-data dword, take our make_at
  and emit signatures, and count the guard slot.
- Shader cache MAGIC VSH3, KeySpec version 3 (stride_table encoded).
- Formatting-only hunks from #704 left out.

translate --host-lanes 32-32: compute 2285 -> 2487, vertex/geometry/pixel
14186 -> 14256 (with #1073, #1084, #416 before it), mesh 8381 -> 8383;
"a structured buffer of unknown stride" 206 -> 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
#1215 #1135 #1296 #1277 #1238 #464 #1073 #1057 #1084 #416 #704 #621.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…sak#98, Marvisak#334 to Marvisak#492, validation)

The line rebuilt on the bundles' current heads (Marvisak#1402 119b763, Marvisak#1492 5bbc098
without Marvisak#98, Marvisak#1504 1d41891, Marvisak#1511 ca601f0) with every merge replayed, and the
merges after this file's first version (Marvisak#334, Marvisak#346, Marvisak#1024, Marvisak#211, Marvisak#492): merge
order, the runner's numbers on 967d3ae (RTX 571, WARP 570 + the known Marvisak#1084
failure, all features 580; Marvisak#98's one test leaves), what is not included (Marvisak#98,
Marvisak#282 for Marvisak#346, Marvisak#693 for Marvisak#1024, Marvisak#306's latest commit), and the open pull
requests whose head is contained here (109, from the 18:24 collection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants