GPU: implement null UAV descriptor fallbacks and placed UAV support #552

Closed
github-bot wants to merge 2 commits from gh-pr/552/head into gh-pr/552/base
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 04:49 UTC · original
LAKSHYA-cmd-tech:fix/uav-null-descriptor-safety → main · +341 −47 · 2 files · 2 commits · closed without merging

Summary

Fixes the RDNA3 / D3D12 GPU page fault and device removal caused by compute dispatches writing to unbound UAVs or placed texture UAVs (reported in #508).

Background & Investigation

In #508, compute dispatches writing to unbound or placed UAV slots faulted on an RDNA3 iGPU (\DXGI_ERROR_DEVICE_REMOVED, page fault at \

**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 04:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/552) `LAKSHYA-cmd-tech:fix/uav-null-descriptor-safety` → `main` · +341 −47 · 2 files · 2 commits · closed without merging ### Summary Fixes the RDNA3 / D3D12 GPU page fault and device removal caused by compute dispatches writing to unbound UAVs or placed texture UAVs (reported in #508). ### Background & Investigation In #508, compute dispatches writing to unbound or placed UAV slots faulted on an RDNA3 iGPU (\DXGI_ERROR_DEVICE_REMOVED\, page fault at \
- Add HostHeap::make_null_uav for buffers and textures so unbound UAV slots drop writes safely.
- Support View::Placed(true, ...) in placed_texture to mirror placed unordered access texture views.
- Enhance null_for to match exact UAV dimensions (1D, 2D, 2DArray, 3D, Buffer).
- Add opt-in VICTORY_DROP_UNBOUND_UAV to safely skip compute dispatches with missing UAV bindings.
- Add unit tests for null UAV creation and dimension-matching UAV fallbacks.
- Addresses #508.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:02 +00:00
github-bot closed this pull request 2026-11-26 04:08:02 +00:00
Author
Owner

@⁠Raxstreams on GitHub · 2026-11-24 05:00 UTC · original

On Windows with an RTX 3080 Ti, I integrated the descriptor changes and ran both placed_null_tests. null_for_creates_uav_matching_dimensions and null_uav_descriptors_created_on_host_heap both passed. This verifies the descriptor tests on NVIDIA. The RDNA3 device-removal report needs separate hardware confirmation.

**@⁠Raxstreams** on GitHub · 2026-11-24 05:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/552#issuecomment-7122538366) On Windows with an RTX 3080 Ti, I integrated the descriptor changes and ran both placed_null_tests. null_for_creates_uav_matching_dimensions and null_uav_descriptors_created_on_host_heap both passed. This verifies the descriptor tests on NVIDIA. The RDNA3 device-removal report needs separate hardware confirmation.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-24 05:00 UTC · original

Review: the null UAV dimensions in null_uav_like use the wrong numbers

Thanks for picking up #508. The table_entry / fresh-table changes look right to me (an unbound UAV slot now gets a null UAV instead of the null Texture2D SRV from fill_null). One part of the dimension handling is off, though, and it affects the exact case the description says this PR fixes.

What's wrong

null_uav_like(words, at) switches on words[1] with literals 1 | 2 | 3 | 5 | 6. Those words are the title's D3D12_UNORDERED_ACCESS_VIEW_DESC, in the host's layout: uav_desc reads them with no translation, and null_for already relied on d[1] == 1 for buffers. So words[1] is a D3D12_UAV_DIMENSION. In windows 0.62.2 (the version in Cargo.lock), these are the values:

value constant what #552 makes should be
1 BUFFER buffer buffer ✓
2 TEXTURE1D 1D 1D ✓
3 TEXTURE1DARRAY 1D array 1D array ✓
4 TEXTURE2D 2D (default) 2D ✓
5 TEXTURE2DARRAY 2D array 2D array ✓
6 TEXTURE2DMS 3D 2D (MS UAVs need a cap) ✗
7 TEXTURE2DMSARRAY 2D (default) 2D ✓
8 TEXTURE3D 2D (default) 3D ✗

