fix: default viewport and scissor for translated draws #1650
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1657"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:31:48Z.
What
A command list that never calls RSSetViewports (list slot 21) or RSSetScissorRects (slot 22) draws no pixel on desktop D3D12, yet every translated draw is counted as drawn. Pass now remembers whether the title set each one. A translated draw with no viewport covers the first render target (width, height, depth 0 to 1); with no scissor it gets the same rectangle. A viewport or scissor the title set is never replaced.
Tests
New
startup_stream_viewport_warpandstartup_stream_viewport_hardwarereuse thestartup_stream_consumerfixture (mode chosen by X2W_TEST_VIEWPORT) on an 8x4 target cleared to blue, red pixel shader:Failure message names the first wrong pixel. A mutation that disables the default fails
noneat pixel (0, 0); one that overrides the title's rectangle failsrectat pixel (2, 1); one that keeps the flags across Reset failsresetat pixel (0, 0). The disable-default-viewport mutation was run on Windows 2025 (see Verification).Windows 2025 command:
ctest --preset dev --no-tests=error -R '^startup_stream_viewport_(warp|hardware)$' -VRun locally
x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-onlyon tests/startup_stream_setup.cpp and tests/startup_stream_draw.cpp: clean.Verification (Windows Server 2025, build 26100, MSVC 14.44, D3D12 WARP)
At
22989d61(same tree as50aaa702):x2w_pipe.py preflight /root/wt/x2w-frontier-p04-viewport: no FAIL. It flagged the identifiersmall(Windows SDK macro) in tests/startup_stream_setup.cpp; renamed toinsetin50aaa702.x2w_pipe.py win2025 1657 --regex '^(startup_stream_viewport_warp|startup_stream_draw_warp|startup_stubs|d3d12x_graphics_list_warp|startup_cb_blend_warp|stream_root_srv_warp)$' --force:--preset dev): 6/6 passed./O2(--preset release): 6/6 passed.if (false && !pass.viewport_set)),startup_stream_viewport_warpfailed on Windows 2025:none: pixel (0, 0) is 0000ffff, expected ff0000ff. The mutation commit was reverted (1f24626b,22989d61)._hardwarevariant skips: the node has only WARP.Open PR overlap
git merge-treeagainst the heads of #1441, #1469, #1511, #1549, #1555, #1567, #1641 and #1654: no new conflict. The existing conflicts of #1441 and #1469 (CMakeLists.txt, xg_xs.cpp) and #1549 (docs/experiments.md) already exist against main without this change. #1654 also edits tests/startup_stream_setup.cpp and docs/startup-runtime.md; it merges cleanly.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:50:13Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
22989d61c8ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:00:58Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:45:45Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
22989d6ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:50:14Z.
Code review location:
src/startup_stubs/d3d12_draw.inl; line 1063When a single command-list recording draws to differently sized targets without title viewport/scissor calls, the first fallback sets both
*_setflags.list_targets()subsequently replacespass.target0without clearing those flags, so later draws never recalculate either default. For example, drawing to an 8×4 target and then a 32×16 target leaves the second draw using an 8×4 viewport and scissor, changing its viewport transform and leaving most pixels untouched. Keep title-supplied state distinct from automatically generated state, and refresh only the automatic defaults when the target changes.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:00:58Z.
Code review location:
src/startup_stubs/d3d12_draw.inl; line 1063Fixed in
3e895d2398(logic in07f2464f). The default viewport/scissor no longer sets the title flags. The size of the default already forwarded is tracked separately and regenerated when render target 0 changes. It is cleared on Reset/Close. Newgrowcase instartup_stream_viewportdraws on 8x4 then 16x8 in one list with no slot 21/22 calls. Win2025 Debug and Release /O2 passed: startup_stubs, startup_stream_viewport_warp, startup_stream_draw_warp. Also ran preflight, docs_links_check, bidi_controls_check, git diff --check. AI-assisted; commands listed were executed locally.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T17:16:20Z.
Two ways to overwrite a title-set viewport both survive the fixture
Reviewed
3e895d23. Built at that head, ran the two viewport cases, then mutated the new default ind3d12_draw.inland rebuiltd3d12_xs_shim(the DLL the consumer loads — the timestamp changed each time, and the untouched build passes 2 of 2).Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.
Mutations
if (false))if (true)(always re-issue the default)if (true)Why I am not calling the last two a gap outright
tests/startup_stream_viewport_check.pysays the draw "never replaces one the title set", and therectcase is the one that would show it: a 4x2 viewport at (2,1) has to leave the outside pixels blue. Withif (true)that expectation should break, and it does not — so in this fixture's ordering the title's own slot-21 call must land after whatever the shim does at submission time, and the overwrite is invisible.That leaves two readings I cannot separate from the fixture:
The way to tell them apart is one more case, and it is small: in
grow, draw twice on the first target with the rectangle set once before the first draw, and require red inside the rectangle and blue outside on both. If the second readback is all red, reading 2 is the answer.I would rather flag this than stay quiet, because the branch's own comment says "Only the title's own calls set the flags; an automatic default is regenerated when render target 0 changes size" — the size cache is what makes the two
if (true)mutants indistinguishable, and nothing asserts the cache does its job. Dropping the size comparison entirely (leaving!pass.viewport_set) also survives.What is solid in the change
The swap and the disabled-scissor mutants being caught means the default rectangle is asserted in both extents and both views, and the
resetcase proves the default is not inherited acrossReset.Verdict
Reviewed
3e895d23. The default itself is correct and covered; the "never replaces what the title set" half of the contract is not, on the evidence of two surviving mutants. If you want the extra case I can write it against your branch or as a follow-up withRefs #1657— your call.