mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:25:53 +01:00
[PR #510] [MERGED] d3d12/vulkan: implement multi-viewport and multi-scissor rendering (D3D-MULTI-VIEWPORT) #558
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#558
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/510
Author: @jujumoneylol
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142
Base:
main← Head:pr/d3d12-multi-viewport📝 Commits (1)
7d50f3bd3d12/vulkan: implement multi-viewport and multi-scissor rendering (1..16 viewports/scissors)📊 Changes
9 files changed (+652 additions, -40 deletions)
View changed files
📝
runtime/CMakeLists.txt(+9 -0)📝
runtime/shims/d3d12_com.cpp(+60 -9)📝
runtime/shims/d3d12_vulkan_device.cpp(+24 -20)📝
runtime/src/command_list.h(+10 -0)📝
runtime/src/vulkan_backend.h(+3 -0)📝
runtime/src/vulkan_replay.h(+56 -11)➕
runtime/test/d3d12_multi_viewport_test.cpp(+484 -0)📝
runtime/test/replay_cpu_bench.cpp(+2 -0)📝
runtime/test/vk_test_device.h(+4 -0)📄 Description
Claimed in the coordination issue as: D3D-MULTI-VIEWPORT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7124010841)
Depends on: #469, #499 (adjacent lines in
vulkan_replay.hdraw replay,d3d12_vulkan_device.cpp,d3d12_com.cpp, andvk_test_device.hif multiple merge; this branch is based cleanly on currentmain8f481cf16with no code dependency on either)What and why
Previously,
RSSetViewportsandRSSetScissorRectssilently dropped every viewport and scissor past index 0 (stub("more than one viewport; the first is used")), and graphics pipelines fixedviewportCount = 1/scissorCount = 1even thoughmainalready enables Vulkan 1.2shaderOutputViewportIndexand advertisesVPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation = TRUE.runtime/src/command_list.h,runtime/shims/d3d12_com.cpp):GraphicsCommandList(validatingcount <= 16on both) and caches a sharedDrawViewportsblock (zero allocation per draw, andnullptr/ zero overhead for the common 1-viewport case).record_drawandDispatchMeshto skip rasterization only when all bound viewports are empty, so draws with an empty viewport 0 and active viewports 1..15 still run.runtime/src/vulkan_backend.h,runtime/shims/d3d12_vulkan_device.cpp,runtime/src/vulkan_replay.h):VkPhysicalDeviceFeatures::multiViewportincreate_vulkan_device_standaloneandvktest::Device(plusshaderOutputViewportIndexinvktest::Device).vkCmdSetViewportWithCountandvkCmdSetScissorWithCount(Vulkan 1.3 core) and switches graphics pipelines toVK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT+VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT(withviewportCount = 0,scissorCount = 0) wheneverfeatures.multiViewportand the entry points are available (falling back cleanly to single-viewportvkCmdSetViewport/vkCmdSetScissorotherwise).count = max(vp_count, sc_count)to both calls, pairs empty/unbound viewport slots with a 1×1 dummy viewport and an empty{0, 0, 0, 0}scissor so nothing rasterizes and Vulkan'swidth > 0VUID is satisfied, and clips unbound scissor slots with{0, 0, 0, 0}.runtime/test/d3d12_multi_viewport_test.cpp):OpCapability MultiViewport+OpCapability ShaderViewportIndexwritingBuiltIn ViewportIndex, HLSL viad3dcompiler_47for host reference).Tested
d3d12_multi_viewport_test,d3d12_state_map_test, andreplay_cpu_benchwith MSVC 19.44 (vcvars64) + Ninja on top ofmain8f481cf16.d3d12_multi_viewport_test: ALL 4 CASES PASSED (EXACT MATCH vs host D3D12) — 64/64 pixels exact on every case on NVIDIA GeForce GTX 1650 with 0 validation errors.d3d12_state_map_test: PASSED.py -3.13 -I scripts/check_no_game_data.pyon all 9 touched files: clean.GPUs tested: NVIDIA GeForce GTX 1650 Mobile 4 GB (driver 592.00, Vulkan 1.4.325, Windows 11 26200)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — D3D12 → Vulkan runtime only)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.