Runtime: sample a typeless colour texture's multisample SRV #1014

Closed
github-bot wants to merge 1 commit from gh-pr/1014/head into gh-pr/1014/base
Owner

@⁠roanh47 on GitHub · 2026-11-24 16:53 UTC · original
pr/msaa-typeless → main · +563 −5 · 4 files · 1 commits · closed without merging

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.

**@⁠roanh47** on GitHub · 2026-11-24 16:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1014) `pr/msaa-typeless` → `main` · +563 −5 · 4 files · 1 commits · closed without merging Claim: [RT-MSAA-TYPELESS-SRV](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) 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.
The MSAA SRV path refused every typeless colour texture with
"multisample shader view requires a matching typed colour format", although
D3D12 requires such a view to name a concrete member of the texture's typeless
family. Resolve the SRV format from that family and write the T# for it, and
refuse a format the GPU does not sample at the texture's sample count. A
typeless or UNKNOWN view format, one from another family, a non-sampleable
format and a depth texture stay null descriptors, each with its own log.

Adds d3d12_msaa_typeless_srv_test: a D3D12 clear and SampleMask draws into an
R8G8B8A8_TYPELESS 4x target, then all four samples of the 4x4 image are read
through its R8G8B8A8_UNORM T# by cs_sample.comp on the bindless set and
compared per sample.

Claim RT-MSAA-TYPELESS-SRV. AI-assisted (DeepSeek v4.1 Flash 1017).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:33:35 +00:00
github-bot closed this pull request 2026-11-26 09:33:35 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-24 16:53 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-24 16:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1014#pullrequestreview-6043646389) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.