Shaders: use one select for the first lane of a split wave #4358

Open
github-bot wants to merge 1 commit from github-bot/gh-4357 into main AGit
Owner

@⁠faycalbaklouti on GitHub · 2026-11-30 19:18 UTC · original
faycalbaklouti:fix/wave32-readfirstlane-single-select → main · +4 −4 · 1 files · 1 commits · open

What it changes

On a wave of 64 split across two host waves, choose the upper half only when the lower half has no active lane and the upper has one. No active lanes means lane zero from the lower half. This is the same four-case truth table as the old nested selects but uses one select. The donor recorded different behavior of the nested form on NVIDIA 595.112.07 and 620.70.06 (0fc1ff58); this PR has not been run on either driver. Related: dfmbrollins/victory-linux-nvidia#2 and fxceless/victory-fork#1518.

Base: 84bd61e2, crates/victory-shader/src/emit/lower.rs:10549–10558.

How it was tested

trust/fix/wave32-readfirstlane-single-select: parent=base; diff-check=pass; Rust syntax=1/1; static witness base=0 head=1
Runtime suites: NOT RUN — live benchmark holds the compute lock.

Pending: victory-shader / split-wave translation and driver validation. This is a source-level check, not a Rust type check or runtime result.

  • GPU/profile: not run on this head; no resolution, upscaling, ray tracing or generated-frame result.
  • Before/after: static preimage and changed behavior above; no new runtime timing.
  • Wave sizes exercised on this head: none.
  • Cargo tests passed on this head: not run.

Checked for overlap

  • Searched open PR descriptions for the mechanism and changed source files. Related: #3402 concerns high-dword mask tracking, not first-lane selection.

Radicle project hub (open-source porting and preservation history): https://radicle.network/nodes/rosa.radicle.network/rad:z3rqQw7796wMbgj8RszExtWR4wMSE
Live development stream: https://vdo.ninja/?view=gta6rtx4090live1080p60

**@⁠faycalbaklouti** on GitHub · 2026-11-30 19:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4357) `faycalbaklouti:fix/wave32-readfirstlane-single-select` → `main` · +4 −4 · 1 files · 1 commits · open ## What it changes On a wave of 64 split across two host waves, choose the upper half only when the lower half has no active lane and the upper has one. No active lanes means lane zero from the lower half. This is the same four-case truth table as the old nested selects but uses one select. The donor recorded different behavior of the nested form on NVIDIA 595.112.07 and 620.70.06 (`0fc1ff58`); this PR has not been run on either driver. Related: dfmbrollins/victory-linux-nvidia#2 and fxceless/victory-fork#1518. Base: `84bd61e2`, `crates/victory-shader/src/emit/lower.rs:10549–10558`. ## How it was tested ```text trust/fix/wave32-readfirstlane-single-select: parent=base; diff-check=pass; Rust syntax=1/1; static witness base=0 head=1 Runtime suites: NOT RUN — live benchmark holds the compute lock. ``` Pending: victory-shader / split-wave translation and driver validation. This is a source-level check, not a Rust type check or runtime result. - GPU/profile: not run on this head; no resolution, upscaling, ray tracing or generated-frame result. - Before/after: static preimage and changed behavior above; no new runtime timing. - Wave sizes exercised on this head: none. - Cargo tests passed on this head: not run. ## Checked for overlap - [x] Searched open PR descriptions for the mechanism and changed source files. Related: #3402 concerns high-dword mask tracking, not first-lane selection. --- **Radicle project hub (open-source porting and preservation history):** https://radicle.network/nodes/rosa.radicle.network/rad:z3rqQw7796wMbgj8RszExtWR4wMSE **Live development stream:** https://vdo.ninja/?view=gta6rtx4090live1080p60
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 19:22:36 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 19:37 UTC · original

Ran this on NVIDIA, since the description says it wasn't: Windows 11, RTX 3060, driver 621.40, Rust 1.98.1 (pinned), applied on current main (e1251c31); cherry-picks cleanly and builds.

