Skip to content

Run pixel shader wave operations over helper lanes, as the console does - #2373

Open
Vyto-Line wants to merge 1 commit into
Marvisak:mainfrom
Vyto-Line:helper-lane-waves
Open

Vyto-Line wants to merge 1 commit into
Marvisak:mainfrom
Vyto-Line:helper-lane-waves

Conversation

@Vyto-Line

Copy link
Copy Markdown

The console's wave operations include a pixel shader's helper lanes; the host's leave them out. A loop that serves one lane's value per pass (v_readfirstlane, then the lanes with that value) never serves a helper lane whose value no live lane shares, and a loop over a range taken from a whole-wave min/max gives a helper lane an unreliable range. Such a lane runs to the loop limit; on an RTX 3080 that made single draws of Grand Theft Auto VI's world (PS_VehicleLiveryOff..., PS_Textured_Eight) take longer than the driver allows, which reset the GPU. Each was found with every draw and dispatch made to finish before the next.

Where the host runs shader model 6.7, pixel shaders with wave operations are now emitted as 6.7 with the entry attribute
"waveops-include-helper-lanes" (DXC's [WaveOpsIncludeHelperLanes]); the attribute group is written only into modules that use it, so other shaders' bytes are unchanged. Without 6.7, v_readfirstlane in a pixel shader gives a helper lane its own value: what the console gives it on the pass that serves it.

The setting is part of the translation, so the shader cache keys on it. The RTX 3080 reports 6.7; all of the title's vertex and pixel pipelines build with it. With it, the vehicle draw no longer hangs; another draw (MSR_VS_CascadeShadows_drawskinned) still does.

The console's wave operations include a pixel shader's helper lanes; the
host's leave them out. A loop that serves one lane's value per pass
(v_readfirstlane, then the lanes with that value) never serves a helper
lane whose value no live lane shares, and a loop over a range taken
from a whole-wave min/max gives a helper lane an unreliable range. Such
a lane runs to the loop limit; on an RTX 3080 that made single draws of
Grand Theft Auto VI's world (PS_VehicleLiveryOff..., PS_Textured_Eight)
take longer than the driver allows, which reset the GPU. Each was found
with every draw and dispatch made to finish before the next.

Where the host runs shader model 6.7, pixel shaders with wave operations
are now emitted as 6.7 with the entry attribute
"waveops-include-helper-lanes" (DXC's [WaveOpsIncludeHelperLanes]); the
attribute group is written only into modules that use it, so other
shaders' bytes are unchanged. Without 6.7, v_readfirstlane in a pixel
shader gives a helper lane its own value: what the console gives it on
the pass that serves it.

The setting is part of the translation, so the shader cache keys on it.
The RTX 3080 reports 6.7; all of the title's vertex and pixel pipelines
build with it. With it, the vehicle draw no longer hangs; another draw
(MSR_VS_CascadeShadows_drawskinned) still does.

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

@Melow-code Melow-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two points block this PR. Two points are questions. One point is context.

Blocking: the cache key freezes a value that can be set later

build() builds the key once in a OnceLock. The key now includes helper_lane_waves(). set_helper_lane_waves() runs in Host::create(), after D3D12CreateDevice. Nothing makes create() run before the first build(). If build() runs first, the key freezes with helper_lane_waves() == false. The cache then serves 6.6 translations on a 6.7 host, or the reverse. This is the same OnceLock race that PR #2369 addresses. Fix: set the value before the first key is built, or read the value when the key is used, not when it is frozen.

Blocking: no test

The PR adds 107 lines and no test. Nothing covers the DXIL group-5 attribute (waveops-include-helper-lanes), the 6.7 header (version and shader model), or the select(isHelperLane, a, r) fallback. The repo requires a test that fails before the fix and passes after. Please add one for each change, or say why a test is not possible.

Question: set_function_attr overwrites the attribute

set_function_attr writes funcs[i].attr = Some(attr) with no check. main is created with attr = None, so this is safe today. If main ever carries another attribute, this overwrites it. Should the setter reject an already-set attribute?

Question: two call sites for set_helper_lane_waves

victory-gpu/src/host.rs::create() and victory-shader/src/emit/host.rs both call set_helper_lane_waves(). The two crates share one global AtomicBool. Could the two hosts disagree in one process? Are both call sites needed?

Context: the remaining hang is a vertex shader

The PR notes that MSR_VS_CascadeShadows_drawskinned still hangs. That is a vertex shader, outside this pixel-only fix. This is context, not a defect in this PR.

Assisted-by: DeepSeek V4 Pro (OpenCode)
Generated with Claude Code

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR conflicts with current main (940d32f) in crates/victory-gpu/src/shader_cache.rs and crates/victory-shader/src/emit/lower.rs. Its content will be reviewed once it is rebased.


Generated by Claude Code

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

Helper-lane wave operations gated on SM 6.7 (CheckFeatureSupport), mergeable=False against main 940d32f — needs a rebase. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Note SM 6.7 requires Agility SDK 1.7x — ties to #2383.

@YaBulochka

Copy link
Copy Markdown

Regression data point on the full retail dump: this PR gains 808 programs but loses 3,002, so the net is -2,194 validated.

Method: victory translate shaders.rpf --validate --list, Linux/Wine, dxil.dll 1.9.2609.5, x86_64-pc-windows-gnu release.

Build validated
940d32f (baseline) 23,918
this PR 21,724

Program-by-program (comm on the sorted validated lists):

  • lost 3,002, gained 808, net -2,194;
  • every lost program I sampled now fails with emit: a scalar memory read as data - e.g. MSNC_VS_MirrorReflectionPedTransformSkinD_907647ea_Wrapped at 0x22dc, MS_VS_MirrorReflectionPedTransformDecalsD_db76baa6_Wrapped at 0x1474;
  • the lost set is dominated by MSNC_VS_* / MS_VS_* (mesh and vertex stage), not pixel.

So the helper-lane pixel work does what it says for its own stage (that is presumably the +808), but something in the same tree makes scalar memory reads fail to trace in the mesh/vertex lowering. Worth running this exact command before merging; if you want, I can also bisect the PR's commits to say which one introduces the scalar memory read as data path.

Baseline command and dump are the same as in the #1458 reports.

@YaBulochka

Copy link
Copy Markdown

Correction to my comment above - the regression is not in this PR, and I compared against the wrong baseline.

The PR's merge-base is ffe310e, not 940d32f. Numbers on the same dump, same command:

Build validated
ffe310e (this PR's base) 21,724
this PR (58f0be9) 21,724
940d32f (current main, unrelated to this PR) 23,918

So on its own base this PR is neutral: 21,724 before, 21,724 after, same lost set (emit: a scalar memory read as data on MSNC_VS_*/MS_VS_*). The 3,002 programs I attributed to this PR were already failing at its base; something between ffe310e and 940d32f fixes them.

Apologies for the noise - the fix is to rebase the PR on current main and re-run, where the expected number is 23,918.

notquiteog added a commit to notquiteog/VIctory that referenced this pull request Nov 25, 2026
…me and shader validation (by gomeaw)

Takes the place of the adapter selection hand-ported earlier on this
branch: the pull request also makes the offline pipeline check use the
selected adapter and its wave width, wants shader model 6.6 of it, and
adds VICTORY_D3D12_ADAPTER to pick one by index or name. Kept beside it:
Host::max_wave_lanes (DexNom DexNom#16) and the shader model 6.7 query
(Marvisak Marvisak#2373). README hunk left out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kilolimaVI

Copy link
Copy Markdown

AMD data, Radeon 780M (RDNA3 iGPU, reports SM 6.8), Windows 11, head 58f0be9.

I wrote a hardware test for this: a pixel program (hand-assembled console ISA) that serves one per-pixel key per pass (s_ff1 of EXEC, v_readlane, v_cmpx), then reads the x neighbour's result with DPP quad_perm:[1,0,3,2], drawn as a triangle whose edge crosses quads (16x16, 136 pixels covered). Neighbour results wrong:

780M WARP
main 63bcca4 (wave64 program) 8 18
this PR (wave64 program) 0 0

So the 6.7 path does fix helper lanes on RDNA3 (3/3 runs), and WARP needs it too (it leaves helpers out of waveActiveBallot).

Two problems though:

  1. Every 6.7 pixel shader fails the DXIL validator (Windows SDK dxil.dll): Container part 'Program Output Signature' does not match expected for module. The PR moves dx.valver to 1.7 while container::signature still writes the parts the 1.6 way. The title doesn't run the validator, so it only shows in tests; the numbers above were taken with validation made non-fatal.
  2. It no longer merges onto main (conflicts in victory-gpu/src/host.rs, shader_cache.rs, victory-shader/src/emit/host.rs, lower.rs).

Happy to share the test (emit/helper_lane_tests.rs, ~250 lines, no other changes) if you want it in the PR.

AI-assisted (Claude).

@kilolimaVI

Copy link
Copy Markdown

Follow-up on the validator failure: it comes from dx.valver, not the 6.7 shader model. shader.rs sets both dx.version and dx.valver to 1.7, but container::signature writes the signature parts the way validator 1.6 does. Keeping dx.valver at 1.6 while dx.version and dx.shaderModel go to 6.7 makes the validator accept them:

let valver16 = self.m.md_node(vec![Some(one), Some(six)]);
self.m.named_md("dx.valver", vec![valver16]);

(in place of self.m.named_md("dx.valver", vec![version]);)

With that change on 58f0be9 and validation fatal again, the helper-lane draw test validates and gives 0 wrong neighbours in wave64 on both the Radeon 780M and WARP (main: 8 and 18). The test is now its own PR, #NUMBER, ignored as a defect until a fix like this one lands.

AI-assisted (Claude).

@kilolimaVI

Copy link
Copy Markdown

@Vyto-Line I rebased this onto main 63bcca4 with the validator fix, in case it's useful: https://github.com/kilolimaVI/VIctory/commits/shader/helper-lane-waves

  • Your commit, authorship kept, with the four conflicts resolved: the 6.7 check moved into create_device in emit/host.rs; main's helper_reads_own kept but skipped when helper lanes are on; victory-gpu/host.rs keeps both checks.
  • shader_cache: the folder key is computed when the cache is opened, before any device exists, so helper_lane_waves() was still false there. The flag now keys each entry instead (unchanged on 6.6 hosts).
  • On top: dx.valver stays 1.6 (the validator fix above), and the helper-lane test from my test PR is no longer ignored.

On a Radeon 780M with validation fatal: the helper-lane test gives 0 wrong neighbours on the 780M and on WARP (main: 8 and 18); victory-shader 303 passed, victory-gpu --features diagnostics 246 passed on the 780M and WARP, clippy clean with default and all features.

Feel free to pull it into this PR. If you'd rather I open it as a separate PR that keeps your commit, say so.

AI-assisted (Claude).

@kilolimaVI

Copy link
Copy Markdown

@Vyto-Line since this is labeled "needs rebase" and there was no reply to the rebased branch, I opened #3749 to carry it forward. Your commit is in it unchanged, with your authorship, plus the dx.valver 1.6 fix and the un-ignored helper-lane test (780M: 8 → 0 wrong, WARP: 18 → 0).

If you'd rather update this PR yourself, say so and I'll close #3749.

AI-assisted (Claude).

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.

6 participants