d3d12: RGBA8 render targets of a console device take UNORM and sRGB RTVs without a list (D3D-RGBA8-SRGB-UNORM-RTV) #1204

Closed
github-bot wants to merge 1 commit from gh-pr/1204/head into gh-pr/1204/base
Owner

@⁠DadaCap on GitHub · 2026-11-24 20:14 UTC · original
DadaCap:rgba8-srgb-unorm-rtv → main · +123 −5 · 4 files · 1 commits · closed without merging

Claimed in the coordination issue as: D3D-RGBA8-SRGB-UNORM-RTV

What and why

The retail title draws its Bink movie through an R8G8B8A8_UNORM RTV of an R8G8B8A8_UNORM_SRGB 2D texture made with ALLOW_RENDER_TARGET and no castable list (measured on a retail boot, RTX 5080). CreateRenderTargetView refused the view (unsupported typeless or RGBA8 RTV format/subresource: 28), so the movie's draw had no target. The console allows the cast.

CreateRenderTargetView, the clear path and the draw path already handle this cast when the texture's castable list names the view. So the only change is which list the texture gets: on a device the Xbox-ABI proxy owns (set_device_outer, which D3D12XboxCreateDevice calls), a 2D R8G8B8A8_UNORM or _SRGB render target without a list of its own gets {UNORM, SRGB} in Resource::create_texture. That covers every creation slot (27, 29, 76, 127, 133) without touching the proxy or losing the initial state, and a device without the proxy behaves as before.

Limits:

  • Textures with unordered access, B8G8R8A8 and other families are left as they are: no such cast has been seen.
  • The list also limits SRVs of these textures to the two formats, as any castable list does. An SRV in another format of such a texture is not a valid D3D12 view; it now leaves a null descriptor.
  • The new clears through the sRGB view stay within 1 of the expected bytes, so #1179 (sRGB clear encoding) neither conflicts with nor changes this.

Tested

Built with MSVC (Ninja, RelWithDebInfo). d3d12_draw_test gained a block: for an sRGB texture with a UNORM RTV and the reverse, a clear and a draw are read back as raw bytes, and the same texture made while the device has no proxy must still refuse the RTV (Close fails). With the device change disabled the test does not get through this block; with it, it passes.

Run with and without LEONIDA_VK_VALIDATION=1, exit 0 in both and no VUID messages: d3d12_draw, d3d12_clear, d3d12_typeless_rtv, d3d12_vulkan_device, d3d12_method_variants, typeless_rtv, xs_proxy_mock, d3d12_descriptor, d3d12_present, d3d12_msaa_draw, d3d12_srgb_uav, d3d12_m2_textured, d3d12_m3_frame. d3d12_first_light skips (exit 77). scripts/check_no_game_data.py passes on the touched files.

Not run: the rest of ctest, another GPU, Linux/Wine, the translator suite (untouched), and the retail title with exactly this change (a local prototype with the same list and another gate showed the movie).

GPUs tested: NVIDIA GeForce RTX 5080, 621.24, Windows 11 build 26200

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (not applicable: no translator change)

🤖 Generated with Claude Code

**@⁠DadaCap** on GitHub · 2026-11-24 20:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1204) `DadaCap:rgba8-srgb-unorm-rtv` → `main` · +123 −5 · 4 files · 1 commits · closed without merging Claimed in the coordination issue as: D3D-RGBA8-SRGB-UNORM-RTV ### What and why The retail title draws its Bink movie through an `R8G8B8A8_UNORM` RTV of an `R8G8B8A8_UNORM_SRGB` 2D texture made with `ALLOW_RENDER_TARGET` and no castable list (measured on a retail boot, RTX 5080). `CreateRenderTargetView` refused the view (`unsupported typeless or RGBA8 RTV format/subresource: 28`), so the movie's draw had no target. The console allows the cast. `CreateRenderTargetView`, the clear path and the draw path already handle this cast when the texture's castable list names the view. So the only change is which list the texture gets: on a device the Xbox-ABI proxy owns (`set_device_outer`, which `D3D12XboxCreateDevice` calls), a 2D `R8G8B8A8_UNORM` or `_SRGB` render target without a list of its own gets {UNORM, SRGB} in `Resource::create_texture`. That covers every creation slot (27, 29, 76, 127, 133) without touching the proxy or losing the initial state, and a device without the proxy behaves as before. Limits: - Textures with unordered access, `B8G8R8A8` and other families are left as they are: no such cast has been seen. - The list also limits SRVs of these textures to the two formats, as any castable list does. An SRV in another format of such a texture is not a valid D3D12 view; it now leaves a null descriptor. - The new clears through the sRGB view stay within 1 of the expected bytes, so #1179 (sRGB clear encoding) neither conflicts with nor changes this. ### Tested Built with MSVC (Ninja, RelWithDebInfo). `d3d12_draw_test` gained a block: for an sRGB texture with a UNORM RTV and the reverse, a clear and a draw are read back as raw bytes, and the same texture made while the device has no proxy must still refuse the RTV (`Close` fails). With the device change disabled the test does not get through this block; with it, it passes. Run with and without `LEONIDA_VK_VALIDATION=1`, exit 0 in both and no VUID messages: `d3d12_draw`, `d3d12_clear`, `d3d12_typeless_rtv`, `d3d12_vulkan_device`, `d3d12_method_variants`, `typeless_rtv`, `xs_proxy_mock`, `d3d12_descriptor`, `d3d12_present`, `d3d12_msaa_draw`, `d3d12_srgb_uav`, `d3d12_m2_textured`, `d3d12_m3_frame`. `d3d12_first_light` skips (exit 77). `scripts/check_no_game_data.py` passes on the touched files. Not run: the rest of `ctest`, another GPU, Linux/Wine, the translator suite (untouched), and the retail title with exactly this change (a local prototype with the same list and another gate showed the movie). GPUs tested: NVIDIA GeForce RTX 5080, 621.24, Windows 11 build 26200 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (not applicable: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:49 +00:00
github-bot closed this pull request 2026-11-26 09:42:49 +00:00
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 20:58 UTC · original

