Skip to content

victory-shader: lower v_permlane16_b32 and v_permlanex16_b32 - #1014

Closed
bartikele wants to merge 1 commit into
Marvisak:mainfrom
bartikele:shader-permlane16
Closed

bartikele wants to merge 1 commit into
Marvisak:mainfrom
bartikele:shader-permlane16

Conversation

@bartikele

Copy link
Copy Markdown
Contributor

Adds DXIL lowering for \�_permlane16_b32\ and \�_permlanex16_b32\ in \�ictory-shader:

  • Marks both instructions for \console_lanes\ so host lane order matches the console.
  • Checks \cross_lane(false)\ and lowers via \dx.op.waveGetLaneIndex\ + \dx.op.waveReadLaneAt.i32.
  • Includes unit test \permlane16_lowers.

Verified with \cargo clippy -p victory-shader --all-targets --locked -- -D warnings, \cargo test -p victory-shader --locked, \cargo xtask policy, and \�ictory translate --validate.

@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 9d1c299: 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).

@shortselow-byte

Copy link
Copy Markdown

This PR has no CI run yet, so I ran the CI's checks at head 9d1c299 (on main ffe310e): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2).

  • cargo test --workspace --locked -- --test-threads=1: 343 passed, 0 failed (GPU tests on the AMD device and WARP).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • cargo xtask policy: ok.

Review of the lowering against the ISA's description: the 4-bit select per lane (lanes 0-7 from s1, 8-15 from s2), the own row for v_permlane16_b32 and the other row of the 32-lane pair for v_permlanex16_b32 all look right to me.

Two things I could not confirm:

  • op_sel is not read. On these two opcodes it carries FI (op_sel[0]) and BOUND_CTRL (op_sel[1]), which decide what a lane gets when its source lane is inactive. With every lane active it makes no difference; with inactive source lanes, waveReadLaneAt returns whatever the host gives.
  • permlane16_lowers only checks that the instruction lowers, not the lanes it reads. valu_tests runs one thread, so a result check would need a multi-lane harness like waterfall_tests.

@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_permlane16_b32 + v_permlanex16_b32 lowering: 16-lane row semantics check out (base = row aligned to 16, or 32 with bit-4 flipped for the x16 form; nibble selector from S1/S2 by lane bit 3; shift = (lane&7)*4; pick & 15). Also adds both ops to the cross-lane mask guard, which #1134 lacks. Includes a lowering smoke test. 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: 97 passed, 0 failed. Note: supersedes #1134, which implements only the x16 form without the guard entry or test.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
@Marvisak Marvisak mentioned this pull request Nov 25, 2026
3 tasks done
@Marvisak Marvisak mentioned this pull request Nov 25, 2026
3 tasks done

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Proposed close: superseded by #1737. Thanks for the rebase. It now merges cleanly, and CI check passes at c5d3a9a.

#1737 is built on this PR's own commit (9d1c299), so your lowering is kept there with your authorship. It adds the two things this branch is still missing:

  • op_sel handling: FI and BOUND_CTRL, which decide what a lane gets when its source lane is inactive. Here, op_sel is ignored in the new arm in Lower (crates/victory-shader/src/emit/lower.rs).
  • A multi-lane test (emit/permlane_tests.rs) that checks which lanes are read. Here, permlane16_lowers only checks that the instruction lowers.

#1737 also merges cleanly and is marked as a merge candidate. The lane selection in both PRs matches what main already assumes in emit/wave.rs.

This PR will be closed in 48 hours unless you push a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

