mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:30:52 +01:00
[PR #1183] [CLOSED] Runtime: serve a multisampled depth-stencil SRV's depth plane #1215
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1215
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1183
Author: @roanh47
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:pr/msaa-depth-srv📝 Commits (2)
abfe559Runtime: sample a typeless colour texture's multisample SRV9fd3270Runtime: serve a multisampled depth-stencil SRV's depth plane📊 Changes
6 files changed (+1139 additions, -10 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+15 -2)📝
runtime/CMakeLists.txt(+39 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+55 -7)➕
runtime/test/d3d12_msaa_depth_srv_test.cpp(+512 -0)➕
runtime/test/d3d12_msaa_typeless_srv_test.cpp(+504 -0)📝
runtime/test/glsl/cs_sample.comp(+14 -1)📄 Description
Claim: RT-MSAA-DEPTH-SRV
Depends on #1014 (the typeless colour fix, "Runtime: sample a typeless colour texture's multisample SRV"). This
branch is stacked on that one, so the diff below #1014's commit includes it; review the top commit for this change.
No game data.
Log source
runtime/shims/d3d12_vulkan_device.cpp, the multisample SRV refusal inimage_descriptor:The retail prototype's
19isDXGI_FORMAT_R32G8X24_TYPELESS, aD32_SFLOAT_S8_UINTdepth-stencil image, soevery multisampled shader-resource view of it was refused and left a null descriptor.
Changes
runtime/shims/d3d12_vulkan_device.cppimage_descriptor: a multisampled SRV of a depth-stencil texture is now its depth plane, so it goes through thesame plane checks single-sampled views use (
R32G8X24_TYPELESStakesR32_FLOAT_X8X24_TYPELESS,R24G8_TYPELESSR24_UNORM_X8_TYPELESS,D32_FLOATR32_FLOAT,D16_UNORMR16_UNORM;UNKNOWNonly on the typed ones). Thecolour path (#1014) is unchanged. D3D12's
TEXTURE2DMS/TEXTURE2DMSARRAYSRVs have no plane field, so plane 1is not an SRV shape.
DeviceState::multisample_sampleable()takes the texture's aspects: a depth texture is queried as a depthattachment (sampled, copied) at the resource's sample count, a colour texture as a colour attachment.
CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT): the depth-plane formats advertiseMULTISAMPLE_LOADwhen thedepth image can be sampled at a multisampled count and set 0 has the float pair — the host PC runtime advertises
it for
R32_FLOAT_X8X24_TYPELESS,X32_TYPELESS_G8X24_UINT,R24_UNORM_X8_TYPELESSandX24_TYPELESS_G8_UINT(measured with a native device: formats 21, 22, 46, 47) and for the typed formats (41,56), and does not for the depth formats themselves (20, 45).
CreateShaderResourceView'sTEXTURE2DMS/TEXTURE2DMSARRAYpaths are unchanged: they name plane 0.runtime/test/glsl/cs_sample.comp: aTEST_MS_DEPTHvariant that reads the four samples of atexture2DMSandwrites their raw float bits.
runtime/test/d3d12_msaa_depth_srv_test.cpp,runtime/CMakeLists.txt: new GPU test, ctestd3d12_msaa_depth_srv.runtime/test/d3d12_msaa_typeless_srv_test.cpp: #1014's "an MS view of a depth texture is null" negative becomes"a colour format on a depth texture is null", since the depth plane is now served (the depth test covers it).
docs/d3d12_vulkan.md: describes the depth-plane MSAA SRV and itsMULTISAMPLE_LOADbit, and removes"multisampled depth/stencil SRVs" from the descriptor-path gap list.
Tests
Synthetic only, no game data.
d3d12_msaa_depth_srv_testcreates a 4x4, 4xR32G8X24_TYPELESSdepth target,clears depth to 0.5 (stencil 0x5a), draws a red triangle with PSO
SampleMask 0x1(its sample 0 writes depth 0,samples 1-3 keep the clear), creates the SRV with
Format = R32_FLOAT_X8X24_TYPELESSandTEXTURE2DMS, and checksthe T# decodes to
X24_8_32_FLOAT, a multisampled 2D image with four samples. A compute shader looks the T# up inset 0's hash table and reads all four depth samples of each 4x4 texel, comparing the raw float bits (0.0 in sample 0
of covered texels, 0.5 from the clear elsewhere; the diagonal's partial pixels are either). It also asserts
MULTISAMPLE_LOADfor the plane format, as the host reports it.Null descriptors asserted for: a
TEXTURE2Dview of the 4x texture (non-MSAA), aTEXTURE2DMSview of asingle-sampled depth texture,
R24_UNORM_X8_TYPELESS(another family),R32_FLOAT, a colour format,UNKNOWNonthe typeless texture, and
R32_FLOAT_X8X24_TYPELESSon aD32_FLOATtexture without a stencil. A 16x creation isasserted
E_INVALIDARGexactly when the GPU's quality-levels query says 16x does not exist.With #1014's shim (before this commit) the test fails on the retail line:
With this change (MSVC 14.44 / Visual Studio 2022 Build Tools, Ninja,
RelWithDebInfo,LEONIDA_VK_VALIDATION=1):The colour test from #1014 still passes:
Related suites, same build and validation layer:
The full
ctest -R "^d3d12_"run has two failures on this machine that are not from this change:d3d12_execute_indirect_validation(5 WARP-vs-NVIDIA argument-validation parity mismatches) andd3d12_clear(Vulkan validation rejects depth clears outside [0, 1] and NaN without
VK_EXT_depth_range_unrestricted). Both failidentically with the shim reverted to #1014's commit.
python -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/CMakeLists.txt runtime/test/d3d12_msaa_typeless_srv_test.cpp runtime/test/d3d12_msaa_depth_srv_test.cpp runtime/test/glsl/cs_sample.comp docs/d3d12_vulkan.mdexits 0.Not in this PR:
image_msaa_loadloweringThe runtime half is here — the SRV is served, its T# is written and set 0 can sample it, so a translated shader
that lowers
image_msaa_loadwill find it. Lowering the instruction itself is not included:docs/fssm_crosscheck.mdrecords that
image_msaa_loadis in no shader of the translated 26,503-shader corpus, and the repository has nomeasured disassembly of its operands (its sample index comes from VADDR, and its DMASK/D16/TFE forms are unmeasured),
so writing a rule now would be guessing at a shape nothing can validate. It needs its own item: MS image types and
the 2DMS/2DMS-array bindings (20-25) in the generated module, an
image_msaa_loadrule with semantic fixtures, anda GPU test once a translated shader can be built for one. Filed as a finding in the coordination issue.
GPU / driver
NVIDIA GeForce RTX 3070 (8 GiB), NVIDIA driver 610.88 on Windows, Vulkan 1.4.363 SDK.
AI-assisted: DeepSeek v4.1 Flash 1017.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.