xshader: execute proven nonuniform readlane loops as paired waves #492

Merged
MathiewMay merged 2 commits from upstream-pr/492 into main 2026-11-29 18:04:33 +00:00
MathiewMay commented 2026-11-29 16:05:40 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by MathiewMay on 2026-11-29T16:05:40Z.


Summary

Select existing paired-wave execution for constant lane reads in proven whole-wave64 compute loops that the ordinary path cannot establish as workgroup-convergent. One paired host wave follows one console wave's scalar PC; adjacent waves may take different trip counts without inventing group-wide convergence.

Keep the ordinary proof and its refusals unchanged: complete wave64 groups, supported constant lane reads, valid instruction targets, no indirect PC transfers, no branch bypassing a group barrier, no barrier inside a backward span, and no interleaved loops for automatic selection. Early termination is accepted only after the final group barrier. Ambiguous widths, partial waves and unsafe rendezvous remain refused.

Review revision: retain runaway protection

Addresses the requested high loop limit. Both paired structured loops and paired block dispatch retain a shared 2^24 (16,777,216) watchdog ceiling. Valid loops may exceed the old 65,536 limit, while a translation bug no longer has an entirely unbounded execution path. This is a safety ceiling, not a measured maximum title workload or a guarantee against driver timeouts.

Dispatch uses its own tb_dispatch_guard, including from nonzero entries, so it cannot redeclare or consume a preceding structured loop's tb_guard. The ordinary 65,536-loop / 1,000,000-dispatch guards and existing ordinary-path exemptions are unchanged. The dispatcher counts passes through its block tests, which may follow several forward blocks in one pass.

Tests

  • Original fresh fa1b9cf6 control: 3 behavior regressions fail / 1 negative control passes.
  • New review regressions against the original published uncapped head d4ec835d: 3 watchdog assertions fail / 4 controls pass. These cover structured loops, block dispatch and dispatch from a nonzero entry. Corrected focused tests: 7/7 pass, including unchanged ordinary guards.
  • Translator crate unit/integration tests: 612 + 1 + 2 passed, no failures.
  • Isolated python tuxbox.py check --no-gpu: all seven groups passed.
  • Full translator GPU suite: 65/65 groups passed.
  • Paired GPU group: 66 programs / 4,325,376 compared words / zero mismatches, including all 15 automatic readlane variants and the >65,536-trip case with the high watchdog enabled.
  • Full homebrew/Lanes verification: 123/123 checks passed.
  • Provider regression controls: 22/22 passed.

Final revision is 66a2977d on the original d4ec835d, with upstream baseline fa1b9cf6. Native providers remain unchanged and separately pinned to that baseline; compiler/helpers are built from this exact immutable source. Original artifacts and public-head backup refs are preserved.

The GPU checker exercises normal automatic translation as well as the explicit paired API: SCC/VCC loops, different trip counts in adjacent waves, shared-memory rendezvous, empty/full/sparse EXEC, nested masks, early exits and the retained >65,536-trip case. Outputs are compared word-for-word with an independent instruction/group model and a separately checked arithmetic oracle for the long loop. No deliberately endless GPU workload was launched to test the watchdog.

The host-profile record adds readlane-loop-two-waves for all three profiles. The review revision regenerates its three hashes and the two paired waterfall / two paired dispatcher hashes because the high watchdog changes their emitted HLSL. Ordinary translations remain recorded unchanged.

No new Lanes scenario: exact scalar branch/readlane encodings, divergence between waves and long trip counts are exercised directly in the synthetic translator fixture; existing Lanes suites provide integration coverage. No title shaders or captures are included.

cargo test --locked --offline --target x86_64-unknown-linux-gnu --manifest-path tools/shader-compiler/Cargo.toml
python tuxbox.py check --no-gpu
python "$MEASURE/run_latest_translator.py" "$ARTIFACT" "$TRANSLATOR_WORK"
python "$MEASURE/run_latest_verify.py" "$ARTIFACT" "$VERIFY_WORK"
python "$MEASURE/run_latest_regressions.py" "$ARTIFACT" "$REGRESSION_WORK"

The wrappers pin immutable source/helpers/providers by SHA, run sequentially in an authenticated hidden/offline display, and reuse the stopped fixture prefix without copies. No retail launch or retail rendering/performance claim.

Local GPU/backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, GE-Proton11-14 on Linux.