Two effects:

  1. A 3D UAV with no host view still gets a Texture2D null view. That is the GBV error from #205 (UAV Dimension Expected: D3D12_UAV_DIMENSION_TEXTURE3D, UAV Dimension In Descriptor: D3D12_UAV_DIMENSION_TEXTURE2D on WindNew:CS_CopyWindFieldBeforeUpdateWithSmooth), which the PR description says is eliminated.
  2. A 2D multisampled UAV gets a Texture3D null view, a new mismatch that main doesn't have.

null_for_creates_uav_matching_dimensions uses [0, 6, …] for its "Texture3D" case. It passes because it only checks that CreateUnorderedAccessView accepts a null descriptor of that shape, not which dimension null_for chose. So the wrong mapping can't fail it.

Suggested fix

Match on the windows constants instead of literals, through a small helper that can be unit-tested without a GPU. MS and unknown words keep the 2D fallback that main and #205 use.

/// The dimension of the null UAV for a title view description's dimension
/// word (the host's `D3D12_UAV_DIMENSION` values: 3D is 8, 6 and 7 are
/// multisampled). Multisampled UAVs need a capability, and unknown words
/// name no dimension: those get a 2D null view, as before.
fn null_uav_dimension(word: u32) -> D3D12_UAV_DIMENSION {
    match D3D12_UAV_DIMENSION(word as i32) {
        d @ (D3D12_UAV_DIMENSION_BUFFER
        | D3D12_UAV_DIMENSION_TEXTURE1D
        | D3D12_UAV_DIMENSION_TEXTURE1DARRAY
        | D3D12_UAV_DIMENSION_TEXTURE2DARRAY
        | D3D12_UAV_DIMENSION_TEXTURE3D) => d,
        _ => D3D12_UAV_DIMENSION_TEXTURE2D,
    }
}

null_uav_like then matches null_uav_dimension(words[1]) against D3D12_UAV_DIMENSION_BUFFER / TEXTURE1D / TEXTURE1DARRAY / TEXTURE2DARRAY / TEXTURE3D (keeping your descriptors as they are), with _ as the 2D case. The existing test's 3D case becomes [0, 8, …], and a new test pins the mapping:

#[test]
fn null_uavs_follow_the_hosts_dimension_numbers() {
    let cases = [
        (1, D3D12_UAV_DIMENSION_BUFFER),
        (2, D3D12_UAV_DIMENSION_TEXTURE1D),
        (3, D3D12_UAV_DIMENSION_TEXTURE1DARRAY),
        (4, D3D12_UAV_DIMENSION_TEXTURE2D),
        (5, D3D12_UAV_DIMENSION_TEXTURE2DARRAY),
        (6, D3D12_UAV_DIMENSION_TEXTURE2D),
        (7, D3D12_UAV_DIMENSION_TEXTURE2D),
        (8, D3D12_UAV_DIMENSION_TEXTURE3D),
        (0, D3D12_UAV_DIMENSION_TEXTURE2D),
        (99, D3D12_UAV_DIMENSION_TEXTURE2D),
    ];
    for (word, want) in cases {
        assert_eq!(null_uav_dimension(word), want, "word {word}");
    }
}

The whole change on top of 1cd9e5b is about 100 lines, in crates/victory-gpu/src/descriptor/host.rs only. I'm happy to post the full diff here if that's easier than re-typing.

What I ran

On top of this PR's head 1cd9e5b (base d2a4bae), Windows 11, Rust 1.98.1 x86_64-pc-windows-msvc, AMD RX 6750 XT (RDNA2):

  • cargo test -p victory-gpu: 46 passed, 0 failed, 1 ignored (the existing benchmark). That includes your null_uav_descriptors_created_on_host_heap and null_for_creates_uav_matching_dimensions, and the new null_uavs_follow_the_hosts_dimension_numbers.
  • cargo test -p victory-gpu --features diagnostics: 48 passed, 0 failed, 1 ignored.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean except the pre-existing undocumented_unsafe_blocks at host.rs:267, which is on main and fixed by #355.
  • cargo fmt -p victory-gpu --check: no diff in descriptor/host.rs or draw.rs. The diffs it reports are in files this PR doesn't touch and are on main too.

Not checked

Not runtime-tested with game files, so I can't say whether this PR makes the #508 device removal go away on RDNA3. That needs the reporter or someone with the title. Note also that #205 makes the same dimension change in null_for (with the right constants), so the two PRs will conflict there.

AI-assisted (Claude did the source analysis and wrote the fix; I ran the tests above on my machine).