The logic is the same. Old: in_lo ? lo : (in_hi ? hi : lo). New: (!in_lo && in_hi) ? hi : lo. In the four cases (low active or not, high active or not), both give lo, lo, hi, lo.

On hardware, the four test files that exercise first-lane reads across halves, on main and with this PR:

main this PR
emit::wave64_tests 47 passed 47 passed
emit::folded_tests 20 passed 20 passed
emit::folded_join_tests 1 passed 1 passed
emit::water_tiles_tests 1 ignored (benchmark) 1 ignored

one_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops runs this path on the GPU, with rounds where both halves are active (lo) and rounds where only the upper half is (hi). To make sure it reaches the new select, I swapped its arms (select(c, upper, lo, hi), not part of this PR), and it fails on the 3060 (hardware, two_blocks=false, kind=firstlane). So the passing run above covers the change. The neither-active case doesn't occur in that test.

One thing for the description: on driver 621.40, main's nested form also passes all of these, so this driver doesn't reproduce the difference recorded on 595.112.07 and 620.70.06. The change is equivalent and passes here, but it doesn't show the old form failing. If the donor's case (0fc1ff58) has a shader that showed it, that would be the test to add.

**@⁠babuakhil** on GitHub · 2026-11-30 19:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4357#issuecomment-7289686871) Ran this on NVIDIA, since the description says it wasn't: Windows 11, RTX 3060, driver 621.40, Rust 1.98.1 (pinned), applied on current `main` (`e1251c31`); cherry-picks cleanly and builds. **The logic is the same.** Old: `in_lo ? lo : (in_hi ? hi : lo)`. New: `(!in_lo && in_hi) ? hi : lo`. In the four cases (low active or not, high active or not), both give `lo`, `lo`, `hi`, `lo`. **On hardware**, the four test files that exercise first-lane reads across halves, on `main` and with this PR: | | `main` | this PR | |---|---|---| | `emit::wave64_tests` | 47 passed | 47 passed | | `emit::folded_tests` | 20 passed | 20 passed | | `emit::folded_join_tests` | 1 passed | 1 passed | | `emit::water_tiles_tests` | 1 ignored (benchmark) | 1 ignored | `one_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops` runs this path on the GPU, with rounds where both halves are active (`lo`) and rounds where only the upper half is (`hi`). To make sure it reaches the new select, I swapped its arms (`select(c, upper, lo, hi)`, not part of this PR), and it fails on the 3060 (`hardware, two_blocks=false, kind=firstlane`). So the passing run above covers the change. The neither-active case doesn't occur in that test. One thing for the description: on driver 621.40, `main`'s nested form also passes all of these, so this driver doesn't reproduce the difference recorded on 595.112.07 and 620.70.06. The change is equivalent and passes here, but it doesn't show the old form failing. If the donor's case (`0fc1ff58`) has a shader that showed it, that would be the test to add.
Author
Owner

@⁠VibeCodeGuy on GitHub · 2026-11-30 22:28 UTC · original

Offline corpus check (every shader container in a v1.0.2.1 dump: 25,699 unique programs), main e1251c31 against main + this PR at 7b1b1cf1.

  • Newly failing: 0. Newly passing: 0.
  • DXIL output changed: 50 programs (50 Cs); 50 of them pass the validator.
