GPU: create host textures without the uses the host refuses #55

Open
github-bot wants to merge 1 commit from github-bot/gh-55 into main AGit
Owner

@⁠a55uka on GitHub · 2026-11-23 23:55 UTC · original
a55uka:fix/nvidia-texture-fallback → main · +47 −15 · 1 files · 1 commits · open

The console's GPU allows some uses of formats that other GPUs don't. On an RTX 4070 (Linux, vkd3d-proton), two 2560×1440 textures failed to create with E_INVALIDARG:

  • format 86 (B8G8R8A8_UNORM) with unordered access
  • format 115 (B4G4R4A4_UNORM) as a render target

vkd3d-proton logs: Requested resource flags #5, but no format in cast list supports it.

Tested:

  • Fedora with Wine 11.21 Staging and vkd3d-proton / DXVK from GE-Proton11-12, on an i7-12700K with an RTX 4070.
  • Both textures are now created and the title runs on.
  • Not tested on Windows. Native D3D12 on NVIDIA might refuse the same uses, haven't confirmed that.
**@⁠a55uka** on GitHub · 2026-11-23 23:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/55) `a55uka:fix/nvidia-texture-fallback` → `main` · +47 −15 · 1 files · 1 commits · open The console's GPU allows some uses of formats that other GPUs don't. On an RTX 4070 (Linux, vkd3d-proton), two 2560×1440 textures failed to create with `E_INVALIDARG`: - format 86 (B8G8R8A8_UNORM) with unordered access - format 115 (B4G4R4A4_UNORM) as a render target vkd3d-proton logs: `Requested resource flags #5, but no format in cast list supports it.` Tested: - Fedora with Wine 11.21 Staging and vkd3d-proton / DXVK from GE-Proton11-12, on an i7-12700K with an RTX 4070. - Both textures are now created and the title runs on. - Not tested on Windows. Native D3D12 on NVIDIA might refuse the same uses, haven't confirmed that.
The console's GPU allows uses of some formats that other host GPUs do
not. On an RTX 4070 two 2560x1440 textures failed to create with
E_INVALIDARG (vkd3d-proton: "Requested resource flags #5, but no format
in cast list supports it"): format 86 (BGRA8) with unordered access, and
format 115 (B4G4R4A4) as a render target.

When creation fails, try again without unordered access, then without
render-target use, as is already done for depth targets that ask for
unordered access. The views the host cannot make are skipped. A clear
value is only passed while the texture is still a render target or
depth target, since the host refuses it otherwise.

Not checked: whether the title draws to or writes these textures in a
way that now goes missing.

Tested: Linux (Wine 11.21, vkd3d-proton 3.1), i7-12700K, RTX 4070. The
two textures are created and the title runs on.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:48:30 +00:00
Author
Owner

@⁠Vyral1978 on GitHub · 2026-11-24 00:20 UTC · original

Tested on native Windows 11 D3D12 (Intel i7-12700 + NVIDIA RTX 3070):

  • Confirms native D3D12 on NVIDIA refuses the exact same two 2560x1440 textures (format 86 with UAV and format 115 with RT); both now create cleanly with dropped=4 and dropped=1.
  • Small follow-up needed for Windows D3D12: once ALLOW_RENDER_TARGET is dropped on format 115, Host::rtv() (called from draw.rs::set_targets and list.rs::clear_rtv) still calls CreateRenderTargetView / OMSetRenderTargets / ClearRenderTargetView on that texture, which triggers DXGI_ERROR_INVALID_CALL (0x887A0001) on native Windows D3D12.
  • Returning Option<D3D12_CPU_DESCRIPTOR_HANDLE> from Host::rtv() (returning None when GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET == 0) and skipping it in set_targets / clear_rtv completely fixes the 0x887A0001 removal (ran ~82s into the world on 35b054e).
**@⁠Vyral1978** on GitHub · 2026-11-24 00:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7117969576) Tested on native Windows 11 D3D12 (Intel i7-12700 + NVIDIA RTX 3070): - Confirms native D3D12 on NVIDIA refuses the exact same two `2560x1440` textures (`format 86` with UAV and `format 115` with RT); both now create cleanly with `dropped=4` and `dropped=1`. - **Small follow-up needed for Windows D3D12**: once `ALLOW_RENDER_TARGET` is dropped on `format 115`, `Host::rtv()` (called from `draw.rs::set_targets` and `list.rs::clear_rtv`) still calls `CreateRenderTargetView` / `OMSetRenderTargets` / `ClearRenderTargetView` on that texture, which triggers `DXGI_ERROR_INVALID_CALL (0x887A0001)` on native Windows D3D12. - Returning `Option<D3D12_CPU_DESCRIPTOR_HANDLE>` from `Host::rtv()` (returning `None` when `GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET == 0`) and skipping it in `set_targets` / `clear_rtv` completely fixes the `0x887A0001` removal (ran ~82s into the world on `35b054e`).
Author
Owner

@⁠EduAzevedo on GitHub · 2026-11-24 00:42 UTC · original

Tested 56f1d41 on NVIDIA GeForce RTX 2070 SUPER (Turing), driver 610.88, Windows 11 (10.0.26200), native D3D12, release build, empty cache: the textures are fixed; the world then ends in device removed with DXGI_ERROR_INVALID_CALL, which confirms the follow-up @⁠Vyral1978 describes, on Turing too.

