OLD-9955: CreateShaderResourceView refuses the views D3D12 refuses (carries #220) #1195

Closed
github-bot wants to merge 1 commit from github-bot/gh-1195 into main AGit
Owner

@⁠TimIdle on GitHub · 2026-11-24 19:59 UTC · original
TimIdle:oldpr-9955-srv-validation → main · +508 −12 · 3 files · 1 commits · closed without merging

Claimed in the coordination issue as: OLD-9955 (claim)

What and why

This carries forward old-pr/9955 by @⁠justr4mzi (draft #220). The commit is cherry-picked onto main unchanged, with the author kept.

CreateShaderResourceView on main writes a descriptor for some views the D3D12 runtime refuses. The layer now refuses them too, in image_descriptor (runtime/shims/d3d12_vulkan_device.cpp):

  • a component mapping without the always-set bit or with a selector past FORCE_VALUE_1, for every view (before, only multisample views were checked)
  • a ResourceMinLODClamp that is negative or NaN
  • a typeless view format, or DXGI_FORMAT_UNKNOWN on a typeless texture
  • a view whose mip or array range ends past the texture (before, only the array range of multisample views)

runtime/test/d3d12_srv_validation_test.cpp compares the layer with the host D3D12 runtime case by case.

Tested

Native Windows 11 10.0.26300, MSVC 19.44, RelWithDebInfo, LEONIDA_REQUIRE_VULKAN=ON, on main 42537e7 plus the commit.

Check Result
d3d12_srv_validation_test with the fix pass: 16 valid cases accepted, 90 invalid cases rejected (0 validation errors)
d3d12_srv_validation_test with main's d3d12_vulkan_device.cpp fail: line 305: expect_null_srv(tex1d.p, &bad)
full ctest -j 6 403 of 403 passed, gameinput and gameinput_script disabled.

GPUs tested: NVIDIA GeForce RTX 2050 (Ampere GA107, laptop), driver 621.24, Windows 11

AI-assisted: yes (Claude Code)

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. (No translator rule here.)

🤖 Generated with Claude Code

**@⁠TimIdle** on GitHub · 2026-11-24 19:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1195) `TimIdle:oldpr-9955-srv-validation` → `main` · +508 −12 · 3 files · 1 commits · closed without merging Claimed in the coordination issue as: OLD-9955 ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)) ### What and why This carries forward `old-pr/9955` by @⁠justr4mzi (draft #220). The commit is cherry-picked onto `main` unchanged, with the author kept. `CreateShaderResourceView` on `main` writes a descriptor for some views the D3D12 runtime refuses. The layer now refuses them too, in `image_descriptor` (`runtime/shims/d3d12_vulkan_device.cpp`): - a component mapping without the always-set bit or with a selector past `FORCE_VALUE_1`, for every view (before, only multisample views were checked) - a `ResourceMinLODClamp` that is negative or NaN - a typeless view format, or `DXGI_FORMAT_UNKNOWN` on a typeless texture - a view whose mip or array range ends past the texture (before, only the array range of multisample views) `runtime/test/d3d12_srv_validation_test.cpp` compares the layer with the host D3D12 runtime case by case. ### Tested Native Windows 11 10.0.26300, MSVC 19.44, RelWithDebInfo, `LEONIDA_REQUIRE_VULKAN=ON`, on `main` `42537e7` plus the commit. | Check | Result | |---|---| | `d3d12_srv_validation_test` with the fix | pass: `16 valid cases accepted, 90 invalid cases rejected (0 validation errors)` | | `d3d12_srv_validation_test` with `main`'s `d3d12_vulkan_device.cpp` | fail: `line 305: expect_null_srv(tex1d.p, &bad)` | | full `ctest -j 6` | 403 of 403 passed, `gameinput` and `gameinput_script` disabled. | GPUs tested: NVIDIA GeForce RTX 2050 (Ampere GA107, laptop), driver 621.24, Windows 11 AI-assisted: yes (Claude Code) ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule here.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reopened from #5275 (closed in the PR reset), rebased on current main.

