Skip to content

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

Closed
TimIdle wants to merge 1 commit into
ProjectLeonida:mainfrom
TimIdle:oldpr-9955-srv-validation
Closed

TimIdle wants to merge 1 commit into
ProjectLeonida:mainfrom
TimIdle:oldpr-9955-srv-validation

Conversation

@TimIdle

@TimIdle TimIdle commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

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

@TimIdle

TimIdle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
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.
@TimIdle
TimIdle force-pushed the oldpr-9955-srv-validation branch from 25e3bce to 6fb60a7 Compare November 25, 2026 06:13
@TimIdle

TimIdle commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

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-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@aslan2142 aslan2142 added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
@TimIdle

TimIdle commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

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

@TimIdle TimIdle closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants