GPU: no render target view of a format the driver refuses while reporting support #2303

Closed
fiestorra wants to merge 1 commit from upstream-pr/2305 into main
fiestorra commented 2026-11-25 10:10:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-25T10:10:26Z.


A 1440p B4G4R4A4_UNORM render target removes the device, and the support query says it should not

With VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_DRED=1 on an RTX 4090 (32.0.16.2124), the debug layer names the call that ends a run (issue #1952):

D3D12: ID3D12Device::CreateRenderTargetView: The format (0x73, B4G4R4A4_UNORM)
    cannot be used with a RenderTarget view because this particular graphics
    implementation doesn't support this                                  id=42
D3D12: ID3D12Device::RemoveDevice: … DXGI_ERROR_INVALID_CALL …           id=232

The obvious guard — refuse the view when CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT) does not report RENDER_TARGET — does not work here, and I measured why before writing this:

format  28 (R8G8B8A8_UNORM): Support1=0x33fcd3f3  RENDER_TARGET=true
format 115 (B4G4R4A4_UNORM): Support1=0x2e4d3f0   RENDER_TARGET=true   ← says yes, then refuses
format  71 (BC1_UNORM):      Support1=0x9013e0    RENDER_TARGET=false

So the query is kept for the formats it answers honestly, and a second, vendor-aware refusal covers the case it gets wrong: NVIDIA reports the format as a target and then refuses the view, while AMD takes it (that is the card on which the same title reaches the lit world).

Change: Host keeps the adapter's VendorId (read from IDXGIDevice::GetAdapter once, at creation — the only other use of a vendor id in this file is a diagnostic in warp_adapter), and rtv asks two things before creating a view:

  • refuses_target(vendor, format): NVIDIA and B4G4R4A4_UNORM — the measured case;
  • takes_render_target(format): the support query, for formats that answer honestly.

When either says no, the slot is filled with a null view and the draw goes nowhere, which costs the target and keeps the device and the run. A warning names the format and the vendor on the first refusal of each format.

Verification

  • the decision is a pure function of (vendor, format) and is tested: NVIDIA + 115 refuses, AMD + 115 does not, NVIDIA + 28 does not. The hardware-dependent half is exercised by the GPU suite, which passes (147 passed, 2 ignored, --features diagnostics);
  • clippy clean with and without --all-features under -D warnings; rustfmt --check shows the same 45 hunks main already has in this file and no new one;
  • what I have not shown: the guard firing in a run. The removal is not deterministic — the same build that died at frame 1,024 in one run reached 8,192 frames in another — so a run where nothing happens is not evidence either way, and I would rather say that than point at a green run as proof. The mechanism is measured, the decision is tested, and the run that hits the path will log no render target of this format on this host: a null view.