Brings non-MSAA/non-volume SRV validation to parity with the MSAA/volume
checks: Shader4ComponentMapping (bit 12 and the four selectors) on every
texture and buffer SRV, negative or NaN ResourceMinLODClamp, typeless
resource/view formats outside depth/stencil, finite MipLevels/ArraySize
bounds on every dimension, and the TextureCubeArray NumCubes overflow.
An invalid view leaves the destination slot zeroed. Adds
d3d12_srv_validation_test.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:23 +00:00
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:08 UTC · original

Recommendation: [WAIT]

Reasoning: Carries #220: CreateShaderResourceView refuses the views the D3D12 runtime refuses (invalid component mapping, bad mip/array ranges, etc.), with a 459-line validation test. Matching D3D12 is right, but refusing views that were previously accepted could expose title paths that relied on the lax behaviour. It also touches the same image_descriptor area as #1097/#1183. No independent run yet: one second-person run plus a smoke check of the title boot would be good before merging. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main.

Impact level: 5/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1195#issuecomment-7143089097) **Recommendation:** [WAIT] **Reasoning:** Carries #220: `CreateShaderResourceView` refuses the views the D3D12 runtime refuses (invalid component mapping, bad mip/array ranges, etc.), with a 459-line validation test. Matching D3D12 is right, but refusing views that were previously accepted could expose title paths that relied on the lax behaviour. It also touches the same `image_descriptor` area as #1097/#1183. No independent run yet: one second-person run plus a smoke check of the title boot would be good before merging. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. **Impact level:** 5/10
Author
Owner

@⁠TimIdle on GitHub · 2026-11-25 02:15 UTC · original

Rebased onto main c266c26. main moved the buffer view code into write_buffer_srv, so the component-mapping check for buffer views now sits right before that call. The texture checks in image_descriptor are unchanged. On the RTX 2050 d3d12_srv_validation_test still accepts 16 valid cases and rejects 90 invalid ones, and the full ctest is 362 of 362.

**@⁠TimIdle** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1195#issuecomment-7150494201) Rebased onto `main` `c266c26`. `main` moved the buffer view code into `write_buffer_srv`, so the component-mapping check for buffer views now sits right before that call. The texture checks in `image_descriptor` are unchanged. On the RTX 2050 `d3d12_srv_validation_test` still accepts 16 valid cases and rejects 90 invalid ones, and the full `ctest` is 362 of 362.
Author
Owner

@⁠TimIdle on GitHub · 2026-11-25 06:13 UTC · original

Rebased onto main 42537e7. main now builds unordered-access views through image_descriptor too, so the checks of this PR now run there as well. A UAV keeps the default component mapping and a MinLOD of 0, so it passes them. The PR's general layer check replaces the multisample-only one, and main's UAV slice checks stay. On the RTX 2050 d3d12_srv_validation_test passes with 16 valid cases accepted and 90 invalid cases rejected, and it still fails at line 305 with main's file. The full ctest is 403 of 403.

**@⁠TimIdle** on GitHub · 2026-11-25 06:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1195#issuecomment-7154565740) Rebased onto `main` `42537e7`. `main` now builds unordered-access views through `image_descriptor` too, so the checks of this PR now run there as well. A UAV keeps the default component mapping and a MinLOD of 0, so it passes them. The PR's general layer check replaces the multisample-only one, and `main`'s UAV slice checks stay. On the RTX 2050 `d3d12_srv_validation_test` passes with 16 valid cases accepted and 90 invalid cases rejected, and it still fails at line 305 with `main`'s file. The full `ctest` is 403 of 403.
github-bot closed this pull request 2026-11-26 11:42:20 +00:00
Author
Owner

@⁠TimIdle on GitHub · 2026-11-26 11:41 UTC · original

Closing this one, no review yet and CI is red. Will reopen if it is still needed.

**@⁠TimIdle** on GitHub · 2026-11-26 11:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1195#issuecomment-7191038596) Closing this one, no review yet and CI is red. Will reopen if it is still needed.

Pull request closed

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