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

Merged
Andretuta merged 1 commit from upstream-pr/220 into main 2026-11-30 17:16:16 +00:00
Andretuta commented 2026-11-24 02:47:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:47:02Z.


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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465123237 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/220). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:47:02Z. --- > 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)
OreoFR commented 2026-11-29 17:02:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T17:02:39Z.


@justr4mzi this carried-over PR (your old PR 9955) now conflicts with main (runtime/shims/d3d12_vulkan_device.cpp). Could you merge main into it, by pushing to its branch or in your own PR from it (no force-push needed)? If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259375364 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/220#issuecomment-7259375364). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T17:02:39Z. --- @justr4mzi this carried-over PR (your old PR 9955) now conflicts with `main` (`runtime/shims/d3d12_vulkan_device.cpp`). Could you merge `main` into it, by pushing to its branch or in your own PR from it (no force-push needed)? If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)
OreoFR commented 2026-11-30 13:40:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:40:22Z.


Carried as #2729 because of the conflict with main after #2566; @justr4mzi, if you come back, say so and the carry is dropped.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7280186108 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/220#issuecomment-7280186108). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:40:22Z. --- Carried as #2729 because of the conflict with main after #2566; @justr4mzi, if you come back, say so and the carry is dropped.
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
ProjectLeonida/mandy!220
No description provided.