Claimed in the coordination issue as: https://github.com/ItsNotRexed/Leonida/issues/1380#issuecomment-7079110815
What and why
CreateGraphicsPipelineState previously rejected any SampleDesc.Count > 1 with E_NOTIMPL and hardcoded multisample.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT, even though multisampled render targets, RTVs, clears, and ResolveSubresource already work on main.
This change:
- Validates power-of-two sample counts (
1..64) inPipelineState::build_graphics()(runtime/shims/d3d12_vulkan_device.cpp) and rejects non-power-of-two counts withE_INVALIDARG. - Checks
samples > 1againstVkPhysicalDeviceLimits::framebufferColorSampleCounts,framebufferDepthSampleCounts,framebufferStencilSampleCounts, andframebufferNoAttachmentsSampleCountsas appropriate for the PSO's attachments. - Sets
VkPipelineMultisampleStateCreateInfo::rasterizationSamples = VkSampleCountFlagBits(samples). - Adds a synthetic 4× MSAA draw +
ResolveSubresourcetest inruntime/test/d3d12_draw_test.cpp: clears a 4× MSAAR8G8B8A8_UNORMtarget to blue, draws a red quad in the top-left quadrant withSampleMask = 0xFFFFFFFF(all 1,024 top-left pixels resolve to(255, 0, 0, 255)), and runs aSampleMask = 0x5control (2 of 4 samples enabled, resolving all 1,024 top-left pixels to ~50/50 purple(128, 0, 128, 255)). Also verifies that non-power-of-twoSampleDesc.Count = 3returnsE_INVALIDARG.
AI-assisted (Antigravity / Gemini, operated by Vonsek).
Tested
Synthetic scene only (no game files or game shaders were run). Built from commit 445f796e (based on upstream/main 99f99890) on Windows 11 with VS 2022 Build Tools (MSVC 19.44.35230.0), Ninja, -DLEONIDA_VULKAN_HEADERS_FETCH=ON, and Khronos glslang 16.6.0. VK_LOADER_LAYERS_DISABLE=~implicit~ was set; VK_LAYER_KHRONOS_validation is not installed locally on this host (CI runs validation).
Before the fix (99f99890): CreateGraphicsPipelineState with SampleDesc.Count = 4 logged multisampled graphics pipelines not supported yet; samples 4 and returned E_NOTIMPL.
Commands and measured outcomes on 445f796e:
- NVIDIA GeForce RTX 5080 (
0x10de:0x2c02), driver616.92, Vulkan1.4.351(LEONIDA_VK_DEVICE=5080):ctest --test-dir build-msaa-pso -R "^(d3d12_draw|d3d12_vulkan_device)$" --output-on-failure -V-> 2/2 passed.4x MSAA graphics pipeline: 4096/4096 resolved pixels matched (SampleMask 0x5 changed 1024/1024 top-left pixels to purple)
- AMD Radeon(TM) Graphics (
0x1002:0x13c0), driver26.10.1, Vulkan1.4.315(LEONIDA_VK_DEVICE=Radeon):ctest --test-dir build-msaa-pso -R "^d3d12_draw$" --output-on-failure -V-> 1/1 passed.4x MSAA graphics pipeline: 4096/4096 resolved pixels matched (SampleMask 0x5 changed 1024/1024 top-left pixels to purple)
- Negative/mask control: changing
SampleMaskfrom0xFFFFFFFFto0x5(2 of 4 samples) shifted all 1,024/1,024 resolved top-left pixels from(255, 0, 0, 255)to~50/50purple(128, 0, 128, 255)while keeping all 3,072 background pixels(0, 0, 255, 255)on both GPUs.
Checklist
- 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. (N/A — runtime graphics pipeline change only.)