Shaders: mark buffer getDimensions heap handles non-uniform for AMD #452

Open
MalfoyDraco99 wants to merge 2 commits from upstream-pr/452 into main
MalfoyDraco99 commented 2026-11-25 01:02:03 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MalfoyDraco99 on 2026-11-25T01:02:03Z.


Problem

Addresses part of #120 and #145.

On AMD RDNA 4 GPUs (tested on RX 9060 XT, driver 32.0.32029.2010), amdxc64.dll+0x861b9f crashes (0xc0000005, null read at +0x8) inside CreateComputePipelineState on live dx.op.getDimensions calls over heap-indexed ByteAddressBuffer handles marked uniform (createHandleFromHeap(..., nonUniformIndex = false)) inside divergent control flow, even though the emitted DXIL passes dxil.dll validation.

This is a separate trigger from the cross-block REUSE pass crash addressed in #195 / #317 — it reproduces even with VICTORY_SHADER_OPT=0 (including compute shader f16876929fa64f9f, which #195 still had to skip).

Fix

  • Added Shader::heap_handle_for_buffer_dim in crates/victory-shader/src/emit/shader.rs to emit nonUniformIndex = true specifically for buffer getDimensions handles without distorting nonuniform_handles.
  • Updated descriptor_data in crates/victory-shader/src/emit/lower.rs to use heap_handle_for_buffer_dim for non-waterfall buffer getDimensions without caching the handle in self.handles, keeping normal buffer loads/stores uniform.
  • Added host-compilation regression test raw_buffer_get_dimensions_compiles_on_host in crates/victory-shader/src/emit/mod.rs lowering a synthetic 19-dword GFX10 compute shader with a divergent branch through the full pipeline (reproduces amdxc64.dll+0x861b9f with nonUniformIndex = false on RX 9060 XT; passes DXIL validation and CreateComputePipelineState with this fix, and skips cleanly on software adapters / hosted CI).

Tested

  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --workspace --locked
  • Verified on AMD Radeon RX 9060 XT (driver 32.0.32029.2010, Windows 11, Rust 1.98.1): f16876929fa64f9f passes dxil.dll validation and CreateComputePipelineState, and title launch ran past frame 512 with zero amdxc64.dll crashes.
<!-- greyfinch-sync:fxceless/victory-fork:issue:5483074855 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/452). Originally posted by [MalfoyDraco99](https://github.com/MalfoyDraco99) on 2026-11-25T01:02:03Z. --- ### Problem Addresses part of #120 and #145. On AMD RDNA 4 GPUs (tested on RX 9060 XT, driver `32.0.32029.2010`), `amdxc64.dll+0x861b9f` crashes (`0xc0000005`, null read at `+0x8`) inside `CreateComputePipelineState` on live `dx.op.getDimensions` calls over heap-indexed `ByteAddressBuffer` handles marked uniform (`createHandleFromHeap(..., nonUniformIndex = false)`) inside divergent control flow, even though the emitted DXIL passes `dxil.dll` validation. This is a separate trigger from the cross-block `REUSE` pass crash addressed in #195 / #317 — it reproduces even with `VICTORY_SHADER_OPT=0` (including compute shader `f16876929fa64f9f`, which #195 still had to skip). ### Fix - Added `Shader::heap_handle_for_buffer_dim` in `crates/victory-shader/src/emit/shader.rs` to emit `nonUniformIndex = true` specifically for buffer `getDimensions` handles without distorting `nonuniform_handles`. - Updated `descriptor_data` in `crates/victory-shader/src/emit/lower.rs` to use `heap_handle_for_buffer_dim` for non-waterfall buffer `getDimensions` without caching the handle in `self.handles`, keeping normal buffer loads/stores uniform. - Added host-compilation regression test `raw_buffer_get_dimensions_compiles_on_host` in `crates/victory-shader/src/emit/mod.rs` lowering a synthetic 19-dword GFX10 compute shader with a divergent branch through the full pipeline (reproduces `amdxc64.dll+0x861b9f` with `nonUniformIndex = false` on RX 9060 XT; passes DXIL validation and `CreateComputePipelineState` with this fix, and skips cleanly on software adapters / hosted CI). ### Tested - `cargo clippy --workspace --all-targets --locked -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo test --workspace --locked` - Verified on AMD Radeon RX 9060 XT (driver `32.0.32029.2010`, Windows 11, Rust 1.98.1): `f16876929fa64f9f` passes `dxil.dll` validation and `CreateComputePipelineState`, and title launch ran past frame 512 with zero `amdxc64.dll` crashes.
Frtuchinno commented 2026-11-25 02:10:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Frtuchinno on 2026-11-25T01:38:07Z.


An RDNA3 data point for this change. The synthetic test doesn't reproduce the crash on this card.

Setup: AMD Radeon RX 7800 XT (RDNA3), driver 32.0.32029.2010, Windows 11 Pro build 26300, Rust 1.98.1, this PR's head f80fd26.

  • raw_buffer_get_dimensions_compiles_on_host passes. I added prints to the test locally: dxil.dll validates the shader and CreateComputePipelineState succeeds on the hardware device, so it isn't skipping silently.
  • The test builds its getDimensions handle with the new heap_handle_for_buffer_dim, so it always takes the fixed path and can't fail without the change. I copied it with the one handle main emits, s.heap_handle(e, idx, false, false, (11, 0)) (uniform), and that pipeline also validates and is created on the 7800 XT, with no crash in amdxc64.dll.
  • cargo test -p victory-shader --locked on this branch: 215 passed, 0 failed, 3 ignored.

So on RDNA3 with this driver, this synthetic shader doesn't hit the crash either way. Either the crash is RDNA4-specific (#120 and #145 are on RX 9070 XT), or it needs something the captured program has and this shader doesn't. If the captured program has a shape that crashes on the old path, building the test from it, with the old handle as the failing case, would make it a regression test. I'm happy to run such a version on this card.

AI-assisted (Claude Code): it ran the tests and the uniform-handle variant on my machine and drafted this.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149777004 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/452#issuecomment-7149777004). Originally posted by [Frtuchinno](https://github.com/Frtuchinno) on 2026-11-25T01:38:07Z. --- An RDNA3 data point for this change. The synthetic test doesn't reproduce the crash on this card. **Setup:** AMD Radeon RX 7800 XT (RDNA3), driver 32.0.32029.2010, Windows 11 Pro build 26300, Rust 1.98.1, this PR's head `f80fd26`. - `raw_buffer_get_dimensions_compiles_on_host` passes. I added prints to the test locally: `dxil.dll` validates the shader and `CreateComputePipelineState` succeeds on the hardware device, so it isn't skipping silently. - The test builds its `getDimensions` handle with the new `heap_handle_for_buffer_dim`, so it always takes the fixed path and can't fail without the change. I copied it with the one handle `main` emits, `s.heap_handle(e, idx, false, false, (11, 0))` (uniform), and that pipeline also validates and is created on the 7800 XT, with no crash in `amdxc64.dll`. - `cargo test -p victory-shader --locked` on this branch: 215 passed, 0 failed, 3 ignored. So on RDNA3 with this driver, this synthetic shader doesn't hit the crash either way. Either the crash is RDNA4-specific (#120 and #145 are on RX 9070 XT), or it needs something the captured program has and this shader doesn't. If the captured program has a shape that crashes on the old path, building the test from it, with the old handle as the failing case, would make it a regression test. I'm happy to run such a version on this card. AI-assisted (Claude Code): it ran the tests and the uniform-handle variant on my machine and drafted this.
MalfoyDraco99 commented 2026-11-25 04:11:20 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MalfoyDraco99 on 2026-11-25T03:17:03Z.


@Frtuchinno
Good catch — switching the original single-block test back to nonUniformIndex = false didn't crash on my card either.

I've pushed an updated raw_buffer_get_dimensions_compiles_on_host that lowers a synthetic 19-dword GFX10 compute shader through the full pipeline (ir::build -> structure -> resource::track -> io::raise -> lower) with a divergent branch (v_cmp_gt_u32 / s_and_saveexec_b32 / s_cbranch_execz) containing the SRV s_load_dwordx4, buffer getDimensions (v_mov_b32 v0, s10), and buffer_load_dword.

Setup: AMD Radeon RX 9060 XT (RDNA4), driver 32.0.32029.2010, Windows 11, Rust 1.98.1

  • Uniform handle (nonUniformIndex = false): reproduces amdxc64.dll+0x861b9f (0xc0000005)
  • Fixed handle (heap_handle_for_buffer_dim, nonUniformIndex = true): passes DXIL validation and Host::compute_pipeline
  • cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings and cargo test --workspace --locked pass

If you have a moment to re-test this version on your RX 7800 XT (same driver), it'd be useful to see whether the divergent-branch shape also hits amdxc64.dll on RDNA3 or stays RDNA4-specific like #120 / #145.

AI-assisted (Gemini 4 Hydrogen): minimized the synthetic reproducer, ran the tests/clippy checks, and helped draft this.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7151768614 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/452#issuecomment-7151768614). Originally posted by [MalfoyDraco99](https://github.com/MalfoyDraco99) on 2026-11-25T03:17:03Z. --- @Frtuchinno Good catch — switching the original single-block test back to `nonUniformIndex = false` didn't crash on my card either. I've pushed an updated `raw_buffer_get_dimensions_compiles_on_host` that lowers a synthetic 19-dword GFX10 compute shader through the full pipeline (`ir::build` -> `structure` -> `resource::track` -> `io::raise` -> `lower`) with a divergent branch (`v_cmp_gt_u32` / `s_and_saveexec_b32` / `s_cbranch_execz`) containing the SRV `s_load_dwordx4`, buffer `getDimensions` (`v_mov_b32 v0, s10`), and `buffer_load_dword`. **Setup:** AMD Radeon RX 9060 XT (RDNA4), driver `32.0.32029.2010`, Windows 11, Rust 1.98.1 - **Uniform handle (`nonUniformIndex = false`):** reproduces `amdxc64.dll+0x861b9f` (`0xc0000005`) - **Fixed handle (`heap_handle_for_buffer_dim`, `nonUniformIndex = true`):** passes DXIL validation and `Host::compute_pipeline` - `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` and `cargo test --workspace --locked` pass If you have a moment to re-test this version on your RX 7800 XT (same driver), it'd be useful to see whether the divergent-branch shape also hits `amdxc64.dll` on RDNA3 or stays RDNA4-specific like #120 / #145. AI-assisted (Gemini 4 Hydrogen): minimized the synthetic reproducer, ran the tests/clippy checks, and helped draft this.
MamaLeVrai commented 2026-11-25 11:10:42 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T10:59:27Z.


Test report: this PR's head no longer merges into main f85101b (RX 6950 XT machine; a trial merge): conflict in crates/victory-shader/src/emit/lower.rs. I did not resolve it. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7160440205 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/452#issuecomment-7160440205). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T10:59:27Z. --- Test report: this PR's head no longer merges into `main` `f85101b` (RX 6950 XT machine; a trial merge): conflict in `crates/victory-shader/src/emit/lower.rs`. I did not resolve it. No game data. AI-assisted (Claude Code); no game data.
Granite900 commented 2026-11-26 21:36:26 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Granite900 on 2026-11-26T21:36:26Z.


A test report from RDNA 4, from the title itself rather than a synthetic shader. No game data.

Setup: AMD Radeon RX 9070 XT 16 GB (RDNA 4), driver 32.0.32029.2010, Ryzen 7 9850X3D, 32 GB RAM, Windows 11, Rust 1.98.1. Base 52ac4ec (current main), release build, no VICTORY_* switches set.

What I tested: this PR's code change on top of 52ac4ec. The changes to lower.rs and shader.rs are line-for-line those of f80fd266 (I took them through ka1qux/BRVIctory-ka1qux dc502e1, which ports it). I did not build the reworked test from 95b1975c.

In the title, same build with and without the change:

  • Without it: the opening cutscene reached its first title card, then the process died 3 min 15 s in with 0xc0000005 at amdxc64.dll+0x861b9f (a read at 0x8), inside CreateComputePipelineState for a compute pipeline.
  • With it: the opening cutscenes played on for 8 min 37 s past that point, with no exception in the driver and a clean exit.

Every shader in the package, no game session (victory translate <game dir> --pipelines, which builds a host pipeline for each emitted shader):

  • Without the change: it crashes after 3 min 10 s, again at amdxc64.dll+0x861b9f (Windows Application event 1000).
  • With it: exit 0. 26,148 of 26,148 programs translated, and a pipeline was built for every emitted shader: 14,249 vertex/pixel, 2,729 compute and 8,765 mesh.

The conflict with main (reported above) is one hunk in lower.rs, at the buffer getDimensions handle. main now builds the (first, props, image, uav, used) tuple in a block and defines src before let h = self.handle(site, &src, false, props)?;. I kept main's lines and replaced only that let h = … with this PR's if image.is_none() && !per_lane { … } else { … }. With that, cargo test -p victory-shader passes (234 tests) and clippy on the crate is clean with -D warnings.

One more thing for the rebase: HostShader gained a half_views field on main (58de9bf), so the test's HostShader { … } literal needs half_views: Vec::new(), to compile. I hit this with the earlier test and added that line. 95b1975c's literal is missing it too.

With the uniform handle put back into the earlier single-block test, that test still passes on this card, as it did on the 7800 XT. On RDNA 4 here, the crash needed the title's own shaders.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7203888242 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/452#issuecomment-7203888242). Originally posted by [Granite900](https://github.com/Granite900) on 2026-11-26T21:36:26Z. --- A test report from RDNA 4, from the title itself rather than a synthetic shader. No game data. **Setup:** AMD Radeon RX 9070 XT 16 GB (RDNA 4), driver 32.0.32029.2010, Ryzen 7 9850X3D, 32 GB RAM, Windows 11, Rust 1.98.1. Base `52ac4ec` (current `main`), release build, no `VICTORY_*` switches set. **What I tested:** this PR's code change on top of `52ac4ec`. The changes to `lower.rs` and `shader.rs` are line-for-line those of `f80fd266` (I took them through ka1qux/BRVIctory-ka1qux `dc502e1`, which ports it). I did not build the reworked test from `95b1975c`. **In the title, same build with and without the change:** - Without it: the opening cutscene reached its first title card, then the process died 3 min 15 s in with `0xc0000005` at `amdxc64.dll+0x861b9f` (a read at 0x8), inside `CreateComputePipelineState` for a compute pipeline. - With it: the opening cutscenes played on for 8 min 37 s past that point, with no exception in the driver and a clean exit. **Every shader in the package, no game session** (`victory translate <game dir> --pipelines`, which builds a host pipeline for each emitted shader): - Without the change: it crashes after 3 min 10 s, again at `amdxc64.dll+0x861b9f` (Windows Application event 1000). - With it: exit 0. 26,148 of 26,148 programs translated, and a pipeline was built for every emitted shader: 14,249 vertex/pixel, 2,729 compute and 8,765 mesh. **The conflict with `main`** (reported above) is one hunk in `lower.rs`, at the buffer `getDimensions` handle. `main` now builds the `(first, props, image, uav, used)` tuple in a block and defines `src` before `let h = self.handle(site, &src, false, props)?;`. I kept `main`'s lines and replaced only that `let h = …` with this PR's `if image.is_none() && !per_lane { … } else { … }`. With that, `cargo test -p victory-shader` passes (234 tests) and clippy on the crate is clean with `-D warnings`. **One more thing for the rebase:** `HostShader` gained a `half_views` field on `main` (`58de9bf`), so the test's `HostShader { … }` literal needs `half_views: Vec::new(),` to compile. I hit this with the earlier test and added that line. `95b1975c`'s literal is missing it too. With the uniform handle put back into the earlier single-block test, that test still passes on this card, as it did on the 7800 XT. On RDNA 4 here, the crash needed the title's own shaders. AI-assisted (Claude Code); no game data.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/452:upstream-pr/452'
git switch 'upstream-pr/452'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/452'
git switch 'upstream-pr/452'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/452'
git switch 'upstream-pr/452'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/452'
git switch 'main'
git merge --squash 'upstream-pr/452'
git switch 'main'
git merge --ff-only 'upstream-pr/452'
git switch 'main'
git merge 'upstream-pr/452'
git push origin 'main'
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
fxceless/victory-fork!452
No description provided.