Maintainer NVIDIA results cover the previous uncapped #493 stack, on main at 065a7f9a: RTX 4070 Ti SUPER (10de:2705), driver 620.x, GE-Proton11-14; 65/65 translator groups and 72 paired programs / 4,718,592 words / zero mismatches. They do not cover this watchdog revision. Updated NVIDIA confirmation remains outstanding before merge; no local NVIDIA run is claimed.

<!-- greyfinch-sync:brcly/TuxBox:issue:5552511807 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/492). Originally posted by [MathiewMay](https://github.com/MathiewMay) on 2026-11-29T16:05:40Z. --- ## Summary Select existing paired-wave execution for constant lane reads in proven whole-wave64 compute loops that the ordinary path cannot establish as workgroup-convergent. One paired host wave follows one console wave's scalar PC; adjacent waves may take different trip counts without inventing group-wide convergence. Keep the ordinary proof and its refusals unchanged: complete wave64 groups, supported constant lane reads, valid instruction targets, no indirect PC transfers, no branch bypassing a group barrier, no barrier inside a backward span, and no interleaved loops for automatic selection. Early termination is accepted only after the final group barrier. Ambiguous widths, partial waves and unsafe rendezvous remain refused. ## Review revision: retain runaway protection Addresses [the requested high loop limit](https://github.com/brcly/TuxBox/pull/492#issuecomment-7258860234). Both paired structured loops and paired block dispatch retain a shared **2^24 (16,777,216)** watchdog ceiling. Valid loops may exceed the old 65,536 limit, while a translation bug no longer has an entirely unbounded execution path. This is a safety ceiling, **not a measured maximum title workload or a guarantee against driver timeouts**. Dispatch uses its own `tb_dispatch_guard`, including from nonzero entries, so it cannot redeclare or consume a preceding structured loop's `tb_guard`. The ordinary 65,536-loop / 1,000,000-dispatch guards and existing ordinary-path exemptions are unchanged. The dispatcher counts passes through its block tests, which may follow several forward blocks in one pass. ## Tests - Original fresh `fa1b9cf6` control: **3 behavior regressions fail / 1 negative control passes**. - New review regressions against the original published uncapped head `d4ec835d`: **3 watchdog assertions fail / 4 controls pass**. These cover structured loops, block dispatch and dispatch from a nonzero entry. Corrected focused tests: **7/7 pass**, including unchanged ordinary guards. - Translator crate unit/integration tests: **612 + 1 + 2 passed**, no failures. - Isolated `python tuxbox.py check --no-gpu`: **all seven groups passed**. - Full translator GPU suite: **65/65 groups passed**. - Paired GPU group: **66 programs / 4,325,376 compared words / zero mismatches**, including all 15 automatic readlane variants and the >65,536-trip case with the high watchdog enabled. - Full homebrew/Lanes verification: **123/123 checks passed**. - Provider regression controls: **22/22 passed**. Final revision is `66a2977d` on the original `d4ec835d`, with upstream baseline `fa1b9cf6`. Native providers remain unchanged and separately pinned to that baseline; compiler/helpers are built from this exact immutable source. Original artifacts and public-head backup refs are preserved. The GPU checker exercises normal automatic translation as well as the explicit paired API: SCC/VCC loops, different trip counts in adjacent waves, shared-memory rendezvous, empty/full/sparse EXEC, nested masks, early exits and the retained **>65,536-trip** case. Outputs are compared word-for-word with an independent instruction/group model and a separately checked arithmetic oracle for the long loop. No deliberately endless GPU workload was launched to test the watchdog. The host-profile record adds `readlane-loop-two-waves` for all three profiles. The review revision regenerates its three hashes and the two paired waterfall / two paired dispatcher hashes because the high watchdog changes their emitted HLSL. Ordinary translations remain recorded unchanged. No new Lanes scenario: exact scalar branch/readlane encodings, divergence between waves and long trip counts are exercised directly in the synthetic translator fixture; existing Lanes suites provide integration coverage. No title shaders or captures are included. ```sh cargo test --locked --offline --target x86_64-unknown-linux-gnu --manifest-path tools/shader-compiler/Cargo.toml python tuxbox.py check --no-gpu python "$MEASURE/run_latest_translator.py" "$ARTIFACT" "$TRANSLATOR_WORK" python "$MEASURE/run_latest_verify.py" "$ARTIFACT" "$VERIFY_WORK" python "$MEASURE/run_latest_regressions.py" "$ARTIFACT" "$REGRESSION_WORK" ``` The wrappers pin immutable source/helpers/providers by SHA, run sequentially in an authenticated hidden/offline display, and reuse the stopped fixture prefix without copies. No retail launch or retail rendering/performance claim. Local GPU/backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, GE-Proton11-14 on Linux. [Maintainer NVIDIA results](https://github.com/brcly/TuxBox/pull/492#issuecomment-7258969153) cover the **previous uncapped #493 stack**, on `main` at `065a7f9a`: RTX 4070 Ti SUPER (10de:2705), driver 620.x, GE-Proton11-14; 65/65 translator groups and 72 paired programs / 4,718,592 words / zero mismatches. They do **not** cover this watchdog revision. **Updated NVIDIA confirmation remains outstanding before merge; no local NVIDIA run is claimed.**
brcly commented 2026-11-29 16:23:03 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T16:23:03Z.


Thanks. This covers the wave64 lane-read loops that are one of our bigger groups of refused programs in GTA VI. One change before we merge, please. It applies to #493 too, since that one is stacked on this.

Please keep a limit on paired loops and the block dispatcher, set high, rather than removing it. I agree valid guest work ends by its own PC and conditions. The limit is there for when the translation is wrong: a bug that makes a loop endless then stops the dispatch, instead of running until the driver's timeout resets the device and takes the game with it. Your >65,536-trip case shows the old cap was too low for real work. A cap far above anything a title plausibly runs (for example 2^24 iterations or blocks) would keep that case working and still bound a runaway loop. If you'd rather tie it to something measured, that's fine too. The point is not to have none.

We'll run the NVIDIA side of the translator GPU checks on #493, which contains this commit, and post the results here.

<!-- greyfinch-sync:brcly/TuxBox:comment:7258860234 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/492#issuecomment-7258860234). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T16:23:03Z. --- Thanks. This covers the wave64 lane-read loops that are one of our bigger groups of refused programs in GTA VI. One change before we merge, please. It applies to #493 too, since that one is stacked on this. **Please keep a limit on paired loops and the block dispatcher, set high, rather than removing it.** I agree valid guest work ends by its own PC and conditions. The limit is there for when the translation is wrong: a bug that makes a loop endless then stops the dispatch, instead of running until the driver's timeout resets the device and takes the game with it. Your >65,536-trip case shows the old cap was too low for real work. A cap far above anything a title plausibly runs (for example 2^24 iterations or blocks) would keep that case working and still bound a runaway loop. If you'd rather tie it to something measured, that's fine too. The point is not to have none. We'll run the NVIDIA side of the translator GPU checks on #493, which contains this commit, and post the results here.
brcly commented 2026-11-29 16:31:21 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T16:31:21Z.


NVIDIA results, as promised. Tree: main at 065a7f9a with #493 merged on top, so this commit is included. RTX 4070 Ti SUPER (10de:2705, 620.x), GE-Proton11-14, tools/check_translator_gpu.py full suite:

  • 65/65 groups pass, 0 failures.
  • paired-wave64: 72 programs, 4,718,592 words compared, 0 mismatches (the same set as your AMD run, including the six new scan variants from #493).
  • lockstep 576 cases, readlane 20/21 (the 64-lane case doesn't run: this host has no 64-lane waves), and all ten wave-guard groups pass.

So the only thing left before merging, for both PRs, is the loop limit from my comment above.

<!-- greyfinch-sync:brcly/TuxBox:comment:7258969153 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/492#issuecomment-7258969153). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T16:31:21Z. --- NVIDIA results, as promised. Tree: `main` at `065a7f9a` with #493 merged on top, so this commit is included. RTX 4070 Ti SUPER (`10de:2705`, 620.x), GE-Proton11-14, `tools/check_translator_gpu.py` full suite: - **65/65 groups pass, 0 failures.** - `paired-wave64`: 72 programs, 4,718,592 words compared, 0 mismatches (the same set as your AMD run, including the six new scan variants from #493). - `lockstep` 576 cases, `readlane` 20/21 (the 64-lane case doesn't run: this host has no 64-lane waves), and all ten `wave-guard` groups pass. So the only thing left before merging, for both PRs, is the loop limit from my comment above.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
brcly/TuxBox!492
No description provided.