The 50 changed programs
  • f83f0ca30c60c3ac Cs DepthOfField:CS_TileClassificationNeighborhood3x3WithLookingGlassMask
  • 2b17036bf3a1d615 Cs DepthOfField:CS_TileClassificationNeighborhood3x3
  • 445c61b3089eb8f0 Cs DepthOfField:CS_TileClassificationNeighborhoodBoundaryWithLookingGlassMask
  • f8a6133bfedc5759 Cs DepthOfField:CS_TileClassificationNeighborhoodBoundary
  • a1f6cdf8874960a9 Cs DistantObjects:CS_DistanceWindowEmissivesCulling
  • b4db8c3785b6fbc5 Cs EntityCoarseVoxelization:CS_EntityCoarseVoxelization
  • c6a4ca484a40cc64 Cs GpuParticleEmit:CS_EmitCounts_WaterSim
  • 0bf394f8aa729a58 Cs GpuParticleEmit:CS_Emit_AppendAddCPURequests
  • cd5aaf9ca7c2d8ee Cs GpuParticleEmit:CS_Emit_Static_Box
  • df3cf10a274e26ca Cs GpuParticleEmit:CS_Emit_Static_Cylinder
  • 06cf47dbd76827cd Cs GpuParticleEmit:CS_Emit_Static_Sphere
  • fd6e1cbec58e93a9 Cs GpuParticleEmit:CS_Emit_WaterSim
  • eab96ed5d1684967 Cs cascadeshadows_classify:CS_ShadowUnifiedClearRT
  • 0c028454b58543f0 Cs cascadeshadows_classify:CS_ShadowUnifiedClearRaster
  • 4e9b58cc637d9272 Cs cascadeshadows_classify:CS_WriteRTClassificationResults
  • b8f3f7979d6bbc50 Cs cascadeshadows_classify:CS_WriteRasterClassificationResults
  • 45f0c5430e25b956 Cs gimg_renderer:CS_GenerateGeomImagePatches
  • 92c12c7a7d607a9a Cs hair_resolve:CS_GenBlurArgs
  • 2809db6c31de483d Cs indirect_diffuse_lighting:CS_GenerateRayBinOffsets
  • a953d5b93efe8424 Cs indirect_diffuse_lighting:CS_ScreenProbes_TraceRays_Fallback
  • e07a678d3f79d4cd Cs indirect_light_probes:CS_IrradianceCache_RegisterAllocationRequests
  • 14264103296aa43a Cs indirect_light_probes:CS_Primary_RegisterAllocationRequests
  • 119ee96f602f1668 Cs lens_flares:CS_MergeQuads
  • 0ea6fac38d096770 Cs shadowmask:CS_DenoiseShadowMaskLDSPacked
  • a7ea75e2653e54d1 Cs shadowmask:CS_DenoiseShadowMaskLDS
  • e99d19aac5b0bcb4 Cs smh_modify:CS_CalculateFireVolumes
  • 9d1d228b02e56a96 Cs sr_tracing:CS_GenerateRayBinOffsets
  • fd8393c7f4e0e3da Cs sr_tracing:CS_RayPrePass_Opaque
  • 058b0f6379a8e312 Cs terrain_virtual_texture:CS_ComputeFeedbackList
  • fef7c913d65ac121 Cs trailmapCompute:CS_TrailMapDepthBlur_ClassifyAndClearMask
  • 227a043578e42fd8 Cs trailmapCompute:CS_TrailMapDepthBlur_Classify
  • c5cb8ef6e18af21a Cs trailmapCompute:CS_TrailMapFullBlur_Classify
  • 1372e2d51663b33d Cs vfx_proj_decal_trail:CS_DefragHeap_RelocateAllocations
  • 5c85d508f4659843 Cs vfx_proj_decal_trail:CS_RelocateProjDecalTrailNodes
  • 80e25fa666764942 Cs vfx_proj_decal_trail:CS_RelocateProjDecalTrail
  • 0e90505eff274aa4 Cs vfx_proj_decal_vbuffer:CS_ProjDecalClassify
  • c85cb6bc1cd8e2ad Cs vfx_triangleClip:CS_DefragHeap_RelocateAllocations
  • 339d476c267c03c7 Cs vfx_triangleClip:CS_RelocateVfxStartIndexLocation
  • 6d5e8adf383092f1 Cs vfx_vegetation:CSVegetationPtFxBulletGpuSpawn
  • e75ab410050ae3e0 Cs vfx_vegetation:CSVegetationPtFxOBBGpuSpawn
  • cbf9b65f2249ba96 Cs water_micro_geom_renderer:CS_CullWaterPatchesUsingCalmingInfo
  • d44aa899b31c6491 Cs water_micro_geom_renderer:CS_CullWaterPatches
  • 73ac67482f6b6a5d Cs water_micro_geom_renderer:CS_GenerateWaterPatchWritingJobs_WithLODStitching
  • e918b781c12d5815 Cs water_micro_geom_renderer:CS_GenerateWaterPatchWritingJobs
  • 8955e67c20fcd59a Cs water_micro_geom_renderer:CS_GenerateWaterPatches_WithLODStitching
  • 45c1a23674cc965e Cs water_micro_geom_renderer:CS_GenerateWaterPatches
  • 1aa247ed3653b616 Cs water_shading:CS_TransmissionVolumetrics_GenerateTiles
  • ac11be2c8599804e Cs water_shading:CS_VolumePortalTiling_Generate
  • 9ba86fa7dcb9f314 Cs water_underwater_mask_mesh_helper:CS_SurfacePrimitives
  • 3d828e61f0b6bddd Cs water_underwater_mask_mesh_helper:CS_SurfacePrimitives_Meshlets

How: victory translate <dump> --validate --list built for each side (release, cross-built with cargo-xwin, run under Wine), VICTORY_HOST_WAVE=32, plus the four shader-cache-key settings play starts with (VICTORY_EARLY_DEPTH=1, VICTORY_NAN_SCRUB=1, VICTORY_BVH_MISS=1, VICTORY_SAMPLED_MARKS=1). Validator: dxil.dll from DXC v1.9.2609. "Changed" compares translate's emitted hash of each module and its bindings. There was no GPU on this side, so no host pipelines were made and nothing was run on a card. On main the same run has 72 failures: 71 mesh programs over the 32 KiB output limit (the known shortcut in mesh_prologue) and CS_TraceShadowRays_FullAdaptive (#2993).

This is the translation and validation check the description lists as pending, at 32 lanes only. It says nothing about what the drivers do with the new select.

**@⁠VibeCodeGuy** on GitHub · 2026-11-30 22:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4357#issuecomment-7293898681) **Offline corpus check** (every shader container in a v1.0.2.1 dump: 25,699 unique programs), `main` e1251c31 against `main` + this PR at 7b1b1cf1. - Newly failing: **0**. Newly passing: **0**. - DXIL output changed: **50** programs (50 Cs); 50 of them pass the validator. <details><summary>The 50 changed programs</summary> - `f83f0ca30c60c3ac` Cs `DepthOfField:CS_TileClassificationNeighborhood3x3WithLookingGlassMask` - `2b17036bf3a1d615` Cs `DepthOfField:CS_TileClassificationNeighborhood3x3` - `445c61b3089eb8f0` Cs `DepthOfField:CS_TileClassificationNeighborhoodBoundaryWithLookingGlassMask` - `f8a6133bfedc5759` Cs `DepthOfField:CS_TileClassificationNeighborhoodBoundary` - `a1f6cdf8874960a9` Cs `DistantObjects:CS_DistanceWindowEmissivesCulling` - `b4db8c3785b6fbc5` Cs `EntityCoarseVoxelization:CS_EntityCoarseVoxelization` - `c6a4ca484a40cc64` Cs `GpuParticleEmit:CS_EmitCounts_WaterSim` - `0bf394f8aa729a58` Cs `GpuParticleEmit:CS_Emit_AppendAddCPURequests` - `cd5aaf9ca7c2d8ee` Cs `GpuParticleEmit:CS_Emit_Static_Box` - `df3cf10a274e26ca` Cs `GpuParticleEmit:CS_Emit_Static_Cylinder` - `06cf47dbd76827cd` Cs `GpuParticleEmit:CS_Emit_Static_Sphere` - `fd6e1cbec58e93a9` Cs `GpuParticleEmit:CS_Emit_WaterSim` - `eab96ed5d1684967` Cs `cascadeshadows_classify:CS_ShadowUnifiedClearRT` - `0c028454b58543f0` Cs `cascadeshadows_classify:CS_ShadowUnifiedClearRaster` - `4e9b58cc637d9272` Cs `cascadeshadows_classify:CS_WriteRTClassificationResults` - `b8f3f7979d6bbc50` Cs `cascadeshadows_classify:CS_WriteRasterClassificationResults` - `45f0c5430e25b956` Cs `gimg_renderer:CS_GenerateGeomImagePatches` - `92c12c7a7d607a9a` Cs `hair_resolve:CS_GenBlurArgs` - `2809db6c31de483d` Cs `indirect_diffuse_lighting:CS_GenerateRayBinOffsets` - `a953d5b93efe8424` Cs `indirect_diffuse_lighting:CS_ScreenProbes_TraceRays_Fallback` - `e07a678d3f79d4cd` Cs `indirect_light_probes:CS_IrradianceCache_RegisterAllocationRequests` - `14264103296aa43a` Cs `indirect_light_probes:CS_Primary_RegisterAllocationRequests` - `119ee96f602f1668` Cs `lens_flares:CS_MergeQuads` - `0ea6fac38d096770` Cs `shadowmask:CS_DenoiseShadowMaskLDSPacked` - `a7ea75e2653e54d1` Cs `shadowmask:CS_DenoiseShadowMaskLDS` - `e99d19aac5b0bcb4` Cs `smh_modify:CS_CalculateFireVolumes` - `9d1d228b02e56a96` Cs `sr_tracing:CS_GenerateRayBinOffsets` - `fd8393c7f4e0e3da` Cs `sr_tracing:CS_RayPrePass_Opaque` - `058b0f6379a8e312` Cs `terrain_virtual_texture:CS_ComputeFeedbackList` - `fef7c913d65ac121` Cs `trailmapCompute:CS_TrailMapDepthBlur_ClassifyAndClearMask` - `227a043578e42fd8` Cs `trailmapCompute:CS_TrailMapDepthBlur_Classify` - `c5cb8ef6e18af21a` Cs `trailmapCompute:CS_TrailMapFullBlur_Classify` - `1372e2d51663b33d` Cs `vfx_proj_decal_trail:CS_DefragHeap_RelocateAllocations` - `5c85d508f4659843` Cs `vfx_proj_decal_trail:CS_RelocateProjDecalTrailNodes` - `80e25fa666764942` Cs `vfx_proj_decal_trail:CS_RelocateProjDecalTrail` - `0e90505eff274aa4` Cs `vfx_proj_decal_vbuffer:CS_ProjDecalClassify` - `c85cb6bc1cd8e2ad` Cs `vfx_triangleClip:CS_DefragHeap_RelocateAllocations` - `339d476c267c03c7` Cs `vfx_triangleClip:CS_RelocateVfxStartIndexLocation` - `6d5e8adf383092f1` Cs `vfx_vegetation:CSVegetationPtFxBulletGpuSpawn` - `e75ab410050ae3e0` Cs `vfx_vegetation:CSVegetationPtFxOBBGpuSpawn` - `cbf9b65f2249ba96` Cs `water_micro_geom_renderer:CS_CullWaterPatchesUsingCalmingInfo` - `d44aa899b31c6491` Cs `water_micro_geom_renderer:CS_CullWaterPatches` - `73ac67482f6b6a5d` Cs `water_micro_geom_renderer:CS_GenerateWaterPatchWritingJobs_WithLODStitching` - `e918b781c12d5815` Cs `water_micro_geom_renderer:CS_GenerateWaterPatchWritingJobs` - `8955e67c20fcd59a` Cs `water_micro_geom_renderer:CS_GenerateWaterPatches_WithLODStitching` - `45c1a23674cc965e` Cs `water_micro_geom_renderer:CS_GenerateWaterPatches` - `1aa247ed3653b616` Cs `water_shading:CS_TransmissionVolumetrics_GenerateTiles` - `ac11be2c8599804e` Cs `water_shading:CS_VolumePortalTiling_Generate` - `9ba86fa7dcb9f314` Cs `water_underwater_mask_mesh_helper:CS_SurfacePrimitives` - `3d828e61f0b6bddd` Cs `water_underwater_mask_mesh_helper:CS_SurfacePrimitives_Meshlets` </details> How: `victory translate <dump> --validate --list` built for each side (release, cross-built with cargo-xwin, run under Wine), `VICTORY_HOST_WAVE=32`, plus the four shader-cache-key settings `play` starts with (`VICTORY_EARLY_DEPTH=1`, `VICTORY_NAN_SCRUB=1`, `VICTORY_BVH_MISS=1`, `VICTORY_SAMPLED_MARKS=1`). Validator: `dxil.dll` from DXC v1.9.2609. "Changed" compares translate's `emitted` hash of each module and its bindings. There was no GPU on this side, so no host pipelines were made and nothing was run on a card. On `main` the same run has 72 failures: 71 mesh programs over the 32 KiB output limit (the known shortcut in `mesh_prologue`) and `CS_TraceShadowRays_FullAdaptive` (#2993). This is the translation and validation check the description lists as pending, at 32 lanes only. It says nothing about what the drivers do with the new select.
github-bot force-pushed github-bot/gh-4357 from 7b1b1cf1f8 to 3615d2c3b9 2026-12-01 00:46:40 +00:00 Compare
Author
Owner

@⁠faycalbaklouti on GitHub · 2026-12-01 00:44 UTC · original

Thanks, @⁠babuakhil, for the hardware run and swapped-arm check, and @⁠VibeCodeGuy for the corpus comparison.

On an RTX PRO 4500 Blackwell with NVIDIA 620.70.06 through GE-Proton/Wine + vkd3d-proton, I tested 7d93ee07 and the #4358 patch cherry-picked onto it (3db7a3abb). Both passed wave64 (47), folded (20), and folded-join (1). Water tiles was ignored by default and passed all 200 cases when run explicitly on each. The separate divergent-loop test passed on both, with GPU readbacks matching the oracle for first-lane, reduction, and ballot in both loop layouts. I did not reproduce a failure of the nested form in these tests.

0fc1ff58 does have a donor case: the original tile-sort histogram/scatter with a CPU oracle. It explicitly reports a wrong nested-form result on 595.112.07 and a correct result on 620.70.06. I recovered the oracle, but not the two original containers it needs, so I did not rerun that case. I would narrow the description to the historical 595.112.07 observation and the 620.70.06 results above, and not add a regression test without a case that distinguishes the two forms.

**@⁠faycalbaklouti** on GitHub · 2026-12-01 00:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4357#issuecomment-7296674899) Thanks, @⁠babuakhil, for the hardware run and swapped-arm check, and @⁠VibeCodeGuy for the corpus comparison. On an RTX PRO 4500 Blackwell with NVIDIA 620.70.06 through GE-Proton/Wine + vkd3d-proton, I tested `7d93ee07` and the #4358 patch cherry-picked onto it (`3db7a3abb`). Both passed wave64 (47), folded (20), and folded-join (1). Water tiles was ignored by default and passed all 200 cases when run explicitly on each. The separate divergent-loop test passed on both, with GPU readbacks matching the oracle for first-lane, reduction, and ballot in both loop layouts. I did not reproduce a failure of the nested form in these tests. `0fc1ff58` does have a donor case: the original tile-sort histogram/scatter with a CPU oracle. It explicitly reports a wrong nested-form result on 595.112.07 and a correct result on 620.70.06. I recovered the oracle, but not the two original containers it needs, so I did not rerun that case. I would narrow the description to the historical 595.112.07 observation and the 620.70.06 results above, and not add a regression test without a case that distinguishes the two forms.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4358/head:github-bot/gh-4357'
git switch 'github-bot/gh-4357'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4357'
git switch 'github-bot/gh-4357'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4357'
git switch 'github-bot/gh-4357'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4357'
git switch 'main'
git merge --squash 'github-bot/gh-4357'
git switch 'main'
git merge --ff-only 'github-bot/gh-4357'
git switch 'main'
git merge 'github-bot/gh-4357'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4358
No description provided.