runtime/d3d12: implement ForcedSampleCount target-independent rasterization (OLD-7205) #581

Closed
Taffyyy-ops wants to merge 2 commits from upstream-pr/581 into main
Taffyyy-ops commented 2026-11-24 09:04:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-24T09:04:08Z.


Claimed in the coordination issue as: OLD-7205 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126487215)

What and why

Carried over from the closed upstream ItsNotRexed/Leonida PR #7205 and rebased cleanly onto ubiquitarianism/leonida main (fecb3cc1b, 2830b134a).

Implements D3D12 Target-Independent Rasterization (D3D12_RASTERIZER_DESC::ForcedSampleCount ∈ {0, 1, 4, 8, 16}):

  • Captures and validates ForcedSampleCount (plus depth/stencil disabled and DXGI_FORMAT_UNKNOWN DSV rules, and SampleDesc.Count == 1 when ForcedSampleCount > 1) in runtime/shims/d3d12_vulkan_device.cpp (D3D12_RESOURCE_DESC / PSO creation and d3d12_com.h).
  • Supports attachmentless TIR on Vulkan (0 color attachments + rasterizationSamples = ForcedSampleCount) unconditionally when supported, and 1x-RTV mixed-sample TIR via VK_NV_framebuffer_mixed_samples (enabled by default on NVIDIA) or VK_AMD_mixed_attachment_samples (gated behind explicit opt-in LEONIDA_VK_AMD_MIXED_SAMPLES=1 due to AMD SV_Coverage / SampleMask / RDNA4 occlusion divergences measured in upstream #7205 review).
  • Exposes/queries mixed-sample capability through runtime/src/vulkan_replay.h and runtime/test/vk_test_device.h, updates docs/d3d12_vulkan.md, and adds comprehensive host-parity tests (d3d12_forced_sample_count) in runtime/test/d3d12_forced_sample_count_test.cpp and runtime/CMakeLists.txt.

Tested

Built cleanly with MSVC 19.44 / Ninja (cmake --build runtime/build, 0 new /W4 warnings on modified files) and verified after rebasing onto 1c93c8697:

  • NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, Windows 11, vs native D3D12 + Microsoft WARP):
    • ctest --test-dir runtime/build -R "^d3d12_forced_sample_count$" --output-on-failure -V -> Passed (2.39 sec, all checks passed: 22 PSO validation cases, 15+ attachmentless occlusion scenes, mixed-sample RGBA8 / SV_Coverage / MRT / unbound-RTV / conservative TIR, capability gating, multi-submission PSO switching sequence).
  • Intel RaptorLake-S Mobile Graphics Controller (Windows 11, vs Microsoft WARP / D3D12):
    • ctest --test-dir runtime/build -R "^d3d12_forced_sample_count$" --output-on-failure -V -> Passed (0.63 sec, attachmentless TIR 15/15 passed, capability gating mixed_attachment_samples=0 verified).
  • python -I scripts/check_no_game_data.py -> exit 0
  • git diff --check upstream/main..HEAD -> exit 0