No game data is involved: format numbers, a vendor id, an HRESULT and debug-layer text.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6602074967 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-25T10:10:26Z. --- **A 1440p `B4G4R4A4_UNORM` render target removes the device, and the support query says it should not** With `VICTORY_D3D12_DEBUG=1` and `VICTORY_D3D12_DRED=1` on an RTX 4090 (`32.0.16.2124`), the debug layer names the call that ends a run (issue #1952): ``` D3D12: ID3D12Device::CreateRenderTargetView: The format (0x73, B4G4R4A4_UNORM) cannot be used with a RenderTarget view because this particular graphics implementation doesn't support this id=42 D3D12: ID3D12Device::RemoveDevice: … DXGI_ERROR_INVALID_CALL … id=232 ``` The obvious guard — refuse the view when `CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)` does not report `RENDER_TARGET` — **does not work here**, and I measured why before writing this: ``` format 28 (R8G8B8A8_UNORM): Support1=0x33fcd3f3 RENDER_TARGET=true format 115 (B4G4R4A4_UNORM): Support1=0x2e4d3f0 RENDER_TARGET=true ← says yes, then refuses format 71 (BC1_UNORM): Support1=0x9013e0 RENDER_TARGET=false ``` So the query is kept for the formats it answers honestly, and a second, **vendor-aware** refusal covers the case it gets wrong: NVIDIA reports the format as a target and then refuses the view, while AMD takes it (that is the card on which the same title reaches the lit world). **Change**: `Host` keeps the adapter's `VendorId` (read from `IDXGIDevice::GetAdapter` once, at creation — the only other use of a vendor id in this file is a diagnostic in `warp_adapter`), and `rtv` asks two things before creating a view: - `refuses_target(vendor, format)`: NVIDIA and `B4G4R4A4_UNORM` — the measured case; - `takes_render_target(format)`: the support query, for formats that answer honestly. When either says no, the slot is filled with a **null view** and the draw goes nowhere, which costs the target and keeps the device and the run. A warning names the format and the vendor on the first refusal of each format. **Verification** - the decision is a pure function of (vendor, format) and is tested: NVIDIA + 115 refuses, AMD + 115 does not, NVIDIA + 28 does not. The hardware-dependent half is exercised by the GPU suite, which passes (**147 passed, 2 ignored**, `--features diagnostics`); - clippy clean with and without `--all-features` under `-D warnings`; `rustfmt --check` shows the same 45 hunks `main` already has in this file and no new one; - **what I have not shown**: the guard *firing* in a run. The removal is not deterministic — the same build that died at frame 1,024 in one run reached 8,192 frames in another — so a run where nothing happens is not evidence either way, and I would rather say that than point at a green run as proof. The mechanism is measured, the decision is tested, and the run that hits the path will log `no render target of this format on this host: a null view`. No game data is involved: format numbers, a vendor id, an HRESULT and debug-layer text. Written with an AI assistant.
catminou4 commented 2026-11-25 11:04:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:21Z.

Review: COMMENTED


No render target view of a format the driver refuses while its support query says it takes it (vendor-id check, #1952). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Vendor workaround tied to issue #1952.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055714336 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#pullrequestreview-6055714336). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:21Z. **Review:** COMMENTED --- No render target view of a format the driver refuses while its support query says it takes it (vendor-id check, #1952). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Vendor workaround tied to issue #1952.
DenRakEiw commented 2026-11-25 11:04:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T10:21:56Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Checking both refuses_target(self.vendor, ...) (for NVIDIA B4G4R4A4_UNORM #1952) and takes_render_target before CreateRenderTargetView, falling back to a null RTV when unsupported, avoids device removal without penalizing vendors that support the format.
  • cargo test -p victory-gpu host::tests: all 7/7 host::tests::* passed on RTX 5090 and 7/7 on WARP (only the pre-existing NVIDIA #1744 baseline failure in descriptor::host::tests::dynamic_slots_are_held_until_released matched the substring).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055750246 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#pullrequestreview-6055750246). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T10:21:56Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Checking both `refuses_target(self.vendor, ...)` (for NVIDIA `B4G4R4A4_UNORM` #1952) and `takes_render_target` before `CreateRenderTargetView`, falling back to a null RTV when unsupported, avoids device removal without penalizing vendors that support the format. - `cargo test -p victory-gpu host::tests`: all 7/7 `host::tests::*` passed on RTX 5090 and 7/7 on WARP (only the pre-existing NVIDIA #1744 baseline failure in `descriptor::host::tests::dynamic_slots_are_held_until_released` matched the substring). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
fiestorra commented 2026-11-25 11:05:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-25T10:28:08Z.


A risk I want on the record before this lands: a null view of the 1440p target can turn a crash into a black screen

While tracing where the refused format comes from, I found that host_desc asks the host for format 115 unchanged — pc_format only stands in for 118/119/120 — so this 1440p render target reaches D3D12 as B4G4R4A4_UNORM, which NVIDIA refuses.

That means the target this pull request turns into a null view is very plausibly the title's scene target (2560×1440, flags RENDER_TARGET). With the guard, the draw goes nowhere instead of the device dying. For a run, that is better — it survives and can be diagnosed. For a picture, it is not a fix: it can be the black screen the operator reports after the intro (audio and subtitles, no image — issues #904, #1119, #850).

So I want this merged as what it is: a run-keeper, not a renderer, and the description now says so. The picture needs a real stand-in for format 115 in pc_format, which changes the element size (2 bytes per texel today, 4 for R8G8B8A8_UNORM) and therefore the host footprint and every copy of that resource — the same problem the texture ladder in #1630 handles for the other formats, and not a table row.

Two consequences I accept, and one I do not want:

  • accepted: on NVIDIA the title loses that target until the stand-in exists;
  • accepted: the warning names the format and the vendor, so a run that hits it says so once instead of dying silently;
  • not wanted: this being read as "the world renders now". If the picture improves with it, the reason is that the run survives long enough for something else to happen — not that a null target draws anything.

If it is preferred that the guard not land before the stand-in, I will hold it; the mechanism and the measurement are in #1952 either way, and a closed pull request with the analysis is worth more than an open one that misleads.

No game data is involved: a format number and code.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159736659 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#issuecomment-7159736659). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-25T10:28:08Z. --- **A risk I want on the record before this lands: a null view of the 1440p target can turn a crash into a black screen** While tracing where the refused format comes from, I found that `host_desc` asks the host for format 115 unchanged — `pc_format` only stands in for 118/119/120 — so this 1440p render target reaches D3D12 as `B4G4R4A4_UNORM`, which NVIDIA refuses. That means the target this pull request turns into a **null view** is very plausibly the title's scene target (2560×1440, flags `RENDER_TARGET`). With the guard, the draw goes nowhere instead of the device dying. For a run, that is better — it survives and can be diagnosed. For a picture, it is **not** a fix: it can be the black screen the operator reports after the intro (audio and subtitles, no image — issues #904, #1119, #850). So I want this merged as what it is: **a run-keeper, not a renderer**, and the description now says so. The picture needs a real stand-in for format 115 in `pc_format`, which changes the element size (2 bytes per texel today, 4 for `R8G8B8A8_UNORM`) and therefore the host footprint and every copy of that resource — the same problem the texture ladder in #1630 handles for the other formats, and not a table row. Two consequences I accept, and one I do not want: - accepted: on NVIDIA the title loses that target until the stand-in exists; - accepted: the warning names the format and the vendor, so a run that hits it says so once instead of dying silently; - **not** wanted: this being read as "the world renders now". If the picture improves with it, the reason is that the run survives long enough for something else to happen — not that a null target draws anything. If it is preferred that the guard not land before the stand-in, I will hold it; the mechanism and the measurement are in #1952 either way, and a closed pull request with the analysis is worth more than an open one that misleads. No game data is involved: a format number and code. Written with an AI assistant.
Marvisak commented 2026-11-25 16:09:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:22:13Z.


Automated triage for the maintainers.

Verdict: needs work. Re-reviewed at d41e177, which now merges cleanly into main. The fallback in Host::rtv (crates/victory-gpu/src/host.rs) calls CreateRenderTargetView(None, None, handle). D3D12 only accepts a null resource when a view description is given, so this call is itself invalid. KainanP's RTX 4060 run in this thread confirms it: the B4G4R4A4 case still removes the device. A null view needs a D3D12_RENDER_TARGET_VIEW_DESC with a supported format and the right ViewDimension. artor410 also reports that on an RTX 3070 Ti the support query already refuses format 115, so refuses_target's fixed NVIDIA + 115 rule needs evidence from more drivers, or it should be dropped in favour of the query.

As you say in your own follow-up, a null target only keeps the run alive. Several open PRs widen packed 16-bit targets to a format the host can render instead (#2626, #2767, #2936). Please check whether one of them already covers #1952. If it does, this PR may not be needed.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166735802 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#issuecomment-7166735802). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:22:13Z. --- <!-- victory-triage v1 head=d41e17705f31da2f12b31c731a07d3250a43249c verdict=needs-work at=2026-11-26T03:19:16Z --> Automated triage for the maintainers. **Verdict: needs work.** Re-reviewed at `d41e177`, which now merges cleanly into `main`. The fallback in `Host::rtv` (`crates/victory-gpu/src/host.rs`) calls `CreateRenderTargetView(None, None, handle)`. D3D12 only accepts a null resource when a view description is given, so this call is itself invalid. KainanP's RTX 4060 run in this thread confirms it: the B4G4R4A4 case still removes the device. A null view needs a `D3D12_RENDER_TARGET_VIEW_DESC` with a supported format and the right `ViewDimension`. artor410 also reports that on an RTX 3070 Ti the support query already refuses format 115, so `refuses_target`'s fixed NVIDIA + 115 rule needs evidence from more drivers, or it should be dropped in favour of the query. As you say in your own follow-up, a null target only keeps the run alive. Several open PRs widen packed 16-bit targets to a format the host can render instead (#2626, #2767, #2936). Please check whether one of them already covers #1952. If it does, this PR may not be needed. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
KainanP commented 2026-11-25 20:06:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-25T19:36:19Z.


RTX 4060 Laptop (610.47), merged onto main 13f91cae (adjacent-test conflict, kept both): the B4G4R4A4 half still removes the device, because the null view CreateRenderTargetView(None, None, ..) (null resource and null description) is itself an invalid call; the UAV half is unchanged; no new failures. Details and the side-by-side table with the other #1753 PRs: https://github.com/Marvisak/VIctory/issues/1753#issuecomment-7172510623. Tested with the help of an AI assistant (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172526038 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#issuecomment-7172526038). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-25T19:36:19Z. --- RTX 4060 Laptop (610.47), merged onto main 13f91cae (adjacent-test conflict, kept both): the B4G4R4A4 half **still removes the device**, because the null view `CreateRenderTargetView(None, None, ..)` (null resource and null description) is itself an invalid call; the UAV half is unchanged; no new failures. Details and the side-by-side table with the other #1753 PRs: https://github.com/Marvisak/VIctory/issues/1753#issuecomment-7172510623. Tested with the help of an AI assistant (Claude Code).
artor410 commented 2026-11-25 22:04:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by artor410 on 2026-11-25T21:53:23Z.


Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main 13f91ca. Does not merge into main (conflicts in host.rs), so only the head dbce84b was tested.

  • cargo test -p victory-gpu on the head: 142 passed, 2 failed (the same heap-cap pair as on main), 2 ignored. New a_format_a_vendor_refuses_is_known_before_the_view_is_made passes.
  • Not probed on hardware because of the conflict. On main here, an RTV of B4G4R4A4 (115) removes the device (0x887A0001), which is the case this PR guards.
  • CheckFeatureSupport on this card reports no RENDER_TARGET for 115, so the query alone catches it here and the NVIDIA vendor special case is not needed.
  • RTV only: UAV views of 86/115 still crash the driver on main (0xc0000005), and this PR does not touch them.

(Claude Code, Claude Opus 5.5.)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175668490 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#issuecomment-7175668490). Originally posted by [artor410](https://github.com/artor410) on 2026-11-25T21:53:23Z. --- Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main 13f91ca. Does not merge into main (conflicts in `host.rs`), so only the head dbce84b was tested. - `cargo test -p victory-gpu` on the head: 142 passed, 2 failed (the same heap-cap pair as on main), 2 ignored. New `a_format_a_vendor_refuses_is_known_before_the_view_is_made` passes. - Not probed on hardware because of the conflict. On main here, an RTV of B4G4R4A4 (115) removes the device (0x887A0001), which is the case this PR guards. - `CheckFeatureSupport` on this card reports no RENDER_TARGET for 115, so the query alone catches it here and the NVIDIA vendor special case is not needed. - RTV only: UAV views of 86/115 still crash the driver on main (0xc0000005), and this PR does not touch them. (Claude Code, Claude Opus 5.5.)
upstream-sync closed this pull request 2026-11-26 13:03:40 +00:00
fiestorra commented 2026-11-26 13:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-26T12:22:53Z.


Closed into #2332, which now carries both halves

You are right that a null target only keeps the run alive, and the two branches were the same cluster: #2332 now asks the host first (does it refuse B4G4R4A4_UNORM as a target, does it take B5G5R5A1_UNORM) and makes the texture as the stand-in only then, so a refused target is a real view where the host takes one. The guard this branch added (Host::rtv → null view with a warning) is kept there as the last resort for a format neither is taken.

So there is one place that decides the format (stand_in_for in host.rs, called from host_desc) and one that decides the view (Host::rtv), instead of two PRs racing to describe the same texture.

Head of the surviving branch: #2332 at 31848207.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191927533 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2305#issuecomment-7191927533). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-26T12:22:53Z. --- **Closed into #2332, which now carries both halves** You are right that a null target only keeps the run alive, and the two branches were the same cluster: #2332 now asks the host first (does it refuse `B4G4R4A4_UNORM` as a target, does it take `B5G5R5A1_UNORM`) and makes the texture as the stand-in only then, so a refused target is a real view where the host takes one. The guard this branch added (`Host::rtv` → null view with a warning) is kept there as the last resort for a format neither is taken. So there is one place that decides the format (`stand_in_for` in `host.rs`, called from `host_desc`) and one that decides the view (`Host::rtv`), instead of two PRs racing to describe the same texture. Head of the surviving branch: #2332 at `31848207`. Written with an AI assistant.

Pull request closed

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