**@⁠wwwwwwww3333333** on GitHub · 2026-11-24 05:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/552#issuecomment-7122544149) ## Review: the null UAV dimensions in `null_uav_like` use the wrong numbers Thanks for picking up #508. The `table_entry` / fresh-table changes look right to me (an unbound UAV slot now gets a null UAV instead of the null Texture2D SRV from `fill_null`). One part of the dimension handling is off, though, and it affects the exact case the description says this PR fixes. ### What's wrong `null_uav_like(words, at)` switches on `words[1]` with literals `1 | 2 | 3 | 5 | 6`. Those words are the title's `D3D12_UNORDERED_ACCESS_VIEW_DESC`, in the host's layout: `uav_desc` reads them with no translation, and `null_for` already relied on `d[1] == 1` for buffers. So `words[1]` is a `D3D12_UAV_DIMENSION`. In `windows` 0.62.2 (the version in `Cargo.lock`), these are the values: | value | constant | what #552 makes | should be | |---|---|---|---| | 1 | `BUFFER` | buffer | buffer ✓ | | 2 | `TEXTURE1D` | 1D | 1D ✓ | | 3 | `TEXTURE1DARRAY` | 1D array | 1D array ✓ | | 4 | `TEXTURE2D` | 2D (default) | 2D ✓ | | 5 | `TEXTURE2DARRAY` | 2D array | 2D array ✓ | | 6 | `TEXTURE2DMS` | **3D** | 2D (MS UAVs need a cap) ✗ | | 7 | `TEXTURE2DMSARRAY` | 2D (default) | 2D ✓ | | 8 | `TEXTURE3D` | **2D (default)** | **3D** ✗ | Two effects: 1. **A 3D UAV with no host view still gets a Texture2D null view.** That is the GBV error from #205 (`UAV Dimension Expected: D3D12_UAV_DIMENSION_TEXTURE3D, UAV Dimension In Descriptor: D3D12_UAV_DIMENSION_TEXTURE2D` on `WindNew:CS_CopyWindFieldBeforeUpdateWithSmooth`), which the PR description says is eliminated. 2. **A 2D multisampled UAV gets a Texture3D null view**, a new mismatch that `main` doesn't have. `null_for_creates_uav_matching_dimensions` uses `[0, 6, …]` for its "Texture3D" case. It passes because it only checks that `CreateUnorderedAccessView` accepts a null descriptor of that shape, not which dimension `null_for` chose. So the wrong mapping can't fail it. ### Suggested fix Match on the `windows` constants instead of literals, through a small helper that can be unit-tested without a GPU. MS and unknown words keep the 2D fallback that `main` and #205 use. ```rust /// The dimension of the null UAV for a title view description's dimension /// word (the host's `D3D12_UAV_DIMENSION` values: 3D is 8, 6 and 7 are /// multisampled). Multisampled UAVs need a capability, and unknown words /// name no dimension: those get a 2D null view, as before. fn null_uav_dimension(word: u32) -> D3D12_UAV_DIMENSION { match D3D12_UAV_DIMENSION(word as i32) { d @ (D3D12_UAV_DIMENSION_BUFFER | D3D12_UAV_DIMENSION_TEXTURE1D | D3D12_UAV_DIMENSION_TEXTURE1DARRAY | D3D12_UAV_DIMENSION_TEXTURE2DARRAY | D3D12_UAV_DIMENSION_TEXTURE3D) => d, _ => D3D12_UAV_DIMENSION_TEXTURE2D, } } ``` `null_uav_like` then matches `null_uav_dimension(words[1])` against `D3D12_UAV_DIMENSION_BUFFER / TEXTURE1D / TEXTURE1DARRAY / TEXTURE2DARRAY / TEXTURE3D` (keeping your descriptors as they are), with `_` as the 2D case. The existing test's 3D case becomes `[0, 8, …]`, and a new test pins the mapping: ```rust #[test] fn null_uavs_follow_the_hosts_dimension_numbers() { let cases = [ (1, D3D12_UAV_DIMENSION_BUFFER), (2, D3D12_UAV_DIMENSION_TEXTURE1D), (3, D3D12_UAV_DIMENSION_TEXTURE1DARRAY), (4, D3D12_UAV_DIMENSION_TEXTURE2D), (5, D3D12_UAV_DIMENSION_TEXTURE2DARRAY), (6, D3D12_UAV_DIMENSION_TEXTURE2D), (7, D3D12_UAV_DIMENSION_TEXTURE2D), (8, D3D12_UAV_DIMENSION_TEXTURE3D), (0, D3D12_UAV_DIMENSION_TEXTURE2D), (99, D3D12_UAV_DIMENSION_TEXTURE2D), ]; for (word, want) in cases { assert_eq!(null_uav_dimension(word), want, "word {word}"); } } ``` The whole change on top of `1cd9e5b` is about 100 lines, in `crates/victory-gpu/src/descriptor/host.rs` only. I'm happy to post the full diff here if that's easier than re-typing. ### What I ran On top of this PR's head `1cd9e5b` (base `d2a4bae`), Windows 11, Rust 1.98.1 `x86_64-pc-windows-msvc`, AMD RX 6750 XT (RDNA2): - `cargo test -p victory-gpu`: **46 passed**, 0 failed, 1 ignored (the existing benchmark). That includes your `null_uav_descriptors_created_on_host_heap` and `null_for_creates_uav_matching_dimensions`, and the new `null_uavs_follow_the_hosts_dimension_numbers`. - `cargo test -p victory-gpu --features diagnostics`: **48 passed**, 0 failed, 1 ignored. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean except the pre-existing `undocumented_unsafe_blocks` at `host.rs:267`, which is on `main` and fixed by #355. - `cargo fmt -p victory-gpu --check`: no diff in `descriptor/host.rs` or `draw.rs`. The diffs it reports are in files this PR doesn't touch and are on `main` too. ### Not checked Not runtime-tested with game files, so I can't say whether this PR makes the #508 device removal go away on RDNA3. That needs the reporter or someone with the title. Note also that #205 makes the same dimension change in `null_for` (with the right constants), so the two PRs will conflict there. *AI-assisted (Claude did the source analysis and wrote the fix; I ran the tests above on my machine).*
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 05:39 UTC · original