@bartikele

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (940d32f, resolving the test-list merge conflict in crates/victory-shader/src/emit/lower.rs) and extended permlane16_lowers to cover both �_permlane16_b32 (

@bartikele

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1737, which builds on commit 9d1c299 (preserving authorship) and adds the missing EXEC/FI/BOUND_CTRL handling and multi-lane tests. Thanks everyone for the reviews!

@bartikele bartikele closed this Nov 25, 2026
fornorharry added a commit to NitricAcidDev/VIctory-Omega-Fork that referenced this pull request Nov 25, 2026
…ks, constants

Pull requests of fxceless/victory-gta6, each read before it was taken:
- Marvisak#1002: the tiled cascade shadow programs translate exactly on 32-lane hosts
  (f133e35efed2a48a, refused in this machine's log, is one of them);
- Marvisak#1014: the compare of copies in the card's memory hashes a piece with 64
  threads (on; VICTORY_CARD_HASH_WIDE=0: one);
- Marvisak#837: a NaN or an infinity a pixel program exports does not go into the
  colour target (on; VICTORY_NAN_GUARD=0);
- Marvisak#794: a partial texture read-back leaves the bytes beside it;
- Marvisak#1058: small buffers in place with VICTORY_COPY_PLAIN=1;
- Marvisak#799, in part: constant views of at most 64 KiB, s_pack_*_b32_b16, two
  more constant sources of descriptors;
- Marvisak#823, in part: programs that may take the wave-wide form, by hash; one by
  default (particle visibility), the others with VICTORY_WAVE_WIDE_ONLY=all.

Not taken: the rest of Marvisak#823 (the builder kills the title there), of Marvisak#799
(approximate), Marvisak#1069 (this tree notes committed pages already), Marvisak#1044
(fewer storage workers, measured on another kind of machine), Marvisak#1016 (about a
millisecond), Marvisak#827, Marvisak#854 (large; see the handoff).

AI-assisted. Not run with the title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gmankab pushed a commit to gmankab/victory that referenced this pull request Nov 25, 2026
…es a piece with a group of 64 threads

Read whole before merging (the graphics crate's host.rs and a test module). Made opt-in in the commit after this one (VICTORY_CARD_HASH_WIDE=1): it is another hash, and it has not run in a game on this tree yet.
gmankab pushed a commit to gmankab/victory that referenced this pull request Nov 25, 2026
…_CARD_HASH_WIDE=1); changed card copies from a list (VICTORY_CARD_CHANGED_LIST); notes about unmapped blocks kept until told (VICTORY_ABSENT_MS=told)

- VICTORY_CARD_HASH_WIDE=1: the hash of pull request Marvisak#1014 is used only when asked, says so in
  the log, and takes the hash length of VICTORY_CARD_HASH_LEN like the thread-a-piece form.
- VICTORY_CARD_CHANGED_LIST=1|alt: a copy in the card's memory is put on a list when its changed
  offsets go from none to some, and the pass before a submission takes that list instead of
  walking every copy (about 3,900 with every title buffer on the card).
- VICTORY_ABSENT_MS=told (with VICTORY_ABSENT_ONCE): a block found uncommitted is asked about
  again only after the runtime mapped or committed memory there (XMemVirtualAlloc now tells).
- All off by default; none has run in a game yet. The software-adapter tests of both hash forms
  and the device-free guard test passed in the tree these came from; this tree's diagnostics
  build finishes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
notquiteog added a commit to notquiteog/victory-nvidia that referenced this pull request Nov 26, 2026
11 files conflicted (53 hunks): draw.rs 5, host.rs 10, indirect.rs 2,
pipeline.rs 2, shader_cache.rs 2, watch.rs 22 in victory-gpu; emit/lower.rs
1, emit/mod.rs 2, emit/wave64_tests.rs 1, ir.rs 5, resource.rs 1 in
victory-shader. Most of this line was in the branch already: its shader
commits came in as pull requests (fxceless Marvisak#1002, Marvisak#1124, the far-jump exit
paths), and its renderer files are fxceless's line, merged just before.

Ours:
- crates/victory-gpu/src/host.rs, draw.rs, indirect.rs, watch.rs, whole
  files (the incoming side: PR Marvisak#1014's 64-thread card hash, a 128-bit key
  for draws' fresh tables, fxceless's write watch; no measurement on our
  threading, and the card compare's HLSL stays unmixed).
- crates/victory-gpu/src/pipeline.rs (the builder's missing pipelines
  named by our make::hashes).
- crates/victory-shader/src/ir.rs, whole file (both sides give a spill
  lane's lives stores of their own; ours is the form the branch has run
  with, the incoming site_webs is the same fix another way).
- crates/victory-shader/src/emit/lower.rs, emit/shader.rs, and the early
  depth part of emit/mod.rs: our early_depth (DEPTH_BEFORE_SHADER, not for
  programs that export depth, stencil or coverage; VICTORY_EARLY_DEPTH) is
  kept and the incoming one (VICTORY_EARLY_Z) removed: two declarations of
  the same flag.
- crates/victory-shader/src/resource.rs, emit/wave64_tests.rs.

Incoming side, combined into ours:
- crates/victory-gpu/src/shader_cache.rs and emit/mod.rs: the wave-wide
  form and the host wave's own first lane for programs listed by hash
  (VICTORY_WAVE_WIDE_ONLY, VICTORY_FIRSTLANE_OWN_ONLY; defaults: four
  compute programs a 32-lane driver refused, three structure-builder
  programs; mravatins 64ffcc0, on RTX 5060 Ti / 5070). The two lists are
  part of the shader cache key, so the cache is translated anew once. Our
  last-resort wave-wide form is unchanged.

Not taken: docs/nvidia-render-baseline.md, scripts/play-nvidia.ps1 (docs
and scripts stay ours; the script starts the game).

Builds: cargo build -j 6 --locked --profile diag -p victory --features
diagnostics. Not run in game.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

5 participants