[PR #220] d3d12: validate CreateShaderResourceView descriptors (reopens #5275) #272

Open
opened 2026-11-26 20:17:20 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/220
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9955


📝 Commits (1)

  • 7342ead d3d12: validate CreateShaderResourceView descriptors

📊 Changes

3 files changed (+508 additions, -12 deletions)

View changed files

📝 runtime/CMakeLists.txt (+8 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+41 -12)
➕ runtime/test/d3d12_srv_validation_test.cpp (+459 -0)

📄 Description

Carried over from old PR 9955 by justr4mzi in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9955, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
justr4mzi: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: #5156 (comment), carried over from #5275

Reopens #5275, which was closed in the PR reset, rebased onto current main. The patch applied cleanly.

What and why

This brings non-MSAA/non-volume CreateShaderResourceView validation up to parity with the existing MSAA/volume checks:

  • Shader4ComponentMapping: the always-set bit 12 and all four selectors are checked on every texture and buffer SRV.
  • ResourceMinLODClamp: negative and NaN values are rejected.
  • Typeless formats: outside depth/stencil, a typeless resource with no view format (or DXGI_FORMAT_UNKNOWN) is rejected, and so is a typeless view format, on every dimension.
  • MipLevels/ArraySize: finite out-of-range values are rejected on every dimension instead of being silently clamped.
  • TextureCubeArray NumCubes overflow: it now gives 0 layers, so the view is rejected, instead of wrapping to UINT_MAX.

An invalid view leaves the destination slot zeroed (a null descriptor). The PR also adds d3d12_srv_validation_test.

Tested

  • #5275 head cfe2e6d (the same code before the rebase), with d3d12_srv_validation_test: 16 valid cases accepted, 90 invalid cases rejected, 0 Vulkan validation errors.
    • The targeted ctest subset passed 8/8 on RX 6700 XT (mine), RTX 4070 Ti (SirKingg), RX 7600 (ricardotanaka), RTX 3060 (Koro4e) and RTX 5070 Ti (Kam471, review with no blockers).
    • Koro4e compared the results with the host debug layer: the invalid mappings, ranges, cube arrays and typeless cases agree.
    • Koro4e had two non-blocking notes:
      • The host doesn't flag a negative or NaN MinLODClamp at create time.
      • CUBEARRAY with NumCubes=UINT_MAX on fewer than 6 layers is still accepted.
  • This rebase: not built on Windows yet. CI is the first build of this exact commit.

AI-assisted: yes (Claude)

Checklist

  • 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. (n/a: no translator change)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/220 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9955` --- ### 📝 Commits (1) - [`7342ead`](https://github.com/ubiquitarianism/leonida/commit/7342eadaa549907554f18a46ca7c30578375d5df) d3d12: validate CreateShaderResourceView descriptors ### 📊 Changes **3 files changed** (+508 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+8 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+41 -12) ➕ `runtime/test/d3d12_srv_validation_test.cpp` (+459 -0) </details> ### 📄 Description > Carried over from **old PR 9955** by `justr4mzi` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9955`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `justr4mzi`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue as: `#5156` (comment), carried over from `#5275` Reopens `#5275`, which was closed in the PR reset, rebased onto current main. The patch applied cleanly. ### What and why This brings non-MSAA/non-volume `CreateShaderResourceView` validation up to parity with the existing MSAA/volume checks: - **Shader4ComponentMapping:** the always-set bit 12 and all four selectors are checked on every texture and buffer SRV. - **ResourceMinLODClamp:** negative and NaN values are rejected. - **Typeless formats:** outside depth/stencil, a typeless resource with no view format (or `DXGI_FORMAT_UNKNOWN`) is rejected, and so is a typeless view format, on every dimension. - **MipLevels/ArraySize:** finite out-of-range values are rejected on every dimension instead of being silently clamped. - **TextureCubeArray NumCubes overflow:** it now gives 0 layers, so the view is rejected, instead of wrapping to UINT_MAX. An invalid view leaves the destination slot zeroed (a null descriptor). The PR also adds `d3d12_srv_validation_test`. ### Tested - **`#5275` head cfe2e6d** (the same code before the rebase), with `d3d12_srv_validation_test`: 16 valid cases accepted, 90 invalid cases rejected, 0 Vulkan validation errors. - The targeted ctest subset passed 8/8 on RX 6700 XT (mine), RTX 4070 Ti (SirKingg), RX 7600 (ricardotanaka), RTX 3060 (Koro4e) and RTX 5070 Ti (Kam471, review with no blockers). - Koro4e compared the results with the host debug layer: the invalid mappings, ranges, cube arrays and typeless cases agree. - Koro4e had two non-blocking notes: - The host doesn't flag a negative or NaN MinLODClamp at create time. - CUBEARRAY with NumCubes=UINT_MAX on fewer than 6 layers is still accepted. - **This rebase:** not built on Windows yet. CI is the first build of this exact commit. AI-assisted: yes (Claude) ### Checklist - [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. (n/a: no translator change) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#272
No description provided.