d3d12: validate CreateShaderResourceView descriptors (reopens #5275) #220

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

@⁠Andretuta on GitHub · 2026-11-24 02:47 UTC · original
ubiquitarianism:old-pr/9955 → main · +508 −12 · 3 files · 1 commits · draft

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)
**@⁠Andretuta** on GitHub · 2026-11-24 02:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/220) `ubiquitarianism:old-pr/9955` → `main` · +508 −12 · 3 files · 1 commits · draft > 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)
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 08:49:14 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_vulkan_device.cpp
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/220/head:github-bot/gh-220'
git switch 'github-bot/gh-220'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-220'
git switch 'github-bot/gh-220'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-220'
git switch 'github-bot/gh-220'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-220'
git switch 'main'
git merge --squash 'github-bot/gh-220'
git switch 'main'
git merge --ff-only 'github-bot/gh-220'
git switch 'main'
git merge 'github-bot/gh-220'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.