Shaders: honor permlane EXEC and FI/BC flags (on #1014) #1737
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1737
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1737"
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?
@jaschinski97-ops on GitHub · 2026-11-24 21:40 UTC · original
jaschinski97-ops:fix/upstream-permlane-flags→main· +520 −1 · 3 files · 5 commits · openLower v_permlane16_b32 and v_permlanex16_b32 with console EXEC source activity and FI/BC semantics. A selected inactive source must preserve the old destination or return zero according to BC, unless FI requests inactive-lane fetches.
Builds on #1014 (original author commit retained), whose synthetic reverse-row/masked-EXEC case returned a source value instead of the required old destination. Updated against upstream main
940d32f, with its unrelated shader changes retained. Coordination: PR #1737 in #1633.Ballot console EXEC together with host activity; use a safe active shuffle lane before selecting an inactive-source fallback.
Honor both instruction flags, both row operations and in-place aliasing; reject unsupported input modifiers.
Require full host participation for FI. The analysis includes per-lane loop-limit returns, unresolved divergence, uniform branches and genuine reconvergence.
Add synthetic GPU readback and control-flow regressions.
Validation: Windows 11, NVIDIA GeForce RTX 3080, driver 32.0.16.2140; Rust 1.98.1 Windows GNU.
GPU matrix: 400 dispatches / 51,200 lane results, both operations, all FI/BC combinations, aliasing, five selectors and five EXEC masks. All pass. Final
940d32ftargeted run: all five permlane tests pass, including four control-flow regressions; the loop-abort case fails without its correction.Shader Clippy, all targets, diagnostics+host, warnings denied: passed. Asset policy: passed. Independent review of the current-main merge: no blocking findings.
Native wave32 is tested. RTX 3080 cannot execute native wave64, which is capability-skipped. WARP reports four-lane waves here and skips the row matrix. This does not add wave64 emulation or establish game boot, FPS or complete RTX compatibility. Fixtures are synthetic; no title data was used.
AI-assisted with Codex, including parallel research and independent agent review. GPU processes were serialized centrally. GitHub Actions passes on head
a29e902(Windows MSVC).Combined local validation (main
940d32f+ all three contributions, integration cfa116d):cargo clippy --locked --workspace --all-targets --all-features -- -D warnings: passed.cargo test --locked --workspace --all-features --no-fail-fast -- --test-threads=1: completed unfiltered; six tests fail. Shader suite: 271 passed, 3 failed, 3 ignored. GPU suite: 145 passed, 2 failed, 2 ignored. The five GPU/shader failures were independently reproduced on bare main940d32f. The sixth isloads_binds_and_calls_probe: its unchanged fixture passes MSVC/DELAYLOADto the local GNU linker, which rejects it.The baseline failures are
dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views,a_heap_buffer_read_by_element_takes_the_views_stride,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, andgathers_at_a_level_match_the_hardware. The full local workspace run is therefore explicitly not reported as passing.New regression tests and the repository asset policy pass. All three PRs also pass GitHub's Windows MSVC CI. Green CI does not substitute for the separately reported RTX readback evidence.
App-local WARP follow-up: an external native-HLSL control reports the same cross-row/ballot-selected-index mismatch as the translated shader on Microsoft WARP 1.0.22 (#1737). This supports a DXC/WARP execution-path discrepancy; I have not independently reproduced that app-local build. A separate divergent-case discrepancy is still open. The local built-in WARP only supports four-lane waves and skips the matrix. No assertions are weakened to hide this limitation.
Refresh against main
67e8ae1(2026-11-25)Current-main refresh: head
abb811fmerges main67e8ae1401df112248aed36d0024483181b718b7without conflict. The permlane semantics are unchanged. All 6 permlane tests pass again, including 400 RTX 3080 Wave32 dispatches / 51,200 lane values; native Wave64 is unsupported on this card and built-in WARP (4..4 lanes) capability-skips this matrix. The app-local WARP caveat above remains open. Combined current-main validation also passes all 17 general emitter tests, all 20 interpolation tests and all 3 pipeline host-state tests, plus workspace Clippy for all targets/all features with warnings denied. This is targeted validation, not a new full-workspace native test result. GitHub Windows MSVC CI: https://github.com/Marvisak/VIctory/actions/runs/45652322993 (passed on this head).Coordination bookkeeping: the earlier claim label was incorrect; see the correction.
67e8ae1into permlane follow-up abb811f13d@steven-seagull27 on GitHub · 2026-11-24 21:53 UTC · original
The RTX 5080 passed the Wave32 matrix. With app-local Microsoft WARP 1.0.22,
permlane_rows_and_inactive_sourcesreproduced a cross-row mismatch. I reran the unmodified test on the updated PR head108b38b: the RTX passed again, and WARP stopped at the same Wave32 assertion on lane 4.Full counts on
6950616. I temporarily collected mismatches past the first assertion so the test could finish both wave sizes. Two fresh runs gave identical counts. Each row below is one run.Lane 4 read lane 14 instead of lane 30. With
v_permlanex16_b32, selectors[0xF10E2D3C, 0x4B5A6978],EXEC=0x55555555, andFI=0, lane 4 selects index 14 in the opposite 16-lane row. Both destination lane 4 and source lane 30 are active. The expected value was0x1234001e(lane 30); WARP returned0x1234000e(lane 14 in the same row). This was the first difference at both wave sizes in the complete runs. It reproduced with either BC setting and with or without source/destination aliasing. Every same-row permutation passed.Windows 11 build 26300.10075. Built-in WARP reported a wave range of 4–4 and skipped the matrix. The app-local WARP DLL reported 4–128 and exercised both wave sizes.
@Marvisak on GitHub · 2026-11-25 03:36 UTC · original · edited 2026-11-25 22:24 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main:mainhas moved since the last triage, and the branch now conflicts incrates/victory-shader/src/emit/lower.rs. It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
Generated by Claude Code
@zed6000 on GitHub · 2026-11-25 04:23 UTC · original
Measured offline on the title's shaders (the method in #1247): merged onto main
940d32f(a clean merge), +1 program and 0 lost. On main it failed with "emit: v_permlanex16_b32".One thing to fix: on
940d32fthe newpermlane_tests.rsno longer compiles. Main'scd94d35added aview_marksfield, and the test'sParts { .. }(line 85) andHostShader { .. }(line 97) initializers don't set it (E0063: missing field view_marks). The release build is unaffected. Adding the field to both initializers should be enough. Offline counts only; no program names or data.@zed6000 on GitHub · 2026-11-25 04:27 UTC · original
To square this with the macOS approval above:
permlane_testsis#[cfg(all(test, windows))], so it compiles only on Windows, and a macOS or Linux test run never builds it. I rechecked this PR alone, merged onto940d32f, on Windows:cargo test -p victory-shader --lib --no-runfails withE0063: missing field view_marksinPartsandHostShader. Those are main's new fields fromcd94d35. The release build and the +1 program are unaffected. Addingview_marksto the two test initializers is the whole fix.@steven-seagull27 on GitHub · 2026-11-25 10:47 UTC · original
The lane-4 mismatch reproduces in independently compiled HLSL on Microsoft WARP 1.0.22. DXC compiled the control directly to Shader Model 6.6. I also reran the translated matrix on
a29e902, which now builds on Windows. The two matrices agreed on all the counts below.With cross-row selection,
FI=0andEXEC=0x55555555, lane 4 computed source 30. Both lanes were enabled, and a hardware ballot showed every lane physically active. In the same native dispatch,WaveReadLaneAt(value, source)returned0x1234001e(lane 30). Reading with the ballot-selected index returned0x1234000e(lane 14), even though that index also read back as 30. This reproduced at-O3and-Od. Built-in WARP on this PC reported wave sizes 4–4 and skipped both widths. The RTX skipped Wave64.Passing the source index directly cleared the original 400-case matrix on standalone WARP. A separate FI-disabled test with a divergent branch still had 728/25,600 incorrect lanes at Wave32 and 828/25,600 at Wave64 with that change (original lowering: 780 and 734). I would keep the direct-index change experimental. The native control isolates the original discrepancy to this DXC/WARP execution path. The cause of the divergent case remains open.
The focused control is one commit on top of
a29e902. It prints the adapter, loaded WARP DLL and both lane-4 results. HLSL source · Windows rerun instructions@jaschinski97-ops on GitHub · 2026-11-25 10:57 UTC · original
Status on current head
a29e902, merged with main940d32f:The PR keeps the ISA semantics and regression assertions, and the software-backend limitation is explicit. No game-data or gameplay claim. AI-assisted follow-up.
@zed6000 on GitHub · 2026-11-25 18:26 UTC · original
Re-checked head
abb811fon main13f91ca(a clean merge), on Windows.permlane_testscompiles now, andcargo test -p victory-shader --libgives 276 passed and 0 failed on an RX 7900 XTX. Onshaders.rpf(1.0.2.1) it is +1 program, 0 lost: the one main still refuses with "emit: v_permlanex16_b32". Offline counts only; no program names or data.@pawrenity on GitHub · 2026-11-25 23:49 UTC · original
In case it saves you a step on the rebase: I merged current
main(63bcca4) into headabb811flocally. The only conflict is the end ofmod testsincrates/victory-shader/src/emit/lower.rs, wheremainaddedds_bpermute_wave64_preserves_32_lane_halfandds_bpermute_refuses_gdsnext to yourpermlane16_lowers. Keeping both sides resolves it. The PR side only needs its closing}:Nothing else conflicts. Results on that merge, on Windows 11 with an NVIDIA GeForce RTX 4070 + WARP (
--test-threads=1):cargo test -p victory-shader --lib --locked -- emit::permlane_tests emit::crosslane_tests emit::lower: 44 passed, 0 failed.permlane_rows_and_inactive_sourcespasses the full Wave32 matrix and skips Wave64.crosslane_testsrun only on hardware, apart from the pipeline-creation test, which also ran on WARP.d3d10warp.dllfrom theMicrosoft.Direct3D.WARPNuGet package, next to the test binary; it reports waves 4..128),permlane_rows_and_inactive_sourcesfails at the same spot steven-seagull27 reported:WARP wave64=false cross=true fi=false bc=false alias=false selectors=[f10e2d3c, 4b5a6978] mask=55555555 lane=4, got0x1234000e(lane 14), expected0x1234001e(lane 30). The other 4 permlane tests, pluscrosslane_testsandemit::lower(39 tests), pass with that DLL. I did not have the separate divergent FI=0 experiment, so I have no numbers for it.--skip heap_direct_texture_reads_mark_their_heap_index, which crashes the test process onmaintoo on this machine): 304 passed, 3 failed. Those 3 also fail onmain63bcca4here (twostride_tests,synthetic_tests::gathers_at_a_level_match_the_hardware).cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.I have the full merge as a patch against
abb811f(git apply-able, 62 files, almost all of it frommain) if that helps. Re-merging and keeping both test entries gives the same result.AI-assisted (Claude Code).
@zed6000 on GitHub · 2026-11-26 00:11 UTC · original
The same merge on AMD, where the Wave64 half of the matrix can run. Head
abb811fmerged ontomain63bcca4, with the onelower.rsconflict resolved as above (keep both test entries, closepermlane16_lowers). The diff againstmainis the PR's 3 files. Windows 11, AMD Radeon RX 7900 XTX (RDNA3), driver's built-in WARP:permlane_rows_and_inactive_sources: the hardware reports waves 32..64, so both the Wave32 and the Wave64 matrices run, and every row and EXEC case passes ("all row and EXEC cases passed on hardware"). The built-in WARP reports 4..4 and skips, as on the 4070.cargo test -p victory-shader --lib --locked -- emit::permlane_tests emit::crosslane_tests emit::lower --test-threads=1: 44 passed, 0 failed (DPP16 18/0, DPP8/DPP8FI 5/0, ds_swizzle 6/0 on hardware).--skip: 308 passed, 0 failed (3 ignored, as onmain). That includesheap_direct_texture_reads_mark_their_heap_index, everystride_teststest andsynthetic_tests::gathers_at_a_level_match_the_hardware. So the crash and the 3 failures seen on the RTX 4070 machine do not show up on this AMD machine, either with this PR or onmain(main63bcca4alone: 302/0 here).cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.Earlier on this PR I measured
abb811fon the title's shaders (on13f91ca): +1, 0 lost. Between this and the 4070 run, the matrix now has hardware results for both wave sizes. The only failing case left is app-local WARP 1.0.22's Wave32 lane 14 vs 30, which points at WARP's handling of the case rather than at the lowering. A lowering that leans on behaviour D3D leaves undefined would look the same, though, so the FI=0 experiment is still worth having.Offline tests only; no program names or data.
@steven-seagull27 on GitHub · 2026-11-26 01:35 UTC · original
@pawrenity @zed6000 Here is the missing divergent FI=0 readback, based directly on
abb811f. It insertss_cbranch_execzaround the two-dword shuffle and reuses the PR's selectors, masks, alias cases and per-lane oracle. Each width runs 200 dispatches of 128 threads. Runnable test commit.With identity selectors,
permlanex16,EXEC=0xffff0000in both halves, FI=0 and BC=0, lane 16 selects inactive lane 0. Its old destination is 42. WARP returned lane 0's0x12340000. The straight-line control still measured exactly 64/51,200 wrong at each WARP width in every process.I also compiled the divergent case independently with DXC as
cs_6_6. Inside the branch I routed each inactive source to the executing destination's own lane beforeWaveReadLaneAt. Selecting source activity directly from the input EXEC bits still gave 64/25,600 wrong on WARP at either wave width with both-O3and-Od. Lane 4 requested active lane 30 and got lane 14. Selecting activity fromWaveActiveBallot(true)inside the branch gave 780/25,600 on Wave32 and 728/25,600 on Wave64 at-O3. RTX returned 0/25,600 in all four supported DXC configurations. These controls reproduce both symptoms outside VIctory's emitter. A passing straight-line run alone doesn't cover divergent FI=0.To run the new fixture against the PR head or your local merge:
The test prints a numerator, denominator and first failing lane for each supported width. An RX 7900 XTX readback on the merged head would give us the missing AMD comparison.
@zed6000 on GitHub · 2026-11-26 02:12 UTC · original
@steven-seagull27 Here's the AMD comparison: your fixture
a5c7407(onabb811f, as committed) on an RX 7900 XTX (RDNA3), Windows 11, which reports waves 32..64. I ran three fresh processes:permlane_fi_zero_under_divergent_execpasses each time. All 6emit::permlane_testspass on the same build, includingpermlane_rows_and_inactive_sourcesin both wave sizes.With your RTX 5080 numbers, that gives 0 wrong on NVIDIA hardware (Wave32) and on AMD hardware in both Wave32 and Wave64, for divergent FI=0. The only adapter that disagrees is Microsoft.Warp 1.0.22, which your DXC-only controls already reproduce outside VIctory's emitter. That fits WARP's handling of reads from inactive lanes under divergence, not the PR's lowering.
Offline tests only; no program names or data.
@steven-seagull27 on GitHub · 2026-11-26 03:38 UTC · original · edited 2026-11-26 03:45 UTC
@jaschinski97-ops I put a fast-forwardable branch on my fork for current
main(63bcca4). It retains your commits, the divergent FI=0 fixture, and both of theds_bpermuteregressions @pawrenity and @zed6000 identified at the merge conflict. Moving the permlane code into its own module also keepslower.rsunder the repository’s size limit.I found a separate correctness issue affecting physical GPUs as well as WARP. Given a scalar that was set differently on either side of an EXEC split, a later scalar compare can select different host lanes. The old check treated that compare as wave-uniform and allowed a fetch-inactive cross-row shuffle to read a lane that had already left the host branch. With a 128-thread synthetic case and an EXEC mask of 1, all 128/128 outputs were wrong on both RTX 5080 and WARP 1.0.22. Lane 0 expected
0x12340010, got0on RTX and0x12340000on WARP. The all-lanes and no-lanes controls matched. Fix and regressionThe new check refuses that shader and still translates a branch on a scalar expression computed entirely from uniform inputs. All nine focused tests passed on Windows. The RTX 5080 returned 0/51,200 mismatches in the straight-line Wave32 matrix and 0/25,600 in the divergent FI=0 matrix. Your original WARP permutation limitation still applies to this branch. @zed6000’s RX 7900 XTX Wave32 and Wave64 results were on the earlier divergent fixture.
To take the branch from the PR head:
WARP follow-up. I also tested a separate integration of this branch with @andrewpozdnakov7-jpg’s #2997. It reuses their four-lane bank reads and captures which lanes will enter the shuffle while all lanes can still vote. On both branch directions the guest keeps the old destination, or uses zero when bound control requests it, if the source took the other edge. Combined commit
Counts are mismatches per run, with 128 threads per group. All three fresh WARP processes agreed, including the original lane 4 → lane 30 case. Inbox WARP reported only four lanes and skipped both widths. A direct merge of the two PRs still had 64 straight-line mismatches per width and hundreds in the skip case. Banked reads alone fixed the straight case. Moving the vote before the split fixed the eligible divergent case.
The software path explicitly declines partially populated waves and nested control flow where it cannot recover the incoming lane mask. Both have compile-time regressions. Across 192 native-path translations covering Wave32/Wave64, both DXIL and the complete binding records matched the direct merge byte for byte. All 18 focused Windows tests, strict shader Clippy and asset policy passed.
To try the combined branch, fetch
refs/heads/codex/pr1737-warp-lane-selectionfrom the same fork. Both original PR histories are included.AI-assisted with Codex. Synthetic shaders and readbacks.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.