d3d12: support multi-viewport and multi-scissor up to 16 entries #827

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

@⁠kotekompotek on GitHub · 2026-11-24 14:18 UTC · original
kotekompotek:work/d3d12-multi-viewport-scissor → main · +125 −49 · 8 files · 1 commits · closed without merging

Claimed in the coordination issue as: coordination issue #14

What and why

  • Rebased onto current main.
  • Supported up to 16 viewports and scissor rectangles via VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT / VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT when VkPhysicalDeviceFeatures::multiViewport is enabled, added log_once notice when clamped to 1, and synced docs/d3d12_vulkan.md.

Tested

  • Built d3d12_com_test and ran ctest -R ^d3d12_com$ (Passed, 1.47s).

GPUs tested: NVIDIA GeForce GTX 1050 (driver 582.28, Windows)

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.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠kotekompotek** on GitHub · 2026-11-24 14:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/827) `kotekompotek:work/d3d12-multi-viewport-scissor` → `main` · +125 −49 · 8 files · 1 commits · closed without merging Claimed in the coordination issue as: coordination issue #14 ### What and why - Rebased onto current `main`. - Supported up to 16 viewports and scissor rectangles via `VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT` / `VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT` when `VkPhysicalDeviceFeatures::multiViewport` is enabled, added `log_once` notice when clamped to 1, and synced `docs/d3d12_vulkan.md`. ### Tested - Built `d3d12_com_test` and ran `ctest -R ^d3d12_com$` (`Passed`, 1.47s). GPUs tested: NVIDIA GeForce GTX 1050 (driver 582.28, Windows) 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:23:21 +00:00
github-bot closed this pull request 2026-11-26 09:23:21 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:22 UTC · original · approved these changes

Clean-Room Peer Review for PR #827 (d3d12: support multi-viewport and multi-scissor up to 16 entries)

Outstanding implementation of multi-viewport/scissor rasterizer state:

  • D3D12 API Boundary Parity:
    • RSSetViewports and RSSetScissorRects now support up to D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE (16) elements.
    • Zero-count invocation correctly unbinds all elements ( iewports_.fill({}) / scissors_.fill({})) and sets draw_views_stale_ = true.
    • Rejects count > 16 via check(false).
  • Vulkan Y-Axis Inversion & Dynamic Replay:
    • Replay backend correctly preserves D3D winding by calculating negative-height viewports ({v.x, v.y + v.height, v.width, -v.height, v.min_depth, v.max_depth}) across all array entries.
    • Employs k.set_viewport_with_count and k.set_scissor_with_count dynamically when enabled, while maintaining safe fallback to single-viewport devices.
  • Unit Test Coverage:
    untime/test/d3d12_com_test.cpp and k_test_device.h verify multi-viewport recording and zero-count clearing.
  • Clean-room verification: Strict C++20 compliance, clean MSVC/Clang build, zero proprietary data.

LGTM! Excellent work. Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/827#pullrequestreview-6040934480) · **approved these changes** ### Clean-Room Peer Review for PR #827 (d3d12: support multi-viewport and multi-scissor up to 16 entries) Outstanding implementation of multi-viewport/scissor rasterizer state: - **D3D12 API Boundary Parity**: - RSSetViewports and RSSetScissorRects now support up to D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE (16) elements. - Zero-count invocation correctly unbinds all elements ( iewports_.fill({}) / scissors_.fill({})) and sets draw_views_stale_ = true. - Rejects count > 16 via check(false). - **Vulkan Y-Axis Inversion & Dynamic Replay**: - Replay backend correctly preserves D3D winding by calculating negative-height viewports ({v.x, v.y + v.height, v.width, -v.height, v.min_depth, v.max_depth}) across all array entries. - Employs k.set_viewport_with_count and k.set_scissor_with_count dynamically when enabled, while maintaining safe fallback to single-viewport devices. - **Unit Test Coverage**: untime/test/d3d12_com_test.cpp and k_test_device.h verify multi-viewport recording and zero-count clearing. - **Clean-room verification**: Strict C++20 compliance, clean MSVC/Clang build, zero proprietary data. LGTM! Excellent work. Approved.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:25 UTC · original · approved these changes

Clean-room verified (zero game data). Correct implementation of multi-viewport and multi-scissor arrays (up to 16) in GraphicsCommandList and Vulkan replay via multiViewport / vkCmdSetViewportWithCount. Test coverage in d3d12_com_test.cpp.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/827#pullrequestreview-6041002048) · **approved these changes** Clean-room verified (zero game data). Correct implementation of multi-viewport and multi-scissor arrays (up to 16) in GraphicsCommandList and Vulkan replay via multiViewport / vkCmdSetViewportWithCount. Test coverage in d3d12_com_test.cpp.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:50 UTC · original

Thanks for working on multi-viewport support. I'm closing this in favour of #510, which covers the same item:

  • With an empty viewport 0 and other viewports in use, this PR passes a zero-width VkViewport to
    vkCmdSetViewportWithCount, which breaks VUID-VkViewport-width-01770. #510 sends a 1x1 dummy viewport with an
    empty scissor for those slots.
  • #510 includes a pixel test against native D3D12, with 4 quadrant viewports, separate scissors, mismatched counts
    and an empty viewport 0. Two other contributors have confirmed it on Windows. The d3d12_com_test lines here
    don't assert anything, so they also pass on main.
  • #510 also claimed the item before this PR was opened.
  • Your docs/d3d12_vulkan.md update is useful, and so is the idea of a notice when multiViewport is missing.
    Both are worth bringing into #510 or a follow-up.

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

**@⁠aslan2142** on GitHub · 2026-11-24 19:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/827#issuecomment-7142668537) Thanks for working on multi-viewport support. I'm closing this in favour of #510, which covers the same item: - With an empty viewport 0 and other viewports in use, this PR passes a zero-width `VkViewport` to `vkCmdSetViewportWithCount`, which breaks `VUID-VkViewport-width-01770`. #510 sends a 1x1 dummy viewport with an empty scissor for those slots. - #510 includes a pixel test against native D3D12, with 4 quadrant viewports, separate scissors, mismatched counts and an empty viewport 0. Two other contributors have confirmed it on Windows. The `d3d12_com_test` lines here don't assert anything, so they also pass on `main`. - #510 also claimed the item before this PR was opened. - Your `docs/d3d12_vulkan.md` update is useful, and so is the idea of a notice when `multiViewport` is missing. Both are worth bringing into #510 or a follow-up. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

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