Read the whole diff and tested bbf7c82c6 merged on main 66d4f5aa3 (clean), Windows 10 Pro 19045, VS 2022 RelWithDebInfo, LEONIDA_VK_VALIDATION=1. First run of it on Windows 10 and on a second NVIDIA card.

RTX 5060 Ti (NVIDIA 621.01):

d3d12_draw d3d12_clear d3d12_typeless_rtv d3d12_srgb_uav
main pass pass pass pass
this test, main's device code fails, line 1088 (Close, RTV format 28 refused) - - -
this PR pass, console block included pass pass pass

No VUID lines in any run.

Ryzen 7 7700 iGPU (AMD 31.0.22044.1, 128 push-constant bytes): no evidence for or against the new block. d3d12_draw_test stops at its first pipeline (144 bytes needed) before reaching it, on main as well. The other three fail there with and without the PR.

On the code: I checked the case where the title asks D3D12XboxCreateDevice for IDXGIDevice1. is_device_proxy is false for that pointer, but set_device_outer resolves it through device_proxy_primary before set_outer, so console is set there too.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠Snooozs** on GitHub · 2026-11-24 20:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1204#issuecomment-7144295569) Read the whole diff and tested `bbf7c82c6` merged on main `66d4f5aa3` (clean), Windows 10 Pro 19045, VS 2022 RelWithDebInfo, `LEONIDA_VK_VALIDATION=1`. First run of it on Windows 10 and on a second NVIDIA card. RTX 5060 Ti (NVIDIA 621.01): | | `d3d12_draw` | `d3d12_clear` | `d3d12_typeless_rtv` | `d3d12_srgb_uav` | |---|---|---|---|---| | main | pass | pass | pass | pass | | this test, main's device code | fails, line 1088 (`Close`, RTV format 28 refused) | - | - | - | | this PR | pass, console block included | pass | pass | pass | No VUID lines in any run. Ryzen 7 7700 iGPU (AMD 31.0.22044.1, 128 push-constant bytes): no evidence for or against the new block. `d3d12_draw_test` stops at its first pipeline (144 bytes needed) before reaching it, on main as well. The other three fail there with and without the PR. On the code: I checked the case where the title asks `D3D12XboxCreateDevice` for `IDXGIDevice1`. `is_device_proxy` is false for that pointer, but `set_device_outer` resolves it through `device_proxy_primary` before `set_outer`, so `console` is set there too. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠DadaCap on GitHub · 2026-11-25 02:40 UTC · original

Closing this one: main has the rule since #984.

  • Resource::create_texture on main gives an RGBA8 or BGRA8 render target without a castable list its UNORM/sRGB twin (under console_format_stand_ins()), so the movie's R8G8B8A8_UNORM RTV of the R8G8B8A8_UNORM_SRGB target is accepted. That is the draw this pull request was for.
  • One difference: main does it on every device unless LEONIDA_CONSOLE_FORMATS=0; this branch did it only on a device the Xbox-ABI proxy owns, and its d3d12_draw_test case checks that a device without the proxy refuses the view. That check does not hold on main, so the test cannot go in as it is.

If a draw test of main's rule is wanted (clear and draw through both casts, read the bytes back), say so and I will open it as a test-only pull request. The claim D3D-RGBA8-SRGB-UNORM-RTV can be dropped from the table. AI-assisted (Claude Code).

**@⁠DadaCap** on GitHub · 2026-11-25 02:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1204#issuecomment-7151031538) Closing this one: `main` has the rule since #984. - `Resource::create_texture` on `main` gives an RGBA8 or BGRA8 render target without a castable list its UNORM/sRGB twin (under `console_format_stand_ins()`), so the movie's `R8G8B8A8_UNORM` RTV of the `R8G8B8A8_UNORM_SRGB` target is accepted. That is the draw this pull request was for. - One difference: `main` does it on every device unless `LEONIDA_CONSOLE_FORMATS=0`; this branch did it only on a device the Xbox-ABI proxy owns, and its `d3d12_draw_test` case checks that a device without the proxy refuses the view. That check does not hold on `main`, so the test cannot go in as it is. If a draw test of `main`'s rule is wanted (clear and draw through both casts, read the bytes back), say so and I will open it as a test-only pull request. The claim D3D-RGBA8-SRGB-UNORM-RTV can be dropped from the table. AI-assisted (Claude Code).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.