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

Closed
leonida/mandy
kotekompotek wants to merge 0 commits from work/d3d12-multi-viewport-scissor into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

kotekompotek commented 2026-11-24 14:18:14 +00:00

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.
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.
abnalstlll-byte approved these changes 2026-11-24 14:22:38 +00:00
abnalstlll-byte left a comment

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.

### 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 approved these changes 2026-11-24 14:25:59 +00:00
abnalstlll-byte left a comment

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.

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.
aslan2142 commented 2026-11-24 19:50:41 +00:00

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).

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).
Sign in to join this conversation.
No description provided.