lower: give buffer getDimensions its own non-uniform heap handle (RDNA 4 amdxc64 crash) #684

Open
ggwp wants to merge 1 commit from ggwp/Darner:fix/rdna4-size-view-handle into post-merge
Contributor

Contributor role (optional)

  • Fluxer ID: FomalhautCusimanse#7381

What it changes

  • The problem on post-merge: On AMD RDNA 4 (tested on AMD Radeon RX 9070 XT), darner crashes during startup pipeline creation inside AMD's DXIL shader compiler (amdxc64.dll):

    darner: unhandled exception 0xc0000005 at amdxc64.dll+0x861b9f (read 0x8: nothing mapped there)
    at the crash: ... pipeline make of e0e3e4606911c705a1470e1e897cdecf [compute a567b9ef845fb680] (this thread)
    

    This is the same RDNA 4 amdxc64.dll null-pointer dereference fixed on pre-merge (crates/darner-shader/src/emit/lower/amd.rs, port of DexNom/VIctory PR 62): amdxc64 faults when a buffer's getDimensions (descriptor_data) shares the same uniform heap handle (createHandleFromHeap(..., false)) as the buffer's loads. On post-merge, Lower::descriptor_data still calls self.handle(site, &src, false, props)?, and opt::REUSE / amdxc64 share the uniform handle.

  • Fix: Port size_view_handle from pre-merge into Lower (crates/darner-shader/src/emit/lower.rs). For uniform buffer views measured by descriptor_data, emit a separate heap handle via self.heap_index + self.listed + self.s.heap_handle(..., true, props) (marked non-uniform and not cached in self.handles), preventing both opt::REUSE and amdxc64 from merging it with the load handle. Because emit/lower.rs is part of darner_shader::sources(), cached translations automatically re-translate.