Thanks @⁠wwwwwwww3333333 for the careful review and catching the dimension word values!

Updated in commit c261d8d:

  • Added
    ull_uav_dimension\ matching against \windows::Win32::Graphics::Direct3D12::D3D12_UAV_DIMENSION\ constants directly (\TEXTURE3D\ is correctly mapped to 8, \TEXTURE2DMS\ to 2D fallback).
  • Updated
    ull_uav_like\ to match on \D3D12_UAV_DIMENSION\ enums.
  • Added unit test
    ull_uavs_follow_the_hosts_dimension_numbers\ covering all dimension words (1–8, 0, 99) and updated the 3D case in
    ull_for_creates_uav_matching_dimensions.
  • All 46 tests in \ ictory-gpu\ pass cleanly.
**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 05:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/552#issuecomment-7123159382) Thanks @⁠wwwwwwww3333333 for the careful review and catching the dimension word values! Updated in commit c261d8d: - Added \ ull_uav_dimension\ matching against \windows::Win32::Graphics::Direct3D12::D3D12_UAV_DIMENSION\ constants directly (\TEXTURE3D\ is correctly mapped to 8, \TEXTURE2DMS\ to 2D fallback). - Updated \ ull_uav_like\ to match on \D3D12_UAV_DIMENSION\ enums. - Added unit test \ ull_uavs_follow_the_hosts_dimension_numbers\ covering all dimension words (1–8, 0, 99) and updated the 3D case in \ ull_for_creates_uav_matching_dimensions\. - All 46 tests in \ ictory-gpu\ pass cleanly.
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 08:15 UTC · original

Resolved upstream by PR #205 (\6af0fae Merge pull request #205 from asdaasdsaddf/fix/null-uav-dimension), which maps null UAV dimensions matching the title's view dimension.

**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 08:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/552#issuecomment-7125918216) Resolved upstream by PR #205 (\6af0fae Merge pull request #205 from asdaasdsaddf/fix/null-uav-dimension\), which maps null UAV dimensions matching the title's view dimension.
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 08:15 UTC · original

Closing as resolved by merged PR #205.

**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 08:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/552#issuecomment-7125918789) Closing as resolved by merged PR #205.

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!552
No description provided.