Skip to content

Runtime: reject SRVs on depth-stencil textures that deny shader access - #779

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
Vonsek:codex/deny-depth-plane-srv
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
Vonsek:codex/deny-depth-plane-srv

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as depth/stencil SRVs on resources that deny shader access, following the #678 hardware finding.

What and why

A depth/stencil resource can be created with ALLOW_DEPTH_STENCIL | DENY_SHADER_RESOURCE. The Vulkan image already omits sampled-image usage, but CreateShaderResourceView still wrote a live descriptor for either plane. Check the flag after clearing the destination and before encoding or registering a texture SRV.

The regression uses R24G8_TYPELESS and R32G8X24_TYPELESS. For both depth and stencil, it first writes a valid view of an otherwise identical shader-readable resource, then requests the denied view in that same slot and checks every descriptor byte. The ordinary SRV and denied SRV use the same view description. This follows the D3D12 resource flag contract.

Tested

  • Baseline 67204bf: the checked-in regression fails at the first expected null slot on RTX 5080. A separate fixture exercised all four resource/plane combinations on RTX 5080 (616.92) and AMD Radeon Graphics (26.10.1). All four denied views produced live descriptors on each adapter.

  • This head: all four previously populated slots became null on each adapter. The independent two-region DSV clear and shader sampling control on the allowed resources matched 128/128 RGBA texels on each, with Khronos validation enabled.

  • Native Windows D3D12 on RTX, Radeon and WARP: both resource formats returned S_OK with ALLOW_DEPTH_STENCIL alone and with both flags. GetDesc preserved the flags in every case.

  • Integrated main 8df277f by ordinary merge at 6398d46f489959bd6d7ce24eceaaccb2cc084d3e. The general SRV check also covers the volume guard introduced by Runtime: bind 3D shader-resource views through set 0 (D3D-72) #672; the volume-specific LOD check remains. On both RTX and Radeon all four previously populated slots were live with the unmodified new main, and all four became null with this head. The positive sampled-depth probe still matched all 128 texels per adapter. The checked-in RTX descriptor test also passed, including 128/128 volume samples.

  • Fresh MSVC/Ninja build and Windows CTest on RTX: 31/31 with the default validation setting. With Khronos validation enabled, 30/31 passed. The device test reported 10 copy-write synchronization errors on both this head and unmodified 8df277f; tracked in Runtime: order back-to-back copies into an image already in the transfer layout #782. Radeon’s standalone descriptor test reaches the same native-D24 expectation that fails on the base. Combining the original patch with Runtime: depth-plane SRVs only on their own depth family (#678 follow-up) #767 locally passed the stock descriptor test on both adapters.

  • Exact-head GitHub CI: 10/10 checks passed, including the restored rpf9dump build and Wine. CI run · Windows and Wine jobs

  • Merged the next main (dedd75c1) normally at d3949f7798d1762b01be236a96a1564e76dde03f, retaining its cross-family plane checks. The stock descriptor test and the independent four-denied/128-readable-texel test passed with Vulkan validation on both RTX 5080 and Radeon. Full Windows CTest passed all 32 enabled tests both normally and with validation; GameInput is disabled upstream. All 10 checks on the new head passed. Windows and Wine CI

Checklist

  • Only hand-written synthetic resource descriptions and textures were used. No game data, keys or decryption.
  • Runtime-only change. The translator contract is unaffected.

AI-assisted with Codex.

Depth-stencil attachments can opt out of sampling while remaining valid resources. Leave a reused descriptor null before any view is encoded or registered.
The texture-wide deny check now subsumes the volume-specific check. Keep the independent volume LOD restriction and its pixel coverage.
Keep both the cross-family stencil negative and the live-slot shader-access regression on the shared integration base.

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested d3949f7 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • d3d12_descriptor_test (changed here): exit=0 validation=0 | [rt] d3d12_xs: device slot 36 (forwarded) first call
  • 32 test programs in the build pass with 0 validation errors
  • d3d12_clear_test fails (format 28 case 0 byte 2: Vulkan 7f, WARP 80) exactly as on main 67204bf, so not from this PR: NVIDIA rounds a 0.5 UNORM clear to 0x7f, which #521 addresses

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@ItsNotRexed
ItsNotRexed merged commit 0b5a342 into ItsNotRexed:main Nov 22, 2026
10 checks passed
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.

3 participants