How it was tested

  • Tested revision: 99cf227 (standalone checks) and 99cf227 + #676 (in-game run on RX 9070 XT so AMD lighting renders)

  • Commands and results:

    • cargo test --offline -p darner-shader --lib — passed
    • cargo clippy --offline -p darner-shader --tests — 0 warnings in lower.rs
    • cargo build --offline --release -p darner — succeeded
  • Changes a default: yes, affects translated shaders that measure uniform buffer descriptors via descriptor_data (emits a separate non-uniform createHandleFromHeap for getDimensions).

  • A/B result on AMD Radeon RX 9070 XT (RDNA 4), Series X profile, default settings:

    A (off, post-merge 28a9b42) B (on, 99cf227)
    Startup Immediate crash (0xc0000005 at amdxc64.dll+0x861b9f) while compiling compute shader a567b9ef845fb680 Boots cleanly past pipeline compilation into the game
  • Checks run on 99cf227: cargo test, cargo clippy, cargo build --release (all passed).

  • Gameplay: AMD Radeon RX 9070 XT (16 GB), Series X, default settings (tested together with #676 for AMD lighting).

  • Hardware dependence: Fixes an AMD RDNA 4 (amdxc64.dll) compiler crash; safe on other AMD RDNA generations, NVIDIA, and Intel (same approach already shipped on pre-merge).

  • Coverage gaps: Untested on RX 9060 XT, NVIDIA, and Intel on post-merge directly.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on post-merge.
  • The diff contains no game files, code or assets.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #676 (separate AMD fix for PORTABLE_VIEWS heap layout; independent files, no conflict).
  • Replaces or overlaps: none found.
## Contributor role (optional) - Fluxer ID: FomalhautCusimanse#7381 ## What it changes - The problem on `post-merge`: On AMD RDNA 4 (tested on AMD Radeon RX 9070 XT), `darner` crashes during startup pipeline creation inside AMD's DXIL shader compiler (`amdxc64.dll`): ``` darner: unhandled exception 0xc0000005 at amdxc64.dll+0x861b9f (read 0x8: nothing mapped there) at the crash: ... pipeline make of e0e3e4606911c705a1470e1e897cdecf [compute a567b9ef845fb680] (this thread) ``` This is the same RDNA 4 `amdxc64.dll` null-pointer dereference fixed on `pre-merge` (`crates/darner-shader/src/emit/lower/amd.rs`, port of DexNom/VIctory PR 62): `amdxc64` faults when a buffer's `getDimensions` (`descriptor_data`) shares the same uniform heap handle (`createHandleFromHeap(..., false)`) as the buffer's loads. On `post-merge`, `Lower::descriptor_data` still calls `self.handle(site, &src, false, props)?`, and `opt::REUSE` / `amdxc64` share the uniform handle. - Fix: Port `size_view_handle` from `pre-merge` into `Lower` (`crates/darner-shader/src/emit/lower.rs`). For uniform buffer views measured by `descriptor_data`, emit a separate heap handle via `self.heap_index` + `self.listed` + `self.s.heap_handle(..., true, props)` (marked non-uniform and not cached in `self.handles`), preventing both `opt::REUSE` and `amdxc64` from merging it with the load handle. Because `emit/lower.rs` is part of `darner_shader::sources()`, cached translations automatically re-translate. ## How it was tested - Tested revision: `99cf227` (standalone checks) and `99cf227` + #676 (in-game run on RX 9070 XT so AMD lighting renders) - Commands and results: - `cargo test --offline -p darner-shader --lib` — passed - `cargo clippy --offline -p darner-shader --tests` — 0 warnings in `lower.rs` - `cargo build --offline --release -p darner` — succeeded - Changes a default: yes, affects translated shaders that measure uniform buffer descriptors via `descriptor_data` (emits a separate non-uniform `createHandleFromHeap` for `getDimensions`). - A/B result on AMD Radeon RX 9070 XT (RDNA 4), Series X profile, default settings: | | A (off, `post-merge` `28a9b42`) | B (on, `99cf227`) | |---|---|---| | Startup | Immediate crash (`0xc0000005` at `amdxc64.dll+0x861b9f`) while compiling compute shader `a567b9ef845fb680` | Boots cleanly past pipeline compilation into the game | - Checks run on `99cf227`: `cargo test`, `cargo clippy`, `cargo build --release` (all passed). - Gameplay: AMD Radeon RX 9070 XT (16 GB), Series X, default settings (tested together with #676 for AMD lighting). - Hardware dependence: Fixes an AMD RDNA 4 (`amdxc64.dll`) compiler crash; safe on other AMD RDNA generations, NVIDIA, and Intel (same approach already shipped on `pre-merge`). - Coverage gaps: Untested on RX 9060 XT, NVIDIA, and Intel on `post-merge` directly. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `post-merge`. - [x] The diff contains no game files, code or assets. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #676 (separate AMD fix for `PORTABLE_VIEWS` heap layout; independent files, no conflict). - Replaces or overlaps: none found.
TrustNo1 changed title from [pr-fix][shaders][AMD] lower: give buffer getDimensions its own non-uniform heap handle (RDNA 4 amdxc64 crash) to lower: give buffer getDimensions its own non-uniform heap handle (RDNA 4 amdxc64 crash) 2026-12-06 03:25:10 +00:00
This pull request can be merged automatically.
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 'fix/rdna4-size-view-handle:ggwp-fix/rdna4-size-view-handle'
git switch 'ggwp-fix/rdna4-size-view-handle'

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 'post-merge'
git merge --no-ff 'ggwp-fix/rdna4-size-view-handle'
git switch 'ggwp-fix/rdna4-size-view-handle'
git rebase 'post-merge'
git switch 'post-merge'
git merge --ff-only 'ggwp-fix/rdna4-size-view-handle'
git switch 'ggwp-fix/rdna4-size-view-handle'
git rebase 'post-merge'
git switch 'post-merge'
git merge --no-ff 'ggwp-fix/rdna4-size-view-handle'
git switch 'post-merge'
git merge --squash 'ggwp-fix/rdna4-size-view-handle'
git switch 'post-merge'
git merge --ff-only 'ggwp-fix/rdna4-size-view-handle'
git switch 'post-merge'
git merge 'ggwp-fix/rdna4-size-view-handle'
git push origin 'post-merge'
Sign in to join this conversation.
No reviewers
No milestone
No project
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
TrustNo1/Darner!684
No description provided.