Repository navigation
Runtime: viewport and scissor arrays (RSSetViewports, RSSetScissorRects) - #873
TheHoracio wants to merge 1 commit into
Conversation
|
I tested same-list rebinding at The source-built 64×64 RGBA8 fixture issued two draws on one PSO/list. Both drew red and blue quads into two 32×32 viewports. The first draw filled the top half. I moved both viewports to the bottom half and varied only the scissor call before the second draw. The initial scissors covered the full-height left and right halves. The zero-count call passed the same valid array pointer as the nonzero call.
Counts are painted pixels in the bottom half. In the one-scissor case, exactly its left 32×32 became red. All paths kept the top half intact. Both Leonida adapters passed the stock test and reported zero Vulkan validation errors. All native lists closed successfully; the native D3D12 debug layer was unavailable here. The early return on AI-assisted independent verification. |
The call replaces the whole array, so a count of 0 now clears it and the next draws see D3D12's empty default rectangle. WARP and NVIDIA's D3D12 driver do this; AMD's keeps the old rectangles (@Vonsek's measurement on ItsNotRexed#873). A non-zero count with a null array is an invalid call. d3d12_viewport_array_test's second list now draws under a full-screen scissor, sets a count of 0 and draws again: the second draw paints nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Vonsek, thanks: the 0-count case was the
RX 7800 XT, validation on: the test passes, |
|
Rebuilt the updated test at 2de55df on Windows and reran it on the RTX 5080 with Vulkan validation enabled. The 64×64 readback matched the expected image, including the previously failing zero-count case. The bottom half stayed empty after the second draw. On 6d20e48 our fixture painted all 2,048 bottom-half pixels in that case. This confirms the scissor change on this adapter. Zero-count viewport behavior remains unmeasured here. AI-assisted verification. |
|
I measured the other half natively: a standalone D3D12 program (no Leonida code), 64×64 RGBA8, one full-screen triangle per case. The numbers are painted pixels in the top/bottom halves.
Done in
|
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw is dropped only when every viewport is empty. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones; measured on ItsNotRexed#873). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present, which a translated VS writing ViewportIndex or Layer needs. d3d12_viewport_array_test: four instances into four viewports with per-viewport scissors (a VS writing gl_ViewportIndex), then one viewport, a scissor count of 0 and a viewport count of 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c1ceefc to
c0c7b2d
Compare
|
The zero-viewport policy at
PS invocations were zero in the last four conditions on all five paths. In a local single-instance control, removing the all-degenerate early return in A second viewport-array issue occurs with no attachments bound. On both Vulkan GPUs I captured the layer requesting 0×64 at |
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw with no usable viewport is recorded, not dropped: D3D12 rasterizes nothing but still runs its vertex work, which pipeline statistics count (@Vonsek measured it natively on ItsNotRexed#873). With no viewport bound, all 16 indices get the 1x1 viewport. With no attachment bound, the render area covers every viewport instead of viewport 0 alone. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present. d3d12_viewport_array_test (in ctest): four instances into four viewports with per-viewport scissors, one viewport, scissor and viewport counts of 0, pipeline statistics without a viewport, and an occlusion query through viewport 1 with no attachment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Vonsek, thanks: both findings were right. Fixed in
AI-assisted. |
c0c7b2d to
aeb2482
Compare
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw with no usable viewport is recorded, not dropped: D3D12 rasterizes nothing but still runs its vertex work, which pipeline statistics count (@Vonsek measured it natively on ItsNotRexed#873). With no viewport bound, all 16 indices get the 1x1 viewport. With no attachment bound, the render area covers every viewport instead of viewport 0 alone. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present. d3d12_viewport_array_test (in ctest): four instances into four viewports with per-viewport scissors, one viewport, scissor and viewport counts of 0, pipeline statistics without a viewport, and an occlusion query through viewport 1 with no attachment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aeb2482 to
1d64d1d
Compare
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw with no usable viewport is recorded, not dropped: D3D12 rasterizes nothing but still runs its vertex work, which pipeline statistics count (@Vonsek measured it natively on ItsNotRexed#873). With no viewport bound, all 16 indices get the 1x1 viewport. With no attachment bound, the render area covers every viewport instead of viewport 0 alone. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present. d3d12_viewport_array_test (in ctest): four instances into four viewports with per-viewport scissors, one viewport, scissor and viewport counts of 0, pipeline statistics without a viewport, and an occlusion query through viewport 1 with no attachment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1d64d1d to
cc09a86
Compare
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw with no usable viewport is recorded, not dropped: D3D12 rasterizes nothing but still runs its vertex work, which pipeline statistics count (@Vonsek measured it natively on ItsNotRexed#873). With no viewport bound, all 16 indices get the 1x1 viewport. With no attachment bound, the render area covers every viewport instead of viewport 0 alone. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present. d3d12_viewport_array_test (in ctest): four instances into four viewports with per-viewport scissors, one viewport, scissor and viewport counts of 0, pipeline statistics without a viewport, and an occlusion query through viewport 1 with no attachment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cc09a86 to
e765c22
Compare
|
Rebased onto |
|
Tested e765c22 on NVIDIA GeForce RTX 5090, driver 621.24, Windows 11 build 26300: pass
Synthetic inputs only. AI-assisted. |
|
RTX 5070, Windows, driver 616.56, Vulkan validation enabled. Parent 4947579 and PR e765c22 both built, created the graphics PSO and completed fence-backed readbacks. Pixel mismatches on the 64�64 images:
First parent differences were (32,0), green instead of blue, and (0,32), red instead of green. With a valid viewport both returned 6 IA vertices, 2 primitives, 4 VS invocations and 4096 PS invocations. With no viewport the parent returned 0/0/0/0 and the PR returned 6/2/4/0. The PR also returned 1024 occlusion samples through viewport 1 without an attachment, rejected 17 viewports and passed with zero validation errors. The parent has no registered fixture. I copied the PR fixture, shader, test device and CMake registration to an isolated parent checkout and omitted the unavailable feature-field assignment. The first parent run stopped at the zero-viewport query assertion. A second parent diagnostic omitted the query and argument checks to count both image mismatches in full. Parent runtime sources were unchanged. Targeted synthetic test only, AI-assisted. |
|
Tested e765c22 (on
AI-assisted (Claude Code). |
|
Windows + GPU check: AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release, Vulkan SDK 1.4.363. Tested head e765c22 merged onto AI-assisted (Claude Code); runs on my machine. |
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw with no usable viewport is recorded, not dropped: D3D12 rasterizes nothing but still runs its vertex work, which pipeline statistics count (@Vonsek measured it natively on ItsNotRexed#873). With no viewport bound, all 16 indices get the 1x1 viewport. With no attachment bound, the render area covers every viewport instead of viewport 0 alone. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present. d3d12_viewport_array_test (in ctest): four instances into four viewports with per-viewport scissors, one viewport, scissor and viewport counts of 0, pipeline statistics without a viewport, and an occlusion query through viewport 1 with no attachment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e765c22 to
67621d1
Compare
|
@kacper-serewis, @Dom-in, thanks for the RTX 5070 and RX 9070 runs. Rebased onto |
|
Tested 67621d1 on Windows 11 (26200), MSVC 19.4x (VS 2022 Build Tools), Ninja RelWithDebInfo: pass on both GPUs of a two-GPU PC.
No game files. AI-assisted check (Claude Code), Vonsek3. |
|
Tested 67621d1 under Wine 11.21 (Fedora 45) on AMD Radeon 610M (RDNA2 iGPU, RADV Mesa 26.2.6) and NVIDIA RTX 4070 Ti (615.78.08): pass These are the first Linux and AMD results. The Windows runtime was cross-built with clang-cl 23.1.5 and xwin (MSVC 14.44, SDK 10.0.26100), and its ctest suite was run under Wine and Xvfb, one GPU at a time with
Not run, because they fail in this environment on every commit:
AI-assisted (Claude Code); numbers copied from the run logs. |
The list keeps up to 16 viewports and scissor rectangles (more, or a non-zero count with a null array, is an invalid call) and every draw carries them. With multiViewport on the device, pipelines use VIEWPORT_WITH_COUNT / SCISSOR_WITH_COUNT and each draw sets all of them, with an empty scissor for a viewport the list gave none (D3D12's default rectangle) and a 1x1 viewport under an empty scissor for an entry with no area. A draw with no usable viewport is recorded, not dropped: D3D12 rasterizes nothing but still runs its vertex work, which pipeline statistics count (@Vonsek measured it natively on ItsNotRexed#873). With no viewport bound, all 16 indices get the 1x1 viewport. With no attachment bound, the render area covers every viewport instead of viewport 0 alone. RSSetScissorRects(0, ...) leaves no rectangle set, as on WARP and NVIDIA's D3D12 driver (AMD's keeps the old ones). RSSetViewports(0) unbinds the viewports, which the RX 7800 XT, a Radeon iGPU and WARP agree on. The standalone and test devices enable multiViewport, shaderOutputViewportIndex and shaderOutputLayer where present. d3d12_viewport_array_test (in ctest): four instances into four viewports with per-viewport scissors, one viewport, scissor and viewport counts of 0, pipeline statistics without a viewport, and an occlusion query through viewport 1 with no attachment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67621d1 to
1bc84e6
Compare
|
@ddm-j, thanks for the Wine/RADV run. Rebased onto
Full |
|
Re-tested the rebased head Tested 1bc84e6 on NVIDIA GeForce RTX 5090, driver 621.24, Windows 11 build 26300: pass
Synthetic inputs only. AI-assisted. |
Claimed in #634 (new D3D item: viewport and scissor arrays on #291's draw path).
Based on
main003e7812(#291 has landed); one commit.What and why
RSSetViewportsandRSSetScissorRectskept only their first entry ("more than one viewport; the first is used"). The translator already writesViewportIndex(andLayer) from a VSpos1misc export (docs/design.md, Inputs and outputs). Without this PR, a draw that selects a viewport per primitive (cascaded shadow maps, split-screen passes) lands every primitive in viewport 0, or in no viewport at all.d3d12_com.cpp): the list keeps up toD3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE(16) of each, and every draw carries them. More than 16 is an invalid call (ClosereturnsE_INVALIDARG).viewport/scissorinDrawstay the first entries, so nothing that reads them changes.d3d12_vulkan_device.cpp): withVulkanDeviceInfo::multi_viewport, pipelines declare 0 viewports and useVK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT/SCISSOR_WITH_COUNT(core 1.3).vulkan_replay.h): it sets all viewports, each flipped as before, and as many scissors, since Vulkan requires the counts to match (VUID-vkCmdDraw-viewportCount-03419). A viewport whose scissor the list never set gets an empty rectangle, D3D12's default, so it draws nothing. One viewport goes through the same with-count call.vk_test_device.henablemultiViewport,shaderOutputViewportIndexandshaderOutputLayerwhere present. A translated VS that writesViewportIndexorLayerneeds the last two whatever the viewport count. Without them nothing changes: viewport and scissor 0 apply.docs/d3d12_vulkan.md, and the command-list table row.Tested
AMD Radeon RX 7800 XT (RDNA3), driver 32.0.32015.7029, Windows 11 Pro (26300), MSVC 14.44.35207, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, Ninja RelWithDebInfo,
LEONIDA_VK_VALIDATION=1:d3d12_viewport_array_test(new, GPU):test/glsl/vs_viewports.vertwritesgl_ViewportIndex = gl_InstanceIndex. One draw of a full-screen quad with 4 instances, 4 viewports (one per quadrant of 64×64) and 3 scissors. All 4,096 pixels match, with 0 validation errors:A second list with one full-screen viewport fills every pixel. 17 viewports give
E_INVALIDARGatClose.Negative control: with the replay applying only the first viewport, the test fails at pixel (32, 0).
Regression:
ctest15/15.d3d12_draw_test,d3d12_compute_testandd3d12_present_testpass with 0 validation errors.Checklist
docs/design.md, with how it was confirmed. (N/A: runtime only. The translator already emitsViewportIndex.)AI-assisted (Claude Code).
🤖 Generated with Claude Code