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

Open
github-bot wants to merge 2 commits from github-bot/gh-581 into main AGit
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-24 09:04 UTC · original
Taffyyy-ops:feat/d3d12-forced-sample-count → main · +1723 −43 · 7 files · 2 commits · open

Claimed in the coordination issue as: OLD-7205 (#14)

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.
**@⁠Taffyyy-ops** on GitHub · 2026-11-24 09:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/581) `Taffyyy-ops:feat/d3d12-forced-sample-count` → `main` · +1723 −43 · 7 files · 2 commits · open Claimed in the coordination issue as: OLD-7205 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:09:51 +00:00
Author
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-25 10:16 UTC · original

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).
**@⁠Taffyyy-ops** on GitHub · 2026-11-25 10:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/581#issuecomment-7159464954) 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`).
This pull request has changes conflicting with the target branch.
  • docs/d3d12_vulkan.md
  • runtime/shims/d3d12_vulkan_device.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/581/head:github-bot/gh-581'
git switch 'github-bot/gh-581'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-581'
git switch 'github-bot/gh-581'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-581'
git switch 'github-bot/gh-581'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-581'
git switch 'main'
git merge --squash 'github-bot/gh-581'
git switch 'main'
git merge --ff-only 'github-bot/gh-581'
git switch 'main'
git merge 'github-bot/gh-581'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.