Previous independent runs on the identical rebased code (upstream ItsNotRexed/Leonida PR #7205 before repo closure): NVIDIA RTX 3060, RTX 3070 (Khronos core+sync validation 1.4.363.0, 0 errors), RTX 5070 Ti, RTX 5080, and AMD Radeon RX 9060 XT (RDNA4, driver 26.11.2, including LEONIDA_VK_VALIDATION=1).

GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, Windows 11); Intel(R) RaptorLake-S Mobile Graphics Controller (Windows 11); plus WARP reference

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5469175935 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/581). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-24T09:04:08Z. --- Claimed in the coordination issue as: OLD-7205 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126487215) ### What and why Carried over from the closed upstream `ItsNotRexed/Leonida` PR #7205 and rebased cleanly onto `ubiquitarianism/leonida` `main` (`fecb3cc1b`, `2830b134a`). Implements D3D12 Target-Independent Rasterization (`D3D12_RASTERIZER_DESC::ForcedSampleCount` ∈ `{0, 1, 4, 8, 16}`): - Captures and validates `ForcedSampleCount` (plus depth/stencil disabled and `DXGI_FORMAT_UNKNOWN` DSV rules, and `SampleDesc.Count == 1` when `ForcedSampleCount > 1`) in `runtime/shims/d3d12_vulkan_device.cpp` (`D3D12_RESOURCE_DESC` / PSO creation and `d3d12_com.h`). - Supports attachmentless TIR on Vulkan (0 color attachments + rasterizationSamples = `ForcedSampleCount`) unconditionally when supported, and 1x-RTV mixed-sample TIR via `VK_NV_framebuffer_mixed_samples` (enabled by default on NVIDIA) or `VK_AMD_mixed_attachment_samples` (gated behind explicit opt-in `LEONIDA_VK_AMD_MIXED_SAMPLES=1` due to AMD `SV_Coverage` / `SampleMask` / RDNA4 occlusion divergences measured in upstream #7205 review). - Exposes/queries mixed-sample capability through `runtime/src/vulkan_replay.h` and `runtime/test/vk_test_device.h`, updates `docs/d3d12_vulkan.md`, and adds comprehensive host-parity tests (`d3d12_forced_sample_count`) in `runtime/test/d3d12_forced_sample_count_test.cpp` and `runtime/CMakeLists.txt`. ### Tested Built cleanly with MSVC 19.44 / Ninja (`cmake --build runtime/build`, 0 new `/W4` warnings on modified files) and verified after rebasing onto `1c93c8697`: - **NVIDIA GeForce RTX 5060 Laptop GPU** (`driver 621.24`, Windows 11, vs native D3D12 + Microsoft WARP): - `ctest --test-dir runtime/build -R "^d3d12_forced_sample_count$" --output-on-failure -V` -> Passed (`2.39 sec`, all checks passed: 22 PSO validation cases, 15+ attachmentless occlusion scenes, mixed-sample RGBA8 / SV_Coverage / MRT / unbound-RTV / conservative TIR, capability gating, multi-submission PSO switching sequence). - **Intel RaptorLake-S Mobile Graphics Controller** (Windows 11, vs Microsoft WARP / D3D12): - `ctest --test-dir runtime/build -R "^d3d12_forced_sample_count$" --output-on-failure -V` -> Passed (`0.63 sec`, attachmentless TIR 15/15 passed, capability gating `mixed_attachment_samples=0` verified). - `python -I scripts/check_no_game_data.py` -> exit 0 - `git diff --check upstream/main..HEAD` -> exit 0 Previous independent runs on the identical rebased code (upstream `ItsNotRexed/Leonida` PR #7205 before repo closure): NVIDIA RTX 3060, RTX 3070 (Khronos core+sync validation 1.4.363.0, 0 errors), RTX 5070 Ti, RTX 5080, and AMD Radeon RX 9060 XT (RDNA4, driver 26.11.2, including `LEONIDA_VK_VALIDATION=1`). GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, Windows 11); Intel(R) RaptorLake-S Mobile Graphics Controller (Windows 11); plus WARP reference AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
Taffyyy-ops commented 2026-11-25 10:16:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-25T10:16:15Z.


Rebased onto upstream/main (3de22a19047b168d28a7a11152bf05d18ed0062e) at dd604fd47 (93bd7c8ed + dd604fd47), picking up the upstream fixes for #892 (cs_imgload_tfe / cs_imgload_d16_tfe), ce9bf43c5 (test_tool_stdout_encoding.py), crt_timed_wait (_Cnd_timedwait_for_unchecked), and #1547 (perf/pipeline-compile-workers) and clearing needs rebase:

  • runtime/shims/d3d12_vulkan_device.cpp: Kept topology_type in the conservative-raster triangle check, replaced the placeholder r.ForcedSampleCount stream_unsupported stub inside conservative-raster validation with ForcedSampleCount TIR handling across create_graphics, converted the missing mixed_attachment_samples and ForcedSampleCount == 1 && SampleDesc.Count > 1 checks to stream_unsupported(...), kept device_.depth_backing(f.format), and preserved info.pipeline_creation_feedback alongside mixed_samples_ext in create_vulkan_device_standalone.
  • runtime/src/vulkan_replay.h: Kept all #1547 GraphicsPipeline fields (rectangle_stage, rectangle_variant_topology, variant, built, large, async_build) and updated the samples comment.

