Translate 64-bit texture atomics and follow proven shader branches #48

Closed
github-bot wants to merge 1 commit from gh-pr/48/head into gh-pr/48/base
Owner

@⁠flapwarp78 on GitHub · 2026-11-23 23:46 UTC · original
flapwarp78:shader/typed-atomics-and-branch-threading → main · +461 −49 · 6 files · 1 commits · closed without merging

What changed

  • Translate 64-bit texture atomics to native SM 6.6 DXIL. Preserve both halves of the old value when the instruction requests it, and declare the typed-resource and descriptor-heap capability bits.
  • Follow a branch directly when the shader proves its outcome on an incoming edge. This lets a reused register carry a descriptor address on one path and buffer data on the other.
  • Cover both atomic widths and branch cases in regression tests.

Verification

Microsoft's DXIL validator accepted 628 shaders from a local shader-pack scan. Texture atomics recovered 520 translations, and the control-flow change recovered another 108. The first 520 outputs were byte-for-byte identical with the control-flow change applied.

The shader, game, and format suites passed 73 tests. The asset-policy check passed. Rendering in the game still needs a Windows D3D12 run.

**@⁠flapwarp78** on GitHub · 2026-11-23 23:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/48) `flapwarp78:shader/typed-atomics-and-branch-threading` → `main` · +461 −49 · 6 files · 1 commits · closed without merging ## What changed - Translate 64-bit texture atomics to native SM 6.6 DXIL. Preserve both halves of the old value when the instruction requests it, and declare the typed-resource and descriptor-heap capability bits. - Follow a branch directly when the shader proves its outcome on an incoming edge. This lets a reused register carry a descriptor address on one path and buffer data on the other. - Cover both atomic widths and branch cases in regression tests. ## Verification Microsoft's DXIL validator accepted 628 shaders from a local shader-pack scan. Texture atomics recovered 520 translations, and the control-flow change recovered another 108. The first 520 outputs were byte-for-byte identical with the control-flow change applied. The shader, game, and format suites passed 73 tests. The asset-policy check passed. Rendering in the game still needs a Windows D3D12 run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:48:06 +00:00
github-bot closed this pull request 2026-11-26 03:48:06 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-23 23:54 UTC · original

Tested d55ca40 stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.

  • main alone does not build on Linux (E0425 in victory-gpu), so the check uses #39 as the base; the merge is clean.
  • cargo test --workspace: 158 passed, 0 failed, 3 ignored across all test binaries, with no new failure from the 64-bit atomics or the branch-specialization code.
  • No game data used.

AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-23 23:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/48#issuecomment-7117492081) Tested `d55ca40` stacked on **#39** on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `main` alone does not build on Linux (E0425 in `victory-gpu`), so the check uses #39 as the base; the merge is clean. - `cargo test --workspace`: **158 passed, 0 failed, 3 ignored** across all test binaries, with no new failure from the 64-bit atomics or the branch-specialization code. - No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:07 UTC · original

Re-checked the new head 56f0072 stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test --workspace: 155 passed, 0 failed, 3 ignored; merge with #39 clean, same result as at d55ca40.

AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/48#issuecomment-7117734203) Re-checked the new head `56f0072` stacked on **#39** on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test --workspace`: **155 passed, 0 failed, 3 ignored**; merge with #39 clean, same result as at `d55ca40`. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-23 23:58 UTC · original · edited 2026-11-24 00:12 UTC

I verified the texture-atomic change on a physical RTX 5070 (Windows 11, NVIDIA 621.01). On 97c78d1, four 32-bit cases produced the expected texel and the translator rejected all four 64-bit cases. At d55ca40, all eight produced the expected texel.

I used the register sequence in heap_texture_atomic_widths with one thread and one initialized texel. The test covered compare-exchange with a matching and mismatching comparand, addition, and subtraction at both widths. The second atomic added the first operation’s returned value back into the texel. With a 64-bit comparand that differed only in the high word, the final low/high words were 00000006 / 00000012, as calculated on the CPU. The wide add and subtract cases also exercised carry and borrow across the 32-bit boundary.

The device reported typed-resource and descriptor-heap 64-bit atomic support. The SDK DXIL validator accepted each emitted shader, the driver created each compute pipeline, and the queue fence reached 1 before readback. The 32-bit view used R32_UINT and the 64-bit view used R32G32_UINT.

