Repository navigation
D3D12: apply the implicit viewport scissor with and without render targets - #5939
Stalkerino wants to merge 3 commits into
Conversation
|
Independent Windows review at Windows, NVIDIA GeForce RTX 4070 Ti, NVIDIA driver 610.88, Vulkan SDK/validation 1.4.363. Synthetic fullscreen triangle, single sample, scissor 0..64, precise occlusion queries (supported and enabled):
The native comparison is a separate synthetic D3D12 program: VS emits
|
|
Tested
|
|
@SirKingg, your Windows comparison caught an incorrect expectation in my first revision. I replaced the round-up at Could you re-run the updated |
|
Re-tested the new head
|
Re-ran NVIDIA GeForce RTX 5060 (Blackwell, 8 GB, no Resizable BAR), driver 617.14, Windows 11 26200, MSVC 14.44 (VS 2022 Build Tools), Windows SDK 10.0.26100, Ninja RelWithDebInfo; clean worktree at
What differs from the passing RTX 4080 SUPER run: GPU generation (Blackwell vs Ada), driver (617.14 vs 616.92) and MSVC (14.44 vs 14.51). I haven't found the cause; the only scissor emit is Full AI-assisted check (Claude Code). No game files. |
|
Tested
|
devnull34
left a comment
There was a problem hiding this comment.
Approved based on independent verification of commit b08cb487.
|
@Mayzkl, thank you for checking the new head three times. I made a diagnostic commit for your RTX 5060 on top of git fetch https://github.com/Stalkerino/Leonida.git refs/heads/diagnose/d3d-604-scissor-pixels
git worktree add --detach ..\leonida-d3d604-probe FETCH_HEADUse your usual Windows build settings in that checkout. The first batch runs the same 14 queries as the PR. The trace prints the bound RTV, render area and exact rectangle passed to On my integrated AMD Radeon (RADV, Mesa 26.3.1), both Wine 11.22 and Proton-CachyOS 11.0-20261015 SLR returned 4, 1, 2, 0, 0, 4, 2 for all three query columns and the pixel counts. For viewport 1 the attached trace is |
Hiiva
left a comment
There was a problem hiding this comment.
Bounded follow-up to the conflicting Windows RTV reports, tested at 379d5044575e1c97cac7a99885f22fc85bdc9a76: pass on RTX 4080 with MSVC 19.44.
Windows build 26200, NVIDIA GeForce RTX 4080, driver 32.0.16.1062 (610.62), MSVC 19.44.35228.0, Windows SDK 10.0.26100.0, Vulkan SDK/layer 1.4.363.0. Fresh detached worktree and fresh RelWithDebInfo build of d3d12_draw_test and its COM library, with the Visual Studio 17 2022 generator. No reused binary or production library.
With LEONIDA_VK_DEVICE=4080, explicit Khronos validation, synchronization validation requested, and implicit layers disabled, the unchanged PR fixture exits 0. Viewports 0 through 6 return 4, 1, 2, 0, 0, 4, 2 both without an RTV and with an RTV. All 14 query checks agree with the fixture. There are seven expected unused fragment-output warnings for the attachmentless draws, no VUID or synchronization-hazard diagnostics.
I read the new preparation and emission path. The scissor is recomputed for every prepared draw, before the attachmentless render-area branch, and emission passes that prepared scissor to Vulkan. The local failure did not reproduce, so I did not add instrumentation or change the fixture.
This adds a passing MSVC 19.44/Ada result; it does not resolve or invalidate the reported Blackwell failure. I did not rerun a native D3D12 oracle, the baseline, viewport-array PR integrations, or the full test suite. Synthetic fixture only; no game files. AI-assisted: yes.
|
Tested GPUs: RX 9070 XT (RDNA4, 32.0.32029.2010) and Ryzen 9800X3D iGPU (RDNA2, 32.0.21045).
The negative control (main's
So the explicit floored scissor is needed on RDNA4 too, but only for the sub-pixel case. On this RDNA2 driver the test cannot tell main from the PR; RADV and NVIDIA still catch a regression. Synthetic fixture only, no game files. AI-assisted. |
|
@Stalkerino, sorry, and thanks for the diagnostic: my failure report was wrong; Both of these used new worktrees and new build directories (Ninja, RelWithDebInfo, MSVC 14.44, RTX 5060 / driver 617.14, Windows 11 26200): Fresh build of Your diagnostic commit So Blackwell agrees with Ada, RDNA and WARP. There is no Blackwell difference for the PR to handle. Sorry again for the detour. AI-assisted (Claude Code). No game files. |
|
Tested 379d504 on NVIDIA GeForce RTX 5090, driver 610.88, Windows 11, MSVC RelWithDebInfo, |
shayderrr
left a comment
There was a problem hiding this comment.
Review
Reviewed change in PR #5939: D3D12: apply the implicit viewport scissor with and without render targets.
Scope: runtime/src/vulkan_replay.h, runtime/test/d3d12_draw_test.cpp
Diff: +76 / -8 across 2 file(s).
The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.
Reviewed by shayderrr via automated batch review.
|
Thanks @Stalkerino - I went through D3D12: apply the implicit viewport scissor with and without render targets and the diff around |
Kam471
left a comment
There was a problem hiding this comment.
Reviewed head 379d5044575e1c97cac7a99885f22fc85bdc9a76. Windows 11 26200, MSVC 19.44.35207, Ninja, RelWithDebInfo, Vulkan 1.4.363, RTX 5070 Ti.
d3d12_draw 1/1. Green: viewport cases 0-6 measured without and with an RTV (1: 1/1, 2: 2/2, 3: 0/0, 5: 4/4), and case 6 shows the explicit scissor still applies; the 4096-pixel, strip-cut and MSAA checks still match.
Red baseline (revert runtime/src/vulkan_replay.h only): exit 1. With an RTV: case 1 4 vs 1, case 2 6 vs 2, case 3 1 vs 0, case 5 5 vs 4; without an RTV the old code already matched.
Verdict: ready to merge. This is the missing D3D implicit viewport scissor; it changes only draws with a render target bound, which is exactly the first real frame.
Note: the new check is gated on occlusion_query_precise because it counts fragments with an occlusion query, so that case is skipped on a device without it. Related: #4550 preserves the 16 viewport/scissor slots; this applies the effective one. No conflict.
|
Tested
AI-assisted (Claude Code). |
D3D-604. Claimed in D3D12 coordination.
Depends on: #873, #4550 (overlap only). This applies to the single-viewport path already on main. The array proposals should apply the intersection per viewport/scissor pair when integrating.
Open Windows result on RTX 5060
At
379d5044, the RTX 4080 SUPER passes all 14 sample-count checks. A separate RTX 5060 run consistently fails four of the seven checks with a color target attached. The attachmentless checks pass on both. The cause is still under investigation. A diagnostic branch compares the emitted Vulkan scissor, the occlusion counts and the pixels written by each draw. RTX 4080 SUPER results · RTX 5060 results · Diagnostic and Linux controlsWhat and why
A fractional D3D viewport acts as an implicit scissor in addition to the application's scissor. D3D floors each of the four edges after adding the floating-point origin to the width and height. The floating-point viewport itself still controls the vertex transform. Direct3D functional specification, §15.7
On main, the presence of an RTV changes occlusion coverage. For a 1.75×1.75 viewport on RADV, the same draw produces one sample without an attachment and four with an RTV. At (0.25, 0.25) with dimensions 2.5×1.5 the corresponding counts are two and six. Native NVIDIA D3D12 and WARP agree on one and two in both configurations. My original revision rounded the render area up and its expected counts were wrong. Thanks to SirKingg for measuring both backends and both attachment configurations. Windows reference measurements
The revised replay prepares one Vulkan scissor by intersecting the application's rectangle with the integral viewport bounds. When there are no attachments and the intersection is empty, it uses a legal 1×1 render area and an empty scissor. The draw is still submitted.
Tested
GPU sample counts on CachyOS, Ryzen 7 9800X3D integrated Radeon (RADV RAPHAEL_MENDOCINO, Mesa 26.3.1). Cross-built the synthetic Windows RelWithDebInfo fixture with clang-cl/xwin. Each entry below shows no attachment / 64×64 RTV. Both Wine 11.22 and Proton-CachyOS 11.0-20261015 SLR via umu 1.4.3 produced the revised counts.
The last two controls distinguish flooring the final edge from flooring the width, and verify the explicit scissor still narrows the draw. The comparison on main used the same synthetic queries linked against the unmodified production library, omitting the two cases for which main would request a zero-sized render area. On the revised implementation, all 14 query checks ran,
d3d12_draw_testexited 0 on both runners, andcommand_list_testandd3d12_msaa_draw_testexited 0 under Wine. The host Khronos validation layer under Wine emitted the existing device-creation dependency VUID 01387 and no draw, scissor or render-area VUID in this run.AI-assisted: yes.