main 35b054e this PR
no host texture (2560×1440, format 86 UAV and format 115 RT) 2 0 (both logged as host texture without a use the host refuses)
Menus 30 fps 30 fps
World (first mission's intro) dark, 0.5-0.9 fps dark, about 1 fps
Device removed reason 0x887A0004 after an 8.6 s submission (a hang) 0x887A0001 (invalid call), twice, after a 0.5 s submission
  • So with the two textures created, the next thing NVIDIA hits on native Windows is the RTV on the format 115 texture, as described above; the device is removed earlier than the hang on main.
  • Compute pipelines refused by the host: 60 in this run (47 on main, 9 with #54). This PR does not touch that; the counts differ with how far each run got.
  • The fatal submission held the same three compute pipelines as the hang on main (2c3592e9bbad543f, 559fb027c6d5b1db, e4a4da9c0f4d810e).

AI-assisted.

**@⁠EduAzevedo** on GitHub · 2026-11-24 00:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7118342664) Tested `56f1d41` on **NVIDIA GeForce RTX 2070 SUPER (Turing)**, driver 610.88, Windows 11 (10.0.26200), native D3D12, release build, empty cache: **the textures are fixed; the world then ends in device removed with `DXGI_ERROR_INVALID_CALL`**, which confirms the follow-up @⁠Vyral1978 describes, on Turing too. | | main `35b054e` | this PR | |---|---|---| | `no host texture` (2560×1440, format 86 UAV and format 115 RT) | 2 | **0** (both logged as `host texture without a use the host refuses`) | | Menus | 30 fps | 30 fps | | World (first mission's intro) | dark, 0.5-0.9 fps | dark, about 1 fps | | Device removed reason | `0x887A0004` after an 8.6 s submission (a hang) | **`0x887A0001` (invalid call)**, twice, after a 0.5 s submission | - So with the two textures created, the next thing NVIDIA hits on native Windows is the RTV on the format 115 texture, as described above; the device is removed earlier than the hang on main. - Compute pipelines refused by the host: 60 in this run (47 on main, 9 with #54). This PR does not touch that; the counts differ with how far each run got. - The fatal submission held the same three compute pipelines as the hang on main (`2c3592e9bbad543f`, `559fb027c6d5b1db`, `e4a4da9c0f4d810e`). AI-assisted.
Author
Owner

@⁠EduAzevedo on GitHub · 2026-11-24 00:54 UTC · original

Follow-up to my test above: I implemented the Host::rtv() change @⁠Vyral1978 describes on top of 56f1d41 and ran it on the same RTX 2070 SUPER (Turing), driver 610.88, Windows 11, native D3D12, release build. The 0x887A0001 removal is gone; the world now runs until the hang from #71 / #97.

this PR (56f1d41) this PR + the patch below
DXGI_ERROR_INVALID_CALL (0x887A0001) 2, then device removed 0
Format 115 target bound as a null view – yes, once
World (first mission's intro) removed early runs ~45 s past the null view; shows an image of the intro that did not appear before
End 0x887A0001 0x887A0004 after a 5.0 s submission holding the same three compute pipelines as on main (2c3592e9bbad543f, 559fb027c6d5b1db, e4a4da9c0f4d810e), i.e. the hang in #71 / #97

One difference from the suggestion: instead of leaving the target out of OMSetRenderTargets, it binds a null RTV in its slot, so the targets after it keep their indices (dropping one would move the pixel shader's later outputs onto the wrong textures). clear_rtv returns without clearing. cargo build --release and cargo test -p victory-gpu (39 passed) are clean.

Feel free to take it into this PR; I can open it as a separate PR on top of this one instead if you prefer.

Patch (on top of 56f1d41)
diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs
index af6ad04..d9e5b2d 100644
--- a/crates/victory-gpu/src/draw.rs
+++ b/crates/victory-gpu/src/draw.rs
@@ -267,7 +267,14 @@ impl State {
             self.targets.push(record.resource as usize);
             #[cfg(feature = "diagnostics")]
             crate::capture::note_target(record.resource);
-            rtvs.push(host.rtv(texture, record.desc().as_ref()));
+            let rtv = host.rtv(texture, record.desc().as_ref()).unwrap_or_else(|| {
+                once!(
+                    resource = format_args!("{:p}", record.resource),
+                    "render target the host cannot render to; bound as a null view"
+                );
+                host.null_rtv()
+            });
+            rtvs.push(rtv);
         }
         self.depth = 0;
         let dsv = crate::descriptor::dsv_record(depth).and_then(|record| {
diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs
index d89159e..7f4835c 100644
--- a/crates/victory-gpu/src/host.rs
+++ b/crates/victory-gpu/src/host.rs
@@ -694,20 +694,48 @@ impl Host {
     }
 
     /// A host render target view of `resource`, valid until it is recorded.
+    /// `None` when the host texture was made without render-target use
+    /// (the host refused it, see `resource.rs`): a view of it is an invalid
+    /// call that removes the device.
     pub(crate) fn rtv(
         &self,
         resource: &ID3D12Resource,
         desc: Option<&D3D12_RENDER_TARGET_VIEW_DESC>,
-    ) -> D3D12_CPU_DESCRIPTOR_HANDLE {
-        let slot = self.next_rtv.fetch_add(1, Ordering::Relaxed) % RTV_RING;
+    ) -> Option<D3D12_CPU_DESCRIPTOR_HANDLE> {
+        // SAFETY: a live resource.
+        let flags = unsafe { resource.GetDesc() }.Flags;
+        if (flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET).0 == 0 {
+            return None;
+        }
+        let handle = self.next_rtv_slot();
         // SAFETY: a slot of our heap and a live resource.
         unsafe {
-            let mut handle = self.rtvs.GetCPUDescriptorHandleForHeapStart();
-            handle.ptr += (slot * self.rtv_size) as usize;
             self.device
                 .CreateRenderTargetView(resource, desc.map(|d| d as *const _), handle);
-            handle
         }
+        Some(handle)
+    }
+
+    /// A null render target view: it keeps a slot's place among the bound
+    /// targets, and writes to it are discarded.
+    pub(crate) fn null_rtv(&self) -> D3D12_CPU_DESCRIPTOR_HANDLE {
+        let handle = self.next_rtv_slot();
+        let desc = D3D12_RENDER_TARGET_VIEW_DESC {
+            Format: DXGI_FORMAT_R8G8B8A8_UNORM,
+            ViewDimension: D3D12_RTV_DIMENSION_TEXTURE2D,
+            ..Default::default()
+        };
+        // SAFETY: a slot of our heap; a null resource with a full description.
+        unsafe { self.device.CreateRenderTargetView(None, Some(&desc), handle) };
+        handle
+    }
+
+    fn next_rtv_slot(&self) -> D3D12_CPU_DESCRIPTOR_HANDLE {
+        let slot = self.next_rtv.fetch_add(1, Ordering::Relaxed) % RTV_RING;
+        // SAFETY: the start of our heap.
+        let mut handle = unsafe { self.rtvs.GetCPUDescriptorHandleForHeapStart() };
+        handle.ptr += (slot * self.rtv_size) as usize;
+        handle
     }
 
     /// A host depth view of `resource`, valid until it is recorded.
diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs
index 78d6d73..aa11fbe 100644
--- a/crates/victory-gpu/src/list.rs
+++ b/crates/victory-gpu/src/list.rs
@@ -695,7 +695,10 @@ extern "system" fn clear_rtv(
             unsafe { std::slice::from_raw_parts(rects.cast(), count as usize) }
         });
         const RENDER_TARGET: u32 = 0x4;
-        let rtv = host.rtv(texture, record.desc().as_ref());
+        // A texture the host cannot render to has no view to clear.
+        let Some(rtv) = host.rtv(texture, record.desc().as_ref()) else {
+            return;
+        };
         // SAFETY: an open list, a fresh view of a live texture.
         unsafe {
             if let Some((_, before)) = list.transition(record.resource, RENDER_TARGET) {

AI-assisted.

**@⁠EduAzevedo** on GitHub · 2026-11-24 00:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7118557652) Follow-up to my test above: I implemented the `Host::rtv()` change @⁠Vyral1978 describes on top of `56f1d41` and ran it on the same **RTX 2070 SUPER (Turing)**, driver 610.88, Windows 11, native D3D12, release build. **The `0x887A0001` removal is gone**; the world now runs until the hang from #71 / #97. | | this PR (`56f1d41`) | this PR + the patch below | |---|---|---| | `DXGI_ERROR_INVALID_CALL` (`0x887A0001`) | 2, then device removed | **0** | | Format 115 target bound as a null view | – | yes, once | | World (first mission's intro) | removed early | runs ~45 s past the null view; **shows an image of the intro that did not appear before** | | End | `0x887A0001` | `0x887A0004` after a 5.0 s submission holding the same three compute pipelines as on main (`2c3592e9bbad543f`, `559fb027c6d5b1db`, `e4a4da9c0f4d810e`), i.e. the hang in #71 / #97 | One difference from the suggestion: instead of leaving the target out of `OMSetRenderTargets`, it binds a **null RTV in its slot**, so the targets after it keep their indices (dropping one would move the pixel shader's later outputs onto the wrong textures). `clear_rtv` returns without clearing. `cargo build --release` and `cargo test -p victory-gpu` (39 passed) are clean. Feel free to take it into this PR; I can open it as a separate PR on top of this one instead if you prefer. <details><summary>Patch (on top of 56f1d41)</summary> ```diff diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index af6ad04..d9e5b2d 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -267,7 +267,14 @@ impl State { self.targets.push(record.resource as usize); #[cfg(feature = "diagnostics")] crate::capture::note_target(record.resource); - rtvs.push(host.rtv(texture, record.desc().as_ref())); + let rtv = host.rtv(texture, record.desc().as_ref()).unwrap_or_else(|| { + once!( + resource = format_args!("{:p}", record.resource), + "render target the host cannot render to; bound as a null view" + ); + host.null_rtv() + }); + rtvs.push(rtv); } self.depth = 0; let dsv = crate::descriptor::dsv_record(depth).and_then(|record| { diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index d89159e..7f4835c 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -694,20 +694,48 @@ impl Host { } /// A host render target view of `resource`, valid until it is recorded. + /// `None` when the host texture was made without render-target use + /// (the host refused it, see `resource.rs`): a view of it is an invalid + /// call that removes the device. pub(crate) fn rtv( &self, resource: &ID3D12Resource, desc: Option<&D3D12_RENDER_TARGET_VIEW_DESC>, - ) -> D3D12_CPU_DESCRIPTOR_HANDLE { - let slot = self.next_rtv.fetch_add(1, Ordering::Relaxed) % RTV_RING; + ) -> Option<D3D12_CPU_DESCRIPTOR_HANDLE> { + // SAFETY: a live resource. + let flags = unsafe { resource.GetDesc() }.Flags; + if (flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET).0 == 0 { + return None; + } + let handle = self.next_rtv_slot(); // SAFETY: a slot of our heap and a live resource. unsafe { - let mut handle = self.rtvs.GetCPUDescriptorHandleForHeapStart(); - handle.ptr += (slot * self.rtv_size) as usize; self.device .CreateRenderTargetView(resource, desc.map(|d| d as *const _), handle); - handle } + Some(handle) + } + + /// A null render target view: it keeps a slot's place among the bound + /// targets, and writes to it are discarded. + pub(crate) fn null_rtv(&self) -> D3D12_CPU_DESCRIPTOR_HANDLE { + let handle = self.next_rtv_slot(); + let desc = D3D12_RENDER_TARGET_VIEW_DESC { + Format: DXGI_FORMAT_R8G8B8A8_UNORM, + ViewDimension: D3D12_RTV_DIMENSION_TEXTURE2D, + ..Default::default() + }; + // SAFETY: a slot of our heap; a null resource with a full description. + unsafe { self.device.CreateRenderTargetView(None, Some(&desc), handle) }; + handle + } + + fn next_rtv_slot(&self) -> D3D12_CPU_DESCRIPTOR_HANDLE { + let slot = self.next_rtv.fetch_add(1, Ordering::Relaxed) % RTV_RING; + // SAFETY: the start of our heap. + let mut handle = unsafe { self.rtvs.GetCPUDescriptorHandleForHeapStart() }; + handle.ptr += (slot * self.rtv_size) as usize; + handle } /// A host depth view of `resource`, valid until it is recorded. diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs index 78d6d73..aa11fbe 100644 --- a/crates/victory-gpu/src/list.rs +++ b/crates/victory-gpu/src/list.rs @@ -695,7 +695,10 @@ extern "system" fn clear_rtv( unsafe { std::slice::from_raw_parts(rects.cast(), count as usize) } }); const RENDER_TARGET: u32 = 0x4; - let rtv = host.rtv(texture, record.desc().as_ref()); + // A texture the host cannot render to has no view to clear. + let Some(rtv) = host.rtv(texture, record.desc().as_ref()) else { + return; + }; // SAFETY: an open list, a fresh view of a live texture. unsafe { if let Some((_, before)) = list.transition(record.resource, RENDER_TARGET) { ``` </details> AI-assisted.
Author
Owner

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

Tested 56f1d41 under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.\n\n- victory_gpu: 36 passed, 3 failed — the same three environment-only failures as main (argument_clamp_builds, a_rejected_blob_gives_an_empty_library, #128's VirtualQuery upload skip).\n- The diff adds no test, so this only shows nothing else broke; the refused-use fallback is not exercised by the suite here.\n\nNo game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7118584542) Tested `56f1d41` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**.\n\n- `victory_gpu`: **36 passed, 3 failed** — the same three environment-only failures as `main` (`argument_clamp_builds`, `a_rejected_blob_gives_an_empty_library`, #128's `VirtualQuery` upload skip).\n- The diff adds no test, so this only shows nothing else broke; the refused-use fallback is not exercised by the suite here.\n\nNo game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠r4tedx on GitHub · 2026-11-24 03:30 UTC · original

Review question (built on main d2a4bae; tests pass on an RTX 5070). When the host refuses a texture, the fallback retries without the uses it refused (fewer.flags &= !drop), which can take away ALLOW_RENDER_TARGET, as in the B4G4R4A4 case in the description. As far as I can follow it, the title's later render-target binds still reach CreateRenderTargetView for that host texture (the draw and clear paths make RTVs for whatever the title binds). Microsoft's description of the flag is "Allows a render target view to be created for the resource", so a view on a texture created without it is invalid, and on a real device that tends to end in a removal rather than a clean error.

Is there a check I missed that skips such binds? If not, #89 takes the other route for the packed 16-bit formats (it renders them as R8G8B8A8, keeping the capability), which avoids the problem for that case.

From reading only; I have no copy of the title.

**@⁠r4tedx** on GitHub · 2026-11-24 03:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7121158173) Review question (built on `main` `d2a4bae`; tests pass on an RTX 5070). When the host refuses a texture, the fallback retries without the uses it refused (`fewer.flags &= !drop`), which can take away `ALLOW_RENDER_TARGET`, as in the B4G4R4A4 case in the description. As far as I can follow it, the title's later render-target binds still reach `CreateRenderTargetView` for that host texture (the draw and clear paths make RTVs for whatever the title binds). Microsoft's description of the flag is "Allows a render target view to be created for the resource", so a view on a texture created without it is invalid, and on a real device that tends to end in a removal rather than a clean error. Is there a check I missed that skips such binds? If not, #89 takes the other route for the packed 16-bit formats (it renders them as R8G8B8A8, keeping the capability), which avoids the problem for that case. From reading only; I have no copy of the title.
Author
Owner

@⁠walterwallaceson on GitHub · 2026-11-24 05:54 UTC · original

Tested #55 (56f1d41) and #89 (081afbd) together on an AMD CPU, so the Intel start-up blocker above doesn't apply: Windows 10 22H2 (19045.6466), RTX 3070, NVIDIA 621.14, Ryzen 5 5600X, release build. Both merged cleanly on top of #233 (3098672) + #175 (19aec59), so this is the four together, not either PR alone.

#175 + #233 + #55 + #89
no host texture (2560x1440, formats 86 and 115, 0x80070057) 2 0
what renders intro only, then nothing during the world load intro, loading screens, the first mission's title card
device removed (0x887A0006, no breadcrumbs) ~60 s into the world load, 27 lists ~40 s into the world load, 32 lists
  • cargo test --workspace: victory-gpu 48 passed (43 without these PRs); the only failures are the known Windows 10 ones (#118/#152, #362).
  • No title exceptions. The two host pipeline refused lines in the run come after the removal (0x887A0005), so they're a consequence of it.
  • New in this run: no free dynamic descriptor slots: a table is not made about 34 s before the removal, the signature #304 and #336 describe. It didn't appear in the #175 + #233 run. Adding #336 on top makes the world last about 2 min instead of 40 s (details on #336).

No game data in this report.

AI-assisted (Claude Code); everything above was run on my machine.

**@⁠walterwallaceson** on GitHub · 2026-11-24 05:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7123389678) Tested #55 (56f1d41) and #89 (081afbd) together on an AMD CPU, so the Intel start-up blocker above doesn't apply: Windows 10 22H2 (19045.6466), RTX 3070, NVIDIA 621.14, Ryzen 5 5600X, release build. Both merged cleanly on top of #233 (3098672) + #175 (19aec59), so this is the four together, not either PR alone. | | #175 + #233 | + #55 + #89 | |---|---|---| | `no host texture` (2560x1440, formats 86 and 115, `0x80070057`) | 2 | 0 | | what renders | intro only, then nothing during the world load | intro, loading screens, the first mission's title card | | device removed (`0x887A0006`, no breadcrumbs) | ~60 s into the world load, 27 lists | ~40 s into the world load, 32 lists | - `cargo test --workspace`: `victory-gpu` 48 passed (43 without these PRs); the only failures are the known Windows 10 ones (#118/#152, #362). - No title exceptions. The two `host pipeline refused` lines in the run come after the removal (`0x887A0005`), so they're a consequence of it. - New in this run: `no free dynamic descriptor slots: a table is not made` about 34 s before the removal, the signature #304 and #336 describe. It didn't appear in the #175 + #233 run. Adding #336 on top makes the world last about 2 min instead of 40 s (details on #336). No game data in this report. AI-assisted (Claude Code); everything above was run on my machine.
Author
Owner

@⁠NuraadGit on GitHub · 2026-11-24 11:45 UTC · original

A gap this leaves on NVIDIA: the render-target views are still made, and one of them removes the device.

When the render-target use is dropped (B4G4R4A4 on NVIDIA), the comment says "the views the host cannot make are skipped as for depth". But the RTV paths don't skip them. draw.rs set_targets and list.rs clear_rtv both call host.rtv(texture, …) for any host texture. CreateRenderTargetView on a texture without ALLOW_RENDER_TARGET writes an invalid descriptor, and the next use removes the device with DXGI_ERROR_INVALID_CALL.

Seen on an RTX 2080 with a stack that includes this change (JMAN730's fork + #493 + #189 + #206 + #667 + 2^18 dynamic slots from #747). That stack makes more world draws run. With the debug layer on (VICTORY_D3D12_DEBUG=1), the last messages before the removal are:

ID3D12Device::CreateRenderTargetView: The format (0x73, B4G4R4A4_UNORM) cannot be used with a RenderTarget view because this particular graphics implementation doesn't support this format.
ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_INVALID_CALL ...)

The fix I used is a check in Host::rtv for whether the texture allows render targets. If it doesn't, the function makes a typed null view instead (R8G8B8A8_UNORM, TEXTURE2D), which discards the writes. A clear of such a texture returns early:

// host.rs
pub(crate) fn renders_to(texture: &ID3D12Resource) -> bool {
    let flags = unsafe { texture.GetDesc() }.Flags;
    flags.contains(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)
}
// in Host::rtv, before CreateRenderTargetView:
let (resource, desc) = match resource {
    Some(r) if !renders_to(r) => (None, Some(&null)), // typed null RTV
    _ => (resource, desc),
};
// list.rs, clear_rtv:
if !crate::host::renders_to(texture) { return; }

Same build, same input, before and after: the device was removed at world entry 2 of 2 times without it, and the run stayed up for 8 minutes with it (~2,430 draws per frame, median 0.91 s per frame). Main's rtv takes &ID3D12Resource rather than Option, so there it's the same check with an early null view. #89 is the fuller fix (render 4444 targets as R8G8B8A8). This is the minimum that makes dropping the use safe.

AI-assisted (Claude Code): the debug-layer run, fix and runs were automated. The hardware, title copy and runs are the user's.

**@⁠NuraadGit** on GitHub · 2026-11-24 11:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7130500585) **A gap this leaves on NVIDIA: the render-target views are still made, and one of them removes the device.** When the render-target use is dropped (B4G4R4A4 on NVIDIA), the comment says "the views the host cannot make are skipped as for depth". But the RTV paths don't skip them. `draw.rs` `set_targets` and `list.rs` `clear_rtv` both call `host.rtv(texture, …)` for any host texture. `CreateRenderTargetView` on a texture without `ALLOW_RENDER_TARGET` writes an invalid descriptor, and the next use removes the device with `DXGI_ERROR_INVALID_CALL`. Seen on an RTX 2080 with a stack that includes this change (JMAN730's fork + #493 + #189 + #206 + #667 + 2^18 dynamic slots from #747). That stack makes more world draws run. With the debug layer on (`VICTORY_D3D12_DEBUG=1`), the last messages before the removal are: ``` ID3D12Device::CreateRenderTargetView: The format (0x73, B4G4R4A4_UNORM) cannot be used with a RenderTarget view because this particular graphics implementation doesn't support this format. ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_INVALID_CALL ...) ``` The fix I used is a check in `Host::rtv` for whether the texture allows render targets. If it doesn't, the function makes a typed null view instead (R8G8B8A8_UNORM, TEXTURE2D), which discards the writes. A clear of such a texture returns early: ```rust // host.rs pub(crate) fn renders_to(texture: &ID3D12Resource) -> bool { let flags = unsafe { texture.GetDesc() }.Flags; flags.contains(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET) } // in Host::rtv, before CreateRenderTargetView: let (resource, desc) = match resource { Some(r) if !renders_to(r) => (None, Some(&null)), // typed null RTV _ => (resource, desc), }; // list.rs, clear_rtv: if !crate::host::renders_to(texture) { return; } ``` Same build, same input, before and after: the device was removed at world entry 2 of 2 times without it, and the run stayed up for 8 minutes with it (~2,430 draws per frame, median 0.91 s per frame). Main's `rtv` takes `&ID3D12Resource` rather than `Option`, so there it's the same check with an early null view. #89 is the fuller fix (render 4444 targets as R8G8B8A8). This is the minimum that makes dropping the use safe. *AI-assisted (Claude Code): the debug-layer run, fix and runs were automated. The hardware, title copy and runs are the user's.*
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-24 16:51 UTC · original

Test report, and a follow-up fix for what this PR exposes.

Setup: RTX 3050 6 GB Laptop (NVIDIA, driver 32.0.16.2124), i7-13700H, 16 GB RAM, Windows 11 26300, diag build. Title 1.0.2.1, Series X profile. Tree: main ffe310e + #208 + the wave64 stack + #452 + #579 + #472/#322/#1024 + #492 (the tree in #1232), plus this PR 56f1d41 (clean merge).

What this PR fixes: the two textures main refuses on this card are created:

host texture without a use the host refuses … width: 2560, height: 1440 … format: 86 … flags: 5
host texture without a use the host refuses … width: 2560, height: 1440 … format: 115 … flags: 1

What it exposes: an invalid call that removes the device. In all three runs with this PR the device was removed 1:41–1:58 in with The application made a call that is invalid (DXGI_ERROR_INVALID_CALL). None of six runs of the same tree without it ended that way (they ran 2:20–9:27 and ended in hangs, resets or title asserts). The cause:

  • The B4G4R4A4 texture (format 115) loses ALLOW_RENDER_TARGET, but the title still clears it and binds it as a target.
  • list.rs (the clear) makes an RTV of it with host.rtv, records a raw barrier to RENDER_TARGET and calls ClearRenderTargetView. All three are invalid on a resource without that flag.
  • draw.rs set_targets also calls host.rtv with no flag check. The UAV path already checks, through fits().

The fix (below, 47 lines; it applies to this PR's head):

  • a host::renders_to(texture) check;
  • the clear is skipped for such a texture, with a one-time warning;
  • set_targets binds a null RTV in that slot (Host::null_rtv), so the other targets keep their slots and the draw writes nothing there. That matches what this PR already does for the views the host cannot make.

With the fix, two runs:

  • no invalid call;
  • clear of a render target the host cannot render to: skipped at 2:18 and render target the host cannot render to: a null view in its slot at 2:41;
  • the runs lasted 5:51 (then the GPU hang this tree has without this PR) and 8:37 (then a title assert).
patch
diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs
index d2537cc..2598d36 100644
--- a/crates/victory-gpu/src/draw.rs
+++ b/crates/victory-gpu/src/draw.rs
@@ -272,6 +272,14 @@ impl State {
             let Some(texture) = crate::resource::host_resource(record.resource) else {
                 continue;
             };
+            if !crate::host::renders_to(texture) {
+                once!(
+                    resource = format_args!("{:#x}", record.resource as usize),
+                    "render target the host cannot render to: a null view in its slot"
+                );
+                rtvs.push(host.null_rtv());
+                continue;
+            }
             self.targets.push(record.resource as usize);
             #[cfg(feature = "diagnostics")]
             crate::capture::note_target(record.resource);
diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs
index 2dc9d27..6e545da 100644
--- a/crates/victory-gpu/src/host.rs
+++ b/crates/victory-gpu/src/host.rs
@@ -1402,6 +1402,25 @@ impl Host {
         }
     }
 
+    /// A null render target view, for a slot the title binds a texture the
+    /// host cannot render to (its copy was made without that use): draws
+    /// write nothing there, and the other targets keep their slots.
+    pub(crate) fn null_rtv(&self) -> D3D12_CPU_DESCRIPTOR_HANDLE {
+        let slot = self.next_rtv.fetch_add(1, Ordering::Relaxed) % RTV_RING;
+        let desc = D3D12_RENDER_TARGET_VIEW_DESC {
+            Format: DXGI_FORMAT_R8G8B8A8_UNORM,
+            ViewDimension: D3D12_RTV_DIMENSION_TEXTURE2D,
+            ..Default::default()
+        };
+        // SAFETY: a slot of our heap; a null resource is allowed with a desc.
+        unsafe {
+            let mut handle = self.rtvs.GetCPUDescriptorHandleForHeapStart();
+            handle.ptr += (slot * self.rtv_size) as usize;
+            self.device.CreateRenderTargetView(None, Some(&desc), handle);
+            handle
+        }
+    }
+
     /// A host depth view of `resource`, valid until it is recorded.
     pub(crate) fn dsv(
         &self,
@@ -2533,6 +2552,14 @@ pub(crate) fn legal_state(texture: &ID3D12Resource, state: u32) -> u32 {
     legal_for(unsafe { texture.GetDesc() }.Flags.0 as u32, state)
 }
 
+/// Whether the host copy of a texture can be a render target: not when the
+/// host refused that use for its format and the copy was made without it.
+pub(crate) fn renders_to(texture: &ID3D12Resource) -> bool {
+    // SAFETY: a plain query.
+    let flags = unsafe { texture.GetDesc() }.Flags;
+    flags.0 & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET.0 != 0
+}
+
 /// [`legal_state`] for a texture with resource flags `flags`.
 pub(crate) fn legal_for(flags: u32, state: u32) -> u32 {
     // (flag, set or clear forbids, state bits): render target, unordered
diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs
index 7adb4e4..b076b67 100644
--- a/crates/victory-gpu/src/list.rs
+++ b/crates/victory-gpu/src/list.rs
@@ -703,6 +703,18 @@ extern "system" fn clear_rtv(
             unsafe { std::slice::from_raw_parts(rects.cast(), count as usize) }
         });
         const RENDER_TARGET: u32 = 0x4;
+        if !crate::host::renders_to(texture) {
+            // Its host copy was made without the render-target use (the
+            // host refuses it for the format): no view, no barrier, no clear.
+            static ONCE: std::sync::Once = std::sync::Once::new();
+            ONCE.call_once(|| {
+                tracing::warn!(
+                    resource = format_args!("{:#x}", record.resource as usize),
+                    "clear of a render target the host cannot render to: skipped"
+                )
+            });
+            return;
+        }
         let rtv = host.rtv(texture, record.desc().as_ref());
         // SAFETY: an open list, a fresh view of a live texture.
         unsafe {

Not tested: AMD (where nothing is dropped, so the new paths never run), more runs, a release build. The null view's format is R8G8B8A8_UNORM, not the dropped format. I have not checked what the debug layer says about the mismatch with the pipeline's RTV format (the debug layer isn't installed here).

AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the patch, ran the title on my machine and drafted this note; results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-24 16:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7138320867) Test report, and a follow-up fix for what this PR exposes. **Setup:** RTX 3050 6 GB Laptop (NVIDIA, driver 32.0.16.2124), i7-13700H, 16 GB RAM, Windows 11 26300, diag build. Title 1.0.2.1, Series X profile. Tree: `main` `ffe310e` + #208 + the wave64 stack + #452 + #579 + #472/#322/#1024 + #492 (the tree in #1232), plus this PR `56f1d41` (clean merge). **What this PR fixes:** the two textures `main` refuses on this card are created: ``` host texture without a use the host refuses … width: 2560, height: 1440 … format: 86 … flags: 5 host texture without a use the host refuses … width: 2560, height: 1440 … format: 115 … flags: 1 ``` **What it exposes: an invalid call that removes the device.** In all three runs with this PR the device was removed 1:41–1:58 in with `The application made a call that is invalid` (`DXGI_ERROR_INVALID_CALL`). None of six runs of the same tree without it ended that way (they ran 2:20–9:27 and ended in hangs, resets or title asserts). The cause: - The `B4G4R4A4` texture (format 115) loses `ALLOW_RENDER_TARGET`, but the title still clears it and binds it as a target. - `list.rs` (the clear) makes an RTV of it with `host.rtv`, records a raw barrier to `RENDER_TARGET` and calls `ClearRenderTargetView`. All three are invalid on a resource without that flag. - `draw.rs` `set_targets` also calls `host.rtv` with no flag check. The UAV path already checks, through `fits()`. **The fix** (below, 47 lines; it applies to this PR's head): - a `host::renders_to(texture)` check; - the clear is skipped for such a texture, with a one-time warning; - `set_targets` binds a null RTV in that slot (`Host::null_rtv`), so the other targets keep their slots and the draw writes nothing there. That matches what this PR already does for the views the host cannot make. **With the fix, two runs:** - no invalid call; - `clear of a render target the host cannot render to: skipped` at 2:18 and `render target the host cannot render to: a null view in its slot` at 2:41; - the runs lasted 5:51 (then the GPU hang this tree has without this PR) and 8:37 (then a title assert). <details><summary>patch</summary> ```diff diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index d2537cc..2598d36 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -272,6 +272,14 @@ impl State { let Some(texture) = crate::resource::host_resource(record.resource) else { continue; }; + if !crate::host::renders_to(texture) { + once!( + resource = format_args!("{:#x}", record.resource as usize), + "render target the host cannot render to: a null view in its slot" + ); + rtvs.push(host.null_rtv()); + continue; + } self.targets.push(record.resource as usize); #[cfg(feature = "diagnostics")] crate::capture::note_target(record.resource); diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 2dc9d27..6e545da 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -1402,6 +1402,25 @@ impl Host { } } + /// A null render target view, for a slot the title binds a texture the + /// host cannot render to (its copy was made without that use): draws + /// write nothing there, and the other targets keep their slots. + pub(crate) fn null_rtv(&self) -> D3D12_CPU_DESCRIPTOR_HANDLE { + let slot = self.next_rtv.fetch_add(1, Ordering::Relaxed) % RTV_RING; + let desc = D3D12_RENDER_TARGET_VIEW_DESC { + Format: DXGI_FORMAT_R8G8B8A8_UNORM, + ViewDimension: D3D12_RTV_DIMENSION_TEXTURE2D, + ..Default::default() + }; + // SAFETY: a slot of our heap; a null resource is allowed with a desc. + unsafe { + let mut handle = self.rtvs.GetCPUDescriptorHandleForHeapStart(); + handle.ptr += (slot * self.rtv_size) as usize; + self.device.CreateRenderTargetView(None, Some(&desc), handle); + handle + } + } + /// A host depth view of `resource`, valid until it is recorded. pub(crate) fn dsv( &self, @@ -2533,6 +2552,14 @@ pub(crate) fn legal_state(texture: &ID3D12Resource, state: u32) -> u32 { legal_for(unsafe { texture.GetDesc() }.Flags.0 as u32, state) } +/// Whether the host copy of a texture can be a render target: not when the +/// host refused that use for its format and the copy was made without it. +pub(crate) fn renders_to(texture: &ID3D12Resource) -> bool { + // SAFETY: a plain query. + let flags = unsafe { texture.GetDesc() }.Flags; + flags.0 & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET.0 != 0 +} + /// [`legal_state`] for a texture with resource flags `flags`. pub(crate) fn legal_for(flags: u32, state: u32) -> u32 { // (flag, set or clear forbids, state bits): render target, unordered diff --git a/crates/victory-gpu/src/list.rs b/crates/victory-gpu/src/list.rs index 7adb4e4..b076b67 100644 --- a/crates/victory-gpu/src/list.rs +++ b/crates/victory-gpu/src/list.rs @@ -703,6 +703,18 @@ extern "system" fn clear_rtv( unsafe { std::slice::from_raw_parts(rects.cast(), count as usize) } }); const RENDER_TARGET: u32 = 0x4; + if !crate::host::renders_to(texture) { + // Its host copy was made without the render-target use (the + // host refuses it for the format): no view, no barrier, no clear. + static ONCE: std::sync::Once = std::sync::Once::new(); + ONCE.call_once(|| { + tracing::warn!( + resource = format_args!("{:#x}", record.resource as usize), + "clear of a render target the host cannot render to: skipped" + ) + }); + return; + } let rtv = host.rtv(texture, record.desc().as_ref()); // SAFETY: an open list, a fresh view of a live texture. unsafe { ``` </details> Not tested: AMD (where nothing is dropped, so the new paths never run), more runs, a release build. The null view's format is `R8G8B8A8_UNORM`, not the dropped format. I have not checked what the debug layer says about the mismatch with the pipeline's RTV format (the debug layer isn't installed here). AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the patch, ran the title on my machine and drafted this note; results are from the runs described.
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-24 19:47 UTC · original

The render-target guard from my comment above is now a PR on its own: #1613. It applies to main, changes nothing there, and stops the invalid-call device removal once this PR lands.

**@⁠AgneyaK** on GitHub · 2026-11-24 19:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7142589601) The render-target guard from my comment above is now a PR on its own: #1613. It applies to `main`, changes nothing there, and stops the invalid-call device removal once this PR lands.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:14 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/resource.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/55#issuecomment-7148308061) <!-- victory-triage v1 head=56f1d413873df6f9313647e86e7e21bf692d9683 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-gpu/src/resource.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/resource.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/55/head:github-bot/gh-55'
git switch 'github-bot/gh-55'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-55'
git switch 'github-bot/gh-55'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-55'
git switch 'github-bot/gh-55'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-55'
git switch 'main'
git merge --squash 'github-bot/gh-55'
git switch 'main'
git merge --ff-only 'github-bot/gh-55'
git switch 'main'
git merge 'github-bot/gh-55'
git push origin 'main'
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!55
No description provided.