Local Verification (AI-assisted, Windows 11)

  • Build: MSVC 19.44 (vcvars64.bat + Ninja), 740/740 targets built (0 errors, 0 new /W4 warnings in PR files).
  • NVIDIA GeForce RTX 5060 Laptop GPU (driver 32.0.16.2124): 6/6 targeted CTests passed (d3d12_pipeline_workers, d3d12_vulkan_device, d3d12_method_variants, d3d12_clear, d3d12_forced_sample_count, crt_timed_wait; 19.85s).
  • Intel RaptorLake-S Mobile Graphics Controller (driver 32.0.101.7026): 6/6 targeted CTests passed (d3d12_pipeline_workers, d3d12_vulkan_device, d3d12_method_variants, d3d12_clear, d3d12_forced_sample_count, crt_timed_wait; 9.95s).
  • Python, docs & hygiene: test_ctest_registration.py (5/5 OK), test_vulkan_extension_guards.py (3/3 OK), all 12 test_docs_*.py suites OK, check_no_game_data.py (exit 0), git diff --check upstream/main..HEAD (exit 0).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7159464954 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/581#issuecomment-7159464954). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-25T10:16:15Z. --- Rebased onto `upstream/main` (`3de22a19047b168d28a7a11152bf05d18ed0062e`) at `dd604fd47` (`93bd7c8ed` + `dd604fd47`), picking up the upstream fixes for `#892` (`cs_imgload_tfe` / `cs_imgload_d16_tfe`), `ce9bf43c5` (`test_tool_stdout_encoding.py`), `crt_timed_wait` (`_Cnd_timedwait_for_unchecked`), and `#1547` (`perf/pipeline-compile-workers`) and clearing `needs rebase`: - **`runtime/shims/d3d12_vulkan_device.cpp`:** Kept `topology_type` in the conservative-raster triangle check, replaced the placeholder `r.ForcedSampleCount` `stream_unsupported` stub inside conservative-raster validation with `ForcedSampleCount` TIR handling across `create_graphics`, converted the missing `mixed_attachment_samples` and `ForcedSampleCount == 1 && SampleDesc.Count > 1` checks to `stream_unsupported(...)`, kept `device_.depth_backing(f.format)`, and preserved `info.pipeline_creation_feedback` alongside `mixed_samples_ext` in `create_vulkan_device_standalone`. - **`runtime/src/vulkan_replay.h`:** Kept all `#1547` `GraphicsPipeline` fields (`rectangle_stage`, `rectangle_variant_topology`, `variant`, `built`, `large`, `async_build`) and updated the `samples` comment. ### Local Verification (AI-assisted, Windows 11) - **Build:** MSVC 19.44 (`vcvars64.bat` + Ninja), `740/740` targets built (`0` errors, `0` new `/W4` warnings in PR files). - **NVIDIA GeForce RTX 5060 Laptop GPU (driver `32.0.16.2124`):** `6/6` targeted CTests passed (`d3d12_pipeline_workers`, `d3d12_vulkan_device`, `d3d12_method_variants`, `d3d12_clear`, `d3d12_forced_sample_count`, `crt_timed_wait`; `19.85s`). - **Intel RaptorLake-S Mobile Graphics Controller (driver `32.0.101.7026`):** `6/6` targeted CTests passed (`d3d12_pipeline_workers`, `d3d12_vulkan_device`, `d3d12_method_variants`, `d3d12_clear`, `d3d12_forced_sample_count`, `crt_timed_wait`; `9.95s`). - **Python, docs & hygiene:** `test_ctest_registration.py` (`5/5` OK), `test_vulkan_extension_guards.py` (`3/3` OK), all `12` `test_docs_*.py` suites OK, `check_no_game_data.py` (exit `0`), `git diff --check upstream/main..HEAD` (exit `0`).
MoonEyes commented 2026-11-28 17:58:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:58:16Z.


Hi @Taffyyy-ops, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/d3d12_vulkan.md, runtime/shims/d3d12_vulkan_device.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243428032 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/581#issuecomment-7243428032). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:58:16Z. --- Hi @Taffyyy-ops, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `docs/d3d12_vulkan.md`, `runtime/shims/d3d12_vulkan_device.cpp`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 16:30:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:30:53Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317732487 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/581#issuecomment-7317732487). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:30:53Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!581
No description provided.