I also matched all nine distinct pixel shaders that had reported the 64-bit atomic error during a local mission-loading run. Offline translation on 97c78d1 reproduced the same error on all nine. With d55ca40, seven translated and passed the SDK validator. The remaining two reached the separate barycentrics read directly limitation. The rebased 56f0072 has the same crates/victory-shader Git tree as the tested revision. The title shaders were only translated and validated offline. Mission rendering is still unverified on this PR.

**@⁠jeremygold02** on GitHub · 2026-11-23 23:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/48#issuecomment-7117572439) · edited 2026-11-24 00:12 UTC I verified the texture-atomic change on a physical RTX 5070 (Windows 11, NVIDIA 621.01). On `97c78d1`, four 32-bit cases produced the expected texel and the translator rejected all four 64-bit cases. At `d55ca40`, all eight produced the expected texel. I used the register sequence in `heap_texture_atomic_widths` with one thread and one initialized texel. The test covered compare-exchange with a matching and mismatching comparand, addition, and subtraction at both widths. The second atomic added the first operation’s returned value back into the texel. With a 64-bit comparand that differed only in the high word, the final low/high words were `00000006 / 00000012`, as calculated on the CPU. The wide add and subtract cases also exercised carry and borrow across the 32-bit boundary. The device reported typed-resource and descriptor-heap 64-bit atomic support. The SDK DXIL validator accepted each emitted shader, the driver created each compute pipeline, and the queue fence reached 1 before readback. The 32-bit view used `R32_UINT` and the 64-bit view used `R32G32_UINT`. I also matched all nine distinct pixel shaders that had reported the 64-bit atomic error during a local mission-loading run. Offline translation on `97c78d1` reproduced the same error on all nine. With `d55ca40`, seven translated and passed the SDK validator. The remaining two reached the separate `barycentrics read directly` limitation. The rebased `56f0072` has the same `crates/victory-shader` Git tree as the tested revision. The title shaders were only translated and validated offline. Mission rendering is still unverified on this PR.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:47 UTC · original

checked: 56f0072 on Linux x86_64 (Debian, kernel 6.12), Rust 1.98.1 (rust-toolchain.toml), cargo -j4. No GPU, no Windows, no game files, no DXIL validator. Others have already reported Windows hardware runs and the Linux workspace on #39; this adds a before/after on main and a few review points.

What I ran (throwaway worktree of the PR head, base 35b054e):

  • cargo test -j4 -p victory-shader -p victory-formats -p victory-game: victory-shader 54 passed, victory-formats 17 passed (3 ignored), victory-game 2 passed, 0 failed. That is 73 passed, which matches the PR text.
  • cargo fmt --check -p victory-shader: no diff.
  • cargo clippy -j4 -p victory-shader --tests: one new warning from this PR: very complex type used (clippy::type_complexity) at lower.rs:157, the handles map key, which now contains a nested (u32, u32). The same command on current main (9aef3d9) only gives the existing dead_code warning for constant_color. A type alias or small key struct would clear it, in case warnings are meant to be zero.
  • Test fails before the fix: I appended atomic_tests::heap_texture_atomic_widths from this PR to main (9aef3d9) and ran it: FAILED with Unsupported { offset: 36, what: "a 64-bit image atomic" } (the 64-bit cases). On the PR it passes. This test runs on Linux; only its optional validator step is Windows-only.
  • Branch threading, before/after: I fed the program from threading.rs (WORDS) through the full emit() with a table SRV + UAV layout. Main refuses it: "GFX10 code at 0x40: a scalar memory read as data is not supported". The PR translates it (2252-byte container); constant_edges returns [(0, 2, 4)]. This shows the retry path is exercised end to end by that program. I did not validate or run the resulting DXIL.
  • Merge check (trial git merge-tree of PR heads): clean with current main and with 17 other open PRs. It conflicts with #54 in emit/mod.rs: both change emit(), #48 wraps it in a retry and #54 adds emit_for.
  • On Linux the PR head alone does not build victory-gpu (E0425 host_resource, also on main); I did not run the full workspace here.

