[PR #1014] [CLOSED] Runtime: sample a typeless colour texture's multisample SRV #1052

Closed
opened 2026-11-26 20:19:55 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1014
Author: @roanh47
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: pr/msaa-typeless


📝 Commits (1)

  • abfe559 Runtime: sample a typeless colour texture's multisample SRV

📊 Changes

4 files changed (+563 additions, -5 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+7 -2)
📝 runtime/CMakeLists.txt (+19 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+34 -3)
➕ runtime/test/d3d12_msaa_typeless_srv_test.cpp (+503 -0)

📄 Description

Claim: RT-MSAA-TYPELESS-SRV

Builds on the merged multisampled SRV binding (88dc8beac, "Runtime: bind multisampled 2D and array shader-resource views"). No game data.

Log source

runtime/shims/d3d12_vulkan_device.cpp, the multisample SRV refusal in image_descriptor:

log_once("multisample shader view requires a matching typed colour format:", int(desc.Format));

The check required the texture's storage format to be typed (!format.typeless) and the view's format to equal the
resource's, so every typeless colour texture was refused, although D3D12 requires an SRV of a typeless resource to
name a concrete member of the texture's typeless family. No legal MSAA SRV of such a texture existed.

Changes

  • runtime/shims/d3d12_vulkan_device.cpp
    • image_descriptor: an MSAA SRV of a typeless colour texture now resolves the concrete SRV format from the
      texture's own typeless family (format_family), and is refused only when the view names no format (UNKNOWN), a
      typeless format, another family's format, or one that does not map to a GFX10 format. The generic path then
      writes the T# for the named format, as the typed MSAA path already did.
    • New DeviceState::multisample_sampleable(): refuses a view format the GPU does not sample at the texture's
      sample count, with vkGetPhysicalDeviceImageFormatProperties and the usages a multisampled colour texture is
      created with (colour attachment, sampled, transfer source/destination).
    • Depth-stencil textures keep their refusal, now with their own message (multisample shader view requires a colour texture); typed MS textures keep the original message. Every refusal still leaves a null descriptor.
  • runtime/test/d3d12_msaa_typeless_srv_test.cpp, runtime/CMakeLists.txt: a new GPU test, ctest
    d3d12_msaa_typeless_srv.
  • docs/d3d12_vulkan.md: describes the typeless colour resolution and takes "typeless color SRVs" off the
    descriptor-path gap list.

Test

Synthetic fixtures only, no game data. d3d12_msaa_typeless_srv_test creates a 4x4, 4x R8G8B8A8_TYPELESS render
target, clears it to blue through an R8G8B8A8_UNORM RTV, draws a red triangle over the half above the diagonal and
a green quad over the bottom-right quadrant with PSO SampleMask 0x1, and creates its SRV with
Format = R8G8B8A8_UNORM. It checks the T# decodes to the same image as the default SRV of a typed
R8G8B8A8_UNORM 4x twin (format, type, width, height, layers, samples; the image address is the only difference),
then a compute shader (cs_sample.comp -DTEST_MS_FLOAT=1) looks the T# up in set 0's hash table and reads all four
samples of the 4x4 image: red where the triangle covers every sample, blue where the clear shows through, green in
sample 0 of the masked quad, and red-or-blue (never green) on the diagonal's partially covered pixels.

Negative cases assert null descriptors for: a typeless view format, UNKNOWN on a typeless texture, another
family's format, a single-sample view of the 4x texture, a foreign format on a typed MS texture, and an MS view of an
R32G8X24_TYPELESS depth texture.

With the previous shim the test fails:

[rt] d3d12: multisample shader view requires a matching typed colour format: 27
line 363: image_at(typeless_view, image)
exit 1

With the change (MSVC 14.44 / Visual Studio 2022 Build Tools, Ninja, RelWithDebInfo, LEONIDA_VK_VALIDATION=1):

> .\d3d12_msaa_typeless_srv_test.exe
device: NVIDIA GeForce RTX 3070 (validation on)
subgroup sizes: 32..32 (default 32), requirable in stages 0x3fff, subgroupSizeControl on, computeFullSubgroups on
MSAA typeless SRV: R8G8B8A8_TYPELESS 4x target cleared and drawn, 64 samples matched through its R8G8B8A8_UNORM T#; typeless, foreign-family, UNKNOWN, single-sample and depth views stayed null
exit 0

Related suites, same build and validation layer:

ctest -R "d3d12_(descriptor|msaa|typeless|view_slices|state_map|vulkan_device|clear_formats|resource_desc)"
 1/11 Test #174: d3d12_vulkan_device ..............   Passed   12.74 sec
 2/11 Test #206: d3d12_descriptor .................   Passed    0.75 sec
 3/11 Test #215: d3d12_typeless_rtv ...............   Passed    8.64 sec
 4/11 Test #217: d3d12_view_slices ................   Passed    1.78 sec
 5/11 Test #218: d3d12_typeless_families ..........   Passed    6.06 sec
 6/11 Test #222: d3d12_resource_desc ..............   Passed    0.72 sec
 7/11 Test #223: d3d12_typeless_depth .............   Passed    0.27 sec
 8/11 Test #255: d3d12_msaa_draw ..................   Passed    0.32 sec
 9/11 Test #256: d3d12_msaa_typeless_srv ..........   Passed    0.49 sec
10/11 Test #268: d3d12_clear_formats ..............   Passed    0.85 sec
11/11 Test #283: d3d12_state_map ..................   Passed    0.01 sec

100% tests passed out of 11

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 docs/d3d12_vulkan.md exits 0.

Note on the logged format (19)

19 is DXGI_FORMAT_R32G8X24_TYPELESS, whose family is depth-stencil (texture_storage_format maps it to a
D32_SFLOAT_S8_UINT image either way), so the exact retail line describes a multisampled depth SRV, not a colour
one. This PR implements the typeless colour resolution the claim describes; that depth view stays refused and is now
logged as multisample shader view requires a colour texture: 19. The limit is not the format: D32_SFLOAT_S8_UINT
is 4x-sampleable here (vkGetPhysicalDeviceImageFormatProperties), but multisampled depth/stencil SRVs and the
image_msaa_load lowering translated shaders would need are a documented gap (docs/d3d12_vulkan.md, descriptor
path), so supporting the depth case is left rather than faked.

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.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1014 **Author:** [@roanh47](https://github.com/roanh47) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/msaa-typeless` --- ### 📝 Commits (1) - [`abfe559`](https://github.com/ubiquitarianism/leonida/commit/abfe55934cf638e221d0fe0adef4dec9468ce817) Runtime: sample a typeless colour texture's multisample SRV ### 📊 Changes **4 files changed** (+563 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+7 -2) 📝 `runtime/CMakeLists.txt` (+19 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+34 -3) ➕ `runtime/test/d3d12_msaa_typeless_srv_test.cpp` (+503 -0) </details> ### 📄 Description Claim: [RT-MSAA-TYPELESS-SRV](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137294269) Builds on the merged multisampled SRV binding (88dc8beac, "Runtime: bind multisampled 2D and array shader-resource views"). No game data. ## Log source `runtime/shims/d3d12_vulkan_device.cpp`, the multisample SRV refusal in `image_descriptor`: ```cpp log_once("multisample shader view requires a matching typed colour format:", int(desc.Format)); ``` The check required the texture's storage format to be typed (`!format.typeless`) and the view's format to equal the resource's, so *every* typeless colour texture was refused, although D3D12 requires an SRV of a typeless resource to name a concrete member of the texture's typeless family. No legal MSAA SRV of such a texture existed. ## Changes - `runtime/shims/d3d12_vulkan_device.cpp` - `image_descriptor`: an MSAA SRV of a typeless colour texture now resolves the concrete SRV format from the texture's own typeless family (`format_family`), and is refused only when the view names no format (`UNKNOWN`), a typeless format, another family's format, or one that does not map to a GFX10 format. The generic path then writes the T# for the named format, as the typed MSAA path already did. - New `DeviceState::multisample_sampleable()`: refuses a view format the GPU does not sample at the texture's sample count, with `vkGetPhysicalDeviceImageFormatProperties` and the usages a multisampled colour texture is created with (colour attachment, sampled, transfer source/destination). - Depth-stencil textures keep their refusal, now with their own message (`multisample shader view requires a colour texture`); typed MS textures keep the original message. Every refusal still leaves a null descriptor. - `runtime/test/d3d12_msaa_typeless_srv_test.cpp`, `runtime/CMakeLists.txt`: a new GPU test, ctest `d3d12_msaa_typeless_srv`. - `docs/d3d12_vulkan.md`: describes the typeless colour resolution and takes "typeless color SRVs" off the descriptor-path gap list. ## Test Synthetic fixtures only, no game data. `d3d12_msaa_typeless_srv_test` creates a 4x4, 4x `R8G8B8A8_TYPELESS` render target, clears it to blue through an `R8G8B8A8_UNORM` RTV, draws a red triangle over the half above the diagonal and a green quad over the bottom-right quadrant with PSO `SampleMask 0x1`, and creates its SRV with `Format = R8G8B8A8_UNORM`. It checks the T# decodes to the same image as the default SRV of a typed `R8G8B8A8_UNORM` 4x twin (format, type, width, height, layers, samples; the image address is the only difference), then a compute shader (`cs_sample.comp -DTEST_MS_FLOAT=1`) looks the T# up in set 0's hash table and reads all four samples of the 4x4 image: red where the triangle covers every sample, blue where the clear shows through, green in sample 0 of the masked quad, and red-or-blue (never green) on the diagonal's partially covered pixels. Negative cases assert null descriptors for: a typeless view format, `UNKNOWN` on a typeless texture, another family's format, a single-sample view of the 4x texture, a foreign format on a typed MS texture, and an MS view of an `R32G8X24_TYPELESS` depth texture. With the previous shim the test fails: ``` [rt] d3d12: multisample shader view requires a matching typed colour format: 27 line 363: image_at(typeless_view, image) exit 1 ``` With the change (MSVC 14.44 / Visual Studio 2022 Build Tools, Ninja, `RelWithDebInfo`, `LEONIDA_VK_VALIDATION=1`): ``` > .\d3d12_msaa_typeless_srv_test.exe device: NVIDIA GeForce RTX 3070 (validation on) subgroup sizes: 32..32 (default 32), requirable in stages 0x3fff, subgroupSizeControl on, computeFullSubgroups on MSAA typeless SRV: R8G8B8A8_TYPELESS 4x target cleared and drawn, 64 samples matched through its R8G8B8A8_UNORM T#; typeless, foreign-family, UNKNOWN, single-sample and depth views stayed null exit 0 ``` Related suites, same build and validation layer: ``` ctest -R "d3d12_(descriptor|msaa|typeless|view_slices|state_map|vulkan_device|clear_formats|resource_desc)" 1/11 Test #174: d3d12_vulkan_device .............. Passed 12.74 sec 2/11 Test #206: d3d12_descriptor ................. Passed 0.75 sec 3/11 Test #215: d3d12_typeless_rtv ............... Passed 8.64 sec 4/11 Test #217: d3d12_view_slices ................ Passed 1.78 sec 5/11 Test #218: d3d12_typeless_families .......... Passed 6.06 sec 6/11 Test #222: d3d12_resource_desc .............. Passed 0.72 sec 7/11 Test #223: d3d12_typeless_depth ............. Passed 0.27 sec 8/11 Test #255: d3d12_msaa_draw .................. Passed 0.32 sec 9/11 Test #256: d3d12_msaa_typeless_srv .......... Passed 0.49 sec 10/11 Test #268: d3d12_clear_formats .............. Passed 0.85 sec 11/11 Test #283: d3d12_state_map .................. Passed 0.01 sec 100% tests passed out of 11 ``` `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 docs/d3d12_vulkan.md` exits 0. ## Note on the logged format (19) `19` is `DXGI_FORMAT_R32G8X24_TYPELESS`, whose family is depth-stencil (`texture_storage_format` maps it to a `D32_SFLOAT_S8_UINT` image either way), so the exact retail line describes a multisampled **depth** SRV, not a colour one. This PR implements the typeless colour resolution the claim describes; that depth view stays refused and is now logged as `multisample shader view requires a colour texture: 19`. The limit is not the format: `D32_SFLOAT_S8_UINT` is 4x-sampleable here (`vkGetPhysicalDeviceImageFormatProperties`), but multisampled depth/stencil SRVs and the `image_msaa_load` lowering translated shaders would need are a documented gap (`docs/d3d12_vulkan.md`, descriptor path), so supporting the depth case is left rather than faked. ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:55 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1052
No description provided.