Review notes (none blocking):

  • emit() retries with threading only when the first attempt returned Unsupported. Programs that already translate never take the new path, which fits the "first 520 outputs identical" statement.
  • The 64-bit atomic path reads consistently with the 32-bit one: cmpswap passes (comparand, new value), sub negates at the same width, and with glc the old value is split into v[reg] and v[reg+1], while inactive lanes keep their original data. I only read this; the Windows runs reported above are the real check.
  • Including the full props in the handles key looks like it also fixes a collision between 32-bit and 64-bit views at the same load site.
  • thread_edges ends in unreachable!("threading an incoming edge") for other exit kinds. I could not find a way to reach it from constant_edges, but returning a ShaderError would keep a future change from turning into a panic in the translator.
  • constant_edges threads at most one incoming edge per join (it stops after the first proven one). Fine for correctness; mentioning it in case it is intended.
  • The translator does not check the device caps for 64-bit atomics on typed resources and on descriptor-heap resources (D3D12_FEATURE_DATA_D3D12_OPTIONS9 and OPTIONS11). A device without them would fail at pipeline creation instead of being refused at translation. Reports above are from a device that has both.
  • I did not cross-check the two new shader-feature bit values (0x40_0000, 0x1000_0000) against DXC's DxilConstants.h; there is no DXC here. The Windows validator results from other testers cover them.
  • The threading unit tests check the rewritten IR (block indexes). A test that goes through emit(), like the check above, would also cover the retry itself.

Not verified: Windows/D3D12 runtime, any GPU, DXIL validation, the 628-shader scan (520 + 108), behavior of translated threaded shaders, bit values against DXC.

**@⁠tedin7** on GitHub · 2026-11-24 00:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/48#issuecomment-7118441272) checked: 56f0072 on Linux x86_64 (Debian, kernel 6.12), Rust 1.98.1 (rust-toolchain.toml), `cargo -j4`. No GPU, no Windows, no game files, no DXIL validator. Others have already reported Windows hardware runs and the Linux workspace on #39; this adds a before/after on main and a few review points. What I ran (throwaway worktree of the PR head, base 35b054e): - `cargo test -j4 -p victory-shader -p victory-formats -p victory-game`: victory-shader 54 passed, victory-formats 17 passed (3 ignored), victory-game 2 passed, 0 failed. That is 73 passed, which matches the PR text. - `cargo fmt --check -p victory-shader`: no diff. - `cargo clippy -j4 -p victory-shader --tests`: **one new warning from this PR**: `very complex type used` (clippy::type_complexity) at `lower.rs:157`, the `handles` map key, which now contains a nested `(u32, u32)`. The same command on current main (9aef3d9) only gives the existing dead_code warning for `constant_color`. A type alias or small key struct would clear it, in case warnings are meant to be zero. - Test fails before the fix: I appended `atomic_tests::heap_texture_atomic_widths` from this PR to main (9aef3d9) and ran it: FAILED with `Unsupported { offset: 36, what: "a 64-bit image atomic" }` (the 64-bit cases). On the PR it passes. This test runs on Linux; only its optional validator step is Windows-only. - Branch threading, before/after: I fed the program from `threading.rs` (`WORDS`) through the full `emit()` with a table SRV + UAV layout. Main refuses it: "GFX10 code at 0x40: a scalar memory read as data is not supported". The PR translates it (2252-byte container); `constant_edges` returns `[(0, 2, 4)]`. This shows the retry path is exercised end to end by that program. I did not validate or run the resulting DXIL. - Merge check (trial `git merge-tree` of PR heads): clean with current main and with 17 other open PRs. It conflicts with #54 in `emit/mod.rs`: both change `emit()`, #48 wraps it in a retry and #54 adds `emit_for`. - On Linux the PR head alone does not build `victory-gpu` (E0425 `host_resource`, also on main); I did not run the full workspace here. Review notes (none blocking): - `emit()` retries with threading only when the first attempt returned `Unsupported`. Programs that already translate never take the new path, which fits the "first 520 outputs identical" statement. - The 64-bit atomic path reads consistently with the 32-bit one: cmpswap passes (comparand, new value), `sub` negates at the same width, and with glc the old value is split into `v[reg]` and `v[reg+1]`, while inactive lanes keep their original data. I only read this; the Windows runs reported above are the real check. - Including the full props in the `handles` key looks like it also fixes a collision between 32-bit and 64-bit views at the same load site. - `thread_edges` ends in `unreachable!("threading an incoming edge")` for other exit kinds. I could not find a way to reach it from `constant_edges`, but returning a `ShaderError` would keep a future change from turning into a panic in the translator. - `constant_edges` threads at most one incoming edge per join (it stops after the first proven one). Fine for correctness; mentioning it in case it is intended. - The translator does not check the device caps for 64-bit atomics on typed resources and on descriptor-heap resources (`D3D12_FEATURE_DATA_D3D12_OPTIONS9` and `OPTIONS11`). A device without them would fail at pipeline creation instead of being refused at translation. Reports above are from a device that has both. - I did not cross-check the two new shader-feature bit values (`0x40_0000`, `0x1000_0000`) against DXC's `DxilConstants.h`; there is no DXC here. The Windows validator results from other testers cover them. - The threading unit tests check the rewritten IR (block indexes). A test that goes through `emit()`, like the check above, would also cover the retry itself. Not verified: Windows/D3D12 runtime, any GPU, DXIL validation, the 628-shader scan (520 + 108), behavior of translated threaded shaders, bit values against DXC.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:59 UTC · original

Tested 56f0072 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test -p victory-shader: 54 passed, 0 failed (2 test binaries), including the 2 tests this PR adds.
  • The full workspace still needs #112 for the victory-gpu E0425; the shader crate itself is green.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/48#issuecomment-7118647609) Tested `56f0072` on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test -p victory-shader`: **54 passed, 0 failed** (2 test binaries), including the 2 tests this PR adds. - The full workspace still needs #112 for the `victory-gpu` E0425; the shader crate itself is green. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠SpaghettiMaster545 on GitHub · 2026-11-24 03:20 UTC · original

Tested with the title 56f0072 (this PR), against main and against #305 on the same machine.

  • NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124); Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1. Diag build of the PR merged alone onto main d2a4bae, its own empty VICTORY_CACHE_DIR, scripted keys into story mode, until the host GPU failure (#71, unrelated), compared program by program with a main run made the same way.
  • In the main run, 14 pixel programs stop with a 64-bit image atomic.
  • With this PR: 0 programs stop with that reason; 10 of the 14 translate and their pipelines are made; 2 stop at a later reason; 2 were not reached in this run.
  • 10 more pixel programs run that stopped on main with a scalar memory read as data (7) and a descriptor read only as data (3), presumably from the branch-following part of this PR. 20 gained in all, 0 programs that ran on main stop, and no pipeline is newly refused by the driver.
  • For comparison, #305 under the same conditions: 0 programs stop with that reason and 9 of the 14 run, with nothing else gained.

Not tested

  • AMD GPUs, a release build, the image results themselves (only translation and pipeline creation are compared).

(Claude Code, Claude Opus 5.5: ran the title on each build and compared the logs program by program.)

**@⁠SpaghettiMaster545** on GitHub · 2026-11-24 03:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/48#issuecomment-7121004371) **Tested with the title** `56f0072` (this PR), against `main` and against #305 on the same machine. - NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32.0.16.2124); Ryzen 7 9800X3D; Windows 11 10.0.26100; Rust 1.98.1. Diag build of the PR merged alone onto `main` `d2a4bae`, its own empty `VICTORY_CACHE_DIR`, scripted keys into story mode, until the host GPU failure (#71, unrelated), compared program by program with a `main` run made the same way. - In the `main` run, 14 pixel programs stop with `a 64-bit image atomic`. - With this PR: 0 programs stop with that reason; 10 of the 14 translate and their pipelines are made; 2 stop at a later reason; 2 were not reached in this run. - 10 more pixel programs run that stopped on `main` with `a scalar memory read as data` (7) and `a descriptor read only as data` (3), presumably from the branch-following part of this PR. 20 gained in all, 0 programs that ran on `main` stop, and no pipeline is newly refused by the driver. - For comparison, #305 under the same conditions: 0 programs stop with that reason and 9 of the 14 run, with nothing else gained. **Not tested** - AMD GPUs, a release build, the image results themselves (only translation and pipeline creation are compared). (Claude Code, Claude Opus 5.5: ran the title on each build and compared the logs program by program.)

Pull request closed

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/Marvisak--VIctory!48
No description provided.