startup: sanitize viewports and scissors and draw with no DSV format when no depth view is bound #3197

Open
github-bot wants to merge 4 commits from github-bot/gh-3195 into main AGit
Owner

@⁠tedin7 on GitHub · 2026-11-27 21:25 UTC · original
tedin7:up-viewport-check → main · +277 −7 · 8 files · 4 commits · open

Part of #870

What this unblocks: title draws whose viewport, scissor or missing depth view made the D3D12 debug layer report errors on desktop GPUs now reach the GPU as valid state.

The device shim forwarded title RSSetViewports / RSSetScissorRects as they came, and a translated draw took its DSVFormat from the pipeline even when the pass bound no depth view. D3D12 requires viewport depth in [0, 1], origin and extent inside D3D12_VIEWPORT_BOUNDS_MIN/MAX and no negative size ("D3D12_VIEWPORT structure"), scissor rectangles with right >= left and bottom >= top ("ID3D12GraphicsCommandList::RSSetScissorRects"), and a PSO DSVFormat that matches the bound depth view ("D3D12_GRAPHICS_PIPELINE_STATE_DESC", DSVFormat).

  • src/startup_stubs/viewport_check.h: sanitize_viewport (NaN and out-of-range depth clamped to [0, 1], an inverted depth range is kept, origin clamped to the bounds, NaN/negative size -> 0, extent trimmed to the bound) and sanitize_scissor (an inverted rectangle becomes an empty one at its left/top edge).
  • List slots 21 / 22 sanitize a copy of the title array before forwarding; the first repairs are logged.
  • pass_dsv_format uses only the depth view bound to the pass, so a pipeline created with a depth format draws with DSVFormat UNKNOWN and no depth-stencil state when no depth view is bound.

Tests:

  • startup_viewport (CPU rules: valid values untouched, NaN/inf/out-of-range repaired, DSV format and depth-state choice).
  • startup_viewport_device_warp / _hardware (debug layer on a shim list: an out-of-range depth range, a negative width and an inverted scissor give no debug-layer error and no device removal; on main these calls are forwarded as they came).
  • startup_slot57_depth_warp / _hardware: new case stream_no_dsv (a stream pipeline created with a depth format, drawn with no depth view bound: picture still read back green, no debug-layer error, no device removal).

Verification:

  • cmake -S . -B /tmp/up-viewport-check-cfg -G Ninja -DDXC_EXECUTABLE=/bin/true -> configure OK
  • python3 -m py_compile tests/startup_slot57_depth_check.py -> OK
  • x86_64-w64-mingw32-g++-posix -std=c++20 -fsyntax-only -Isrc tests/startup_viewport_check.cpp -> OK
  • x86_64-w64-mingw32-g++-posix -std=c++20 -fsyntax-only -Isrc tests/startup_viewport_device.cpp -> OK
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at 5c157e4866947f1962e366594f213a61f9d88c33:
    • dev: cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_slot57_depth startup_viewport startup_viewport_device startup_draw_depth_target startup_stream_depth, then ctest --preset dev -R '^(startup_viewport|startup_slot57_depth_|startup_draw_depth_target|startup_stream_depth_)' --no-tests=error -> 13/13 passed
    • release /O2: same targets and regex -> 13/13 passed
    • same head with the d3d12_xs_device.cpp / d3d12_draw.inl changes reverted (tests kept), dev, -R '^(startup_viewport|startup_slot57_depth_)' -> 4 of 5 failed as expected: startup_viewport_device_warp / _hardware and startup_slot57_depth_warp / _hardware (debug layer: "The depth stencil format does not match that specified by the current pipeline state"); the CPU test startup_viewport passes either way.

Draft until an independent peer review and the Win2025 WARP gate pass.

Thanks to @⁠Makto94 for the testing that found this.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 21:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195) `tedin7:up-viewport-check` → `main` · +277 −7 · 8 files · 4 commits · open Part of #870 What this unblocks: title draws whose viewport, scissor or missing depth view made the D3D12 debug layer report errors on desktop GPUs now reach the GPU as valid state. The device shim forwarded title `RSSetViewports` / `RSSetScissorRects` as they came, and a translated draw took its `DSVFormat` from the pipeline even when the pass bound no depth view. D3D12 requires viewport depth in [0, 1], origin and extent inside `D3D12_VIEWPORT_BOUNDS_MIN/MAX` and no negative size ("D3D12_VIEWPORT structure"), scissor rectangles with right >= left and bottom >= top ("ID3D12GraphicsCommandList::RSSetScissorRects"), and a PSO `DSVFormat` that matches the bound depth view ("D3D12_GRAPHICS_PIPELINE_STATE_DESC", DSVFormat). - `src/startup_stubs/viewport_check.h`: `sanitize_viewport` (NaN and out-of-range depth clamped to [0, 1], an inverted depth range is kept, origin clamped to the bounds, NaN/negative size -> 0, extent trimmed to the bound) and `sanitize_scissor` (an inverted rectangle becomes an empty one at its left/top edge). - List slots 21 / 22 sanitize a copy of the title array before forwarding; the first repairs are logged. - `pass_dsv_format` uses only the depth view bound to the pass, so a pipeline created with a depth format draws with `DSVFormat` UNKNOWN and no depth-stencil state when no depth view is bound. Tests: - `startup_viewport` (CPU rules: valid values untouched, NaN/inf/out-of-range repaired, DSV format and depth-state choice). - `startup_viewport_device_warp` / `_hardware` (debug layer on a shim list: an out-of-range depth range, a negative width and an inverted scissor give no debug-layer error and no device removal; on main these calls are forwarded as they came). - `startup_slot57_depth_warp` / `_hardware`: new case `stream_no_dsv` (a stream pipeline created with a depth format, drawn with no depth view bound: picture still read back green, no debug-layer error, no device removal). Verification: - `cmake -S . -B /tmp/up-viewport-check-cfg -G Ninja -DDXC_EXECUTABLE=/bin/true` -> configure OK - `python3 -m py_compile tests/startup_slot57_depth_check.py` -> OK - `x86_64-w64-mingw32-g++-posix -std=c++20 -fsyntax-only -Isrc tests/startup_viewport_check.cpp` -> OK - `x86_64-w64-mingw32-g++-posix -std=c++20 -fsyntax-only -Isrc tests/startup_viewport_device.cpp` -> OK - Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at `5c157e4866947f1962e366594f213a61f9d88c33`: - dev: `cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_slot57_depth startup_viewport startup_viewport_device startup_draw_depth_target startup_stream_depth`, then `ctest --preset dev -R '^(startup_viewport|startup_slot57_depth_|startup_draw_depth_target|startup_stream_depth_)' --no-tests=error` -> 13/13 passed - release `/O2`: same targets and regex -> 13/13 passed - same head with the `d3d12_xs_device.cpp` / `d3d12_draw.inl` changes reverted (tests kept), dev, `-R '^(startup_viewport|startup_slot57_depth_)'` -> 4 of 5 failed as expected: `startup_viewport_device_warp` / `_hardware` and `startup_slot57_depth_warp` / `_hardware` (debug layer: "The depth stencil format does not match that specified by the current pipeline state"); the CPU test `startup_viewport` passes either way. Draft until an independent peer review and the Win2025 WARP gate pass. Thanks to @⁠Makto94 for the testing that found this. AI-assisted; commands listed were executed locally.
RSSetViewports clamps depth to [0, 1], keeps origin and extent inside the viewport bounds and drops negative or NaN sizes; RSSetScissorRects turns an inverted rectangle into an empty one. A translated draw takes its DSVFormat only from the depth view bound to the pass, so a pipeline created with a depth format draws with DSVFormat UNKNOWN (and no depth state) when no depth view is bound.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:30:15 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-27 23:52 UTC · original

Review of 5c157e48 (single commit):

**@⁠KelboLive** on GitHub · 2026-11-27 23:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7230476582) Review of `5c157e48` (single commit):
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 10:49 UTC · original

Real-GPU verification (NVIDIA RTX 3070 Ti, driver 32.0.16.2101, Windows 11):

Tested at 5c157e4 (current head). dev preset, ctest run one test at a time:

  • ctest on the touched block: 100% tests passed, 0 tests failed out of 13.
  • Mutant patch applied: 69% passed, 4 of 13 failed, exactly the expected ones: startup_viewport_device_warp, startup_viewport_device_hardware, startup_slot57_depth_warp, startup_slot57_depth_hardware.

These complement the existing WARP runs.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 10:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7238143199) Real-GPU verification (NVIDIA RTX 3070 Ti, driver 32.0.16.2101, Windows 11): Tested at 5c157e4 (current head). dev preset, ctest run one test at a time: - ctest on the touched block: 100% tests passed, 0 tests failed out of 13. - Mutant patch applied: 69% passed, 4 of 13 failed, exactly the expected ones: startup_viewport_device_warp, startup_viewport_device_hardware, startup_slot57_depth_warp, startup_slot57_depth_hardware. These complement the existing WARP runs. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-28 10:49 UTC · original · edited 2026-11-28 10:52 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T10:52:10.816742Z 5c157e4 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-28 10:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7238145412) · edited 2026-11-28 10:52 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5c157e4866947f1962e366594f213a61f9d88c33","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-28T10:52:10.816742Z">2026-11-28T10:52:10.816742Z</relative-time> | `5c157e4` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 22:07 UTC · original

Merged current main into this branch (merge commit, no force push, no conflicts); head is now 9fb65760b. No change to the PR's own files.

Verification (Windows Server 2025, D3D12 WARP, head 9fb65760b): x2w_pipe.py win2025 3195 --regex '^startup_viewport' -> 3/3 passed (startup_viewport and the device tests).

@⁠MasterDomino ready for review and merge when you have time. KelboLive's review of 5c157e48 has no open asks.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 22:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7246518413) Merged current `main` into this branch (merge commit, no force push, no conflicts); head is now `9fb65760b`. No change to the PR's own files. Verification (Windows Server 2025, D3D12 WARP, head `9fb65760b`): `x2w_pipe.py win2025 3195 --regex '^startup_viewport'` -> 3/3 passed (`startup_viewport` and the device tests). @⁠MasterDomino ready for review and merge when you have time. KelboLive's review of `5c157e48` has no open asks. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠pigalot on GitHub · 2026-11-29 08:05 UTC · original · requested changes

Independently reviewed 9fb65760 integrated over main 212d4b5f (tree ce819832). The trial merge is clean and git diff --check is clean.

Requesting changes for one thing: the viewport half of this PR has no test that fails without it.

1. startup_viewport_device passes when the viewports are forwarded unsanitized (blocking).

Mutant: in list_viewports, change list->RSSetViewports(count, copy.data()); back to list->RSSetViewports(count, viewports); and leave everything else as it is. Then:

cmake --build --preset dev --target d3d12_xs_shim startup_viewport_device
ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^startup_viewport_device_(warp|hardware)$'

Both pass, on WARP and on the RTX 5090, with debug errors=0 removed=0x00000000. startup_viewport and startup_slot57_depth_warp pass too, so no test in the PR notices that the title's {0, 0, 4, 4, -0.5, 1.5} and {0, 0, -4, 4, 0, 1} viewports reach the list as they came. Expected: a test that fails.

So here the debug layer reports nothing for an out-of-range depth range or a negative width at RSSetViewports, Close or ExecuteCommandLists when no draw follows. The body's control ("with the d3d12_xs_device.cpp changes reverted ... startup_viewport_device_* failed") holds only because of the scissor: with only the scissor forwarding reverted, the test fails with "RSSetScissorRects: In the scissor rect, bottom (4) is less than top (0) or right (2) is less than left (10)". That also means the body's premise for the viewport part (a viewport that makes the debug layer report errors) is not shown by anything in the PR.

Suggested direction (unconfirmed): follow the viewport call with a draw in the fixture, if the debug layer validates viewports at draw time, and show the message it gives on main; or have the test check the shim's own x2w-d3d12 RSSetViewports: repaired invalid viewport line, which at least pins the wiring. If no debug-layer message can be produced for these values, please say in the body what the viewport sanitizing is based on instead.

What I traced. pass.bound_depth and pass.dsv_format are set together, only in list_targets, and both are reset at its top, so draw_dsv_format(pass.bound_depth != nullptr, ...) differs from the old expression only when no depth view is bound: the stream format is no longer used, and with it use_depth_stencil is off for a stream pipeline drawn with no depth view. view_format_of falls back to the resource format, so a bound view never gives UNKNOWN. sanitize_viewport keeps an inverted depth range, clamps NaN depth to 0 / 1, and trims the extent in double before narrowing; count <= 16 bounds the std::array copies.

Tests. Built d3d12_xs_shim startup_slot57_depth startup_viewport startup_viewport_device startup_draw_depth_target startup_stream_depth in dev and release, then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_viewport|startup_viewport_device_warp|startup_slot57_depth_warp|startup_draw_depth_target.*_warp|startup_stream_depth_warp)$' and the _hardware variants (-j 1): 7/7 WARP and 6/6 hardware passed in Debug and in Release /O2, no skips.

Mutants (dev; startup_viewport, startup_viewport_device_warp, startup_slot57_depth_warp):

Killed:

  • forward the title's scissors: startup_viewport_device_warp fails (message above).
  • old pass_dsv_format (fall back to the stream format): startup_slot57_depth_warp fails, fixture exit 70 in stream_no_dsv. This is the negative control for the DSV half and it works.
  • draw_depth_state_enabled returns has_state: startup_viewport and startup_slot57_depth_warp fail.
  • old use_depth_stencil expression in pipeline_for: startup_slot57_depth_warp fails.
  • in viewport_check.h, each killed by startup_viewport only: no MinDepth clamp, no MaxDepth clamp, no TopLeftX clamp, negative size kept, no extent trim, no bottom < top repair.

Surviving:

  • forward the title's viewports (finding 1).
  • remove the std::nextafter line in extent: no test input reaches it (an origin such as 0.0005f with a width past the bound would).

Equivalent: none.

Non-blocking notes.

  • startup_slot57_depth now returns 20 ("no debug layer") when ID3D12InfoQueue1 or the callback registration is unavailable, and startup_viewport_device returns 4. Before this PR startup_slot57_depth_* did not need the debug layer in the fixture. startup_draw_depth_target_debug_* reports a skip (77) in that case; the same here would keep the other 13 cases usable on a machine without the debug layer. I did not run without the debug layer; this is from reading the code.
  • BoundPipeline::dsv_format is still filled from the stream (d3d12_draw.inl:1120) but nothing reads it now; the third parameter of draw_dsv_format is unnamed and unused.
  • The PR carries two behaviours (viewport / scissor sanitizing, and the DSV format choice). The DSV half is independent and well covered; splitting it out would let it go in on its own.

Title run of this head (merged onto the baseline commit): pass, judged no worse than the baseline.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and Microsoft Basic Render Driver (WARP); debug layer on.
CI: Build and test on Windows passed on 9fb65760.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-29 08:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#pullrequestreview-6102014480) · **requested changes** Independently reviewed `9fb65760` integrated over `main` `212d4b5f` (tree `ce819832`). The trial merge is clean and `git diff --check` is clean. Requesting changes for one thing: the viewport half of this PR has no test that fails without it. **1. `startup_viewport_device` passes when the viewports are forwarded unsanitized (blocking).** Mutant: in `list_viewports`, change `list->RSSetViewports(count, copy.data());` back to `list->RSSetViewports(count, viewports);` and leave everything else as it is. Then: ``` cmake --build --preset dev --target d3d12_xs_shim startup_viewport_device ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^startup_viewport_device_(warp|hardware)$' ``` Both pass, on WARP and on the RTX 5090, with `debug errors=0 removed=0x00000000`. `startup_viewport` and `startup_slot57_depth_warp` pass too, so no test in the PR notices that the title's `{0, 0, 4, 4, -0.5, 1.5}` and `{0, 0, -4, 4, 0, 1}` viewports reach the list as they came. Expected: a test that fails. So here the debug layer reports nothing for an out-of-range depth range or a negative width at `RSSetViewports`, `Close` or `ExecuteCommandLists` when no draw follows. The body's control ("with the `d3d12_xs_device.cpp` changes reverted ... `startup_viewport_device_*` failed") holds only because of the scissor: with only the scissor forwarding reverted, the test fails with "RSSetScissorRects: In the scissor rect, bottom (4) is less than top (0) or right (2) is less than left (10)". That also means the body's premise for the viewport part (a viewport that makes the debug layer report errors) is not shown by anything in the PR. Suggested direction (unconfirmed): follow the viewport call with a draw in the fixture, if the debug layer validates viewports at draw time, and show the message it gives on `main`; or have the test check the shim's own `x2w-d3d12 RSSetViewports: repaired invalid viewport` line, which at least pins the wiring. If no debug-layer message can be produced for these values, please say in the body what the viewport sanitizing is based on instead. **What I traced.** `pass.bound_depth` and `pass.dsv_format` are set together, only in `list_targets`, and both are reset at its top, so `draw_dsv_format(pass.bound_depth != nullptr, ...)` differs from the old expression only when no depth view is bound: the stream format is no longer used, and with it `use_depth_stencil` is off for a stream pipeline drawn with no depth view. `view_format_of` falls back to the resource format, so a bound view never gives UNKNOWN. `sanitize_viewport` keeps an inverted depth range, clamps NaN depth to 0 / 1, and trims the extent in double before narrowing; `count <= 16` bounds the `std::array` copies. **Tests.** Built `d3d12_xs_shim startup_slot57_depth startup_viewport startup_viewport_device startup_draw_depth_target startup_stream_depth` in `dev` and `release`, then ran `ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_viewport|startup_viewport_device_warp|startup_slot57_depth_warp|startup_draw_depth_target.*_warp|startup_stream_depth_warp)$'` and the `_hardware` variants (`-j 1`): 7/7 WARP and 6/6 hardware passed in Debug and in Release `/O2`, no skips. **Mutants** (dev; `startup_viewport`, `startup_viewport_device_warp`, `startup_slot57_depth_warp`): Killed: - forward the title's scissors: `startup_viewport_device_warp` fails (message above). - old `pass_dsv_format` (fall back to the stream format): `startup_slot57_depth_warp` fails, fixture exit 70 in `stream_no_dsv`. This is the negative control for the DSV half and it works. - `draw_depth_state_enabled` returns `has_state`: `startup_viewport` and `startup_slot57_depth_warp` fail. - old `use_depth_stencil` expression in `pipeline_for`: `startup_slot57_depth_warp` fails. - in `viewport_check.h`, each killed by `startup_viewport` only: no `MinDepth` clamp, no `MaxDepth` clamp, no `TopLeftX` clamp, negative size kept, no extent trim, no `bottom < top` repair. Surviving: - forward the title's viewports (finding 1). - remove the `std::nextafter` line in `extent`: no test input reaches it (an origin such as `0.0005f` with a width past the bound would). Equivalent: none. **Non-blocking notes.** - `startup_slot57_depth` now returns 20 ("no debug layer") when `ID3D12InfoQueue1` or the callback registration is unavailable, and `startup_viewport_device` returns 4. Before this PR `startup_slot57_depth_*` did not need the debug layer in the fixture. `startup_draw_depth_target_debug_*` reports a skip (77) in that case; the same here would keep the other 13 cases usable on a machine without the debug layer. I did not run without the debug layer; this is from reading the code. - `BoundPipeline::dsv_format` is still filled from the stream (`d3d12_draw.inl:1120`) but nothing reads it now; the third parameter of `draw_dsv_format` is unnamed and unused. - The PR carries two behaviours (viewport / scissor sanitizing, and the DSV format choice). The DSV half is independent and well covered; splitting it out would let it go in on its own. Title run of this head (merged onto the baseline commit): pass, judged no worse than the baseline. Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and Microsoft Basic Render Driver (WARP); debug layer on. CI: `Build and test on Windows` passed on `9fb65760`. This reply was AI-assisted.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 13:05 UTC · original

Review of head 9fb65760 against main 94b679e7. I read the source and ran trial merges only; I did not build or run anything. git merge-tree --write-tree origin/main 9fb65760 exits 0.

On the default launcher path, both halves are on with no switch. I traced the DSV half in the merged tree. pass_dsv_format has two callers, pipeline_for and the scoped stencil-ref check (pass_dsv_format(*bound, pass) != DXGI_FORMAT_UNKNOWN). Both now see UNKNOWN only when no depth view is bound. The other two PSO sites, draw_missing_translation and draw_pipeline_colour, already used pass.dsv_format directly. So the DSV change only affects draws where depth state had no target, and stream_no_dsv shows the picture is the same. That half looks right to me.

Status: pigalot's change request on this head (finding 1: the viewport half has no test that fails without it) is still open, with no push or reply since. That holds the merge, so I am not merging. I have nothing to add to that finding.

SHOULD

  1. The repair log lines carry no values. log("x2w-d3d12 RSSetViewports: repaired invalid viewport") and log("x2w-d3d12 RSSetScissorRects: repaired invalid scissor") are the only trace that a title viewport or scissor was changed on the default path. The values are what show whether the input was garbage or meant something. One example: a negative Height used as a Y flip becomes a zero-size viewport here, so the draw disappears. Could you print the six input floats and the repaired ones (and the four LONGs for a scissor) in those first 6 lines? A fixture for finding 1 could then also check the line.

NIT

  1. CI on a pull request runs ctest --preset pr. Its include list matches none of startup_viewport, startup_viewport_device_* or startup_slot57_depth_* (checked against CMakePresets.json on main). So the green Windows check on 9fb65760 did not run this PR's tests. The runs that cover them are pigalot's and the Win2025 ones in the thread. A line in the body saying so would save the next reviewer the same check.

Trial merges onto main plus one other PR from this group: this PR merges cleanly with #3201 and with #3202 in either order.

AI-assisted.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 13:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7256276409) Review of head `9fb65760` against `main` `94b679e7`. I read the source and ran trial merges only; I did not build or run anything. `git merge-tree --write-tree origin/main 9fb65760` exits 0. On the default launcher path, both halves are on with no switch. I traced the DSV half in the merged tree. `pass_dsv_format` has two callers, `pipeline_for` and the scoped stencil-ref check (`pass_dsv_format(*bound, pass) != DXGI_FORMAT_UNKNOWN`). Both now see `UNKNOWN` only when no depth view is bound. The other two PSO sites, `draw_missing_translation` and `draw_pipeline_colour`, already used `pass.dsv_format` directly. So the DSV change only affects draws where depth state had no target, and `stream_no_dsv` shows the picture is the same. That half looks right to me. Status: pigalot's change request on this head (finding 1: the viewport half has no test that fails without it) is still open, with no push or reply since. That holds the merge, so I am not merging. I have nothing to add to that finding. **SHOULD** 1. **The repair log lines carry no values.** `log("x2w-d3d12 RSSetViewports: repaired invalid viewport")` and `log("x2w-d3d12 RSSetScissorRects: repaired invalid scissor")` are the only trace that a title viewport or scissor was changed on the default path. The values are what show whether the input was garbage or meant something. One example: a negative `Height` used as a Y flip becomes a zero-size viewport here, so the draw disappears. Could you print the six input floats and the repaired ones (and the four `LONG`s for a scissor) in those first 6 lines? A fixture for finding 1 could then also check the line. **NIT** 2. CI on a pull request runs `ctest --preset pr`. Its include list matches none of `startup_viewport`, `startup_viewport_device_*` or `startup_slot57_depth_*` (checked against `CMakePresets.json` on `main`). So the green Windows check on `9fb65760` did not run this PR's tests. The runs that cover them are pigalot's and the Win2025 ones in the thread. A line in the body saying so would save the next reviewer the same check. Trial merges onto `main` plus one other PR from this group: this PR merges cleanly with #3201 and with #3202 in either order. AI-assisted.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-30 13:59 UTC · original

Merged current main (077bff3ac) to resolve conflicts and logged viewport/scissor repair values.

**@⁠tedin7** on GitHub · 2026-11-30 13:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7280656073) Merged current `main` (`077bff3ac`) to resolve conflicts and logged viewport/scissor repair values.
Author
Owner

@⁠JB2WIN on GitHub · 2026-12-02 20:09 UTC · original · edited 2026-12-02 20:46 UTC

Full application run for this PR, on a local retail package. No game files or captures leave this machine. Both builds are release builds launched with tools/startup/run_preset.py --console x --gpu nvidia on an RTX 3080 / Windows 11 and stopped after 900 s:

main 46d465d9 main 46d465d9 + this PR (4a4e420c)
exit stopped at 907 s, no crash stopped at 907 s, no crash
frames presented / fps 26,519 / 29.4 26,777 / 29.8
translated draws (not drawn) 301,005 (4,196) 317,268 (0)
RSSetViewports / RSSetScissorRects repairs logged – 0
desktop pipelines with a DSV format 1 1

No regression. The repair log lines never fired in this window, so this run does not exercise the sanitizer. The 4,196 undrawn draws on main were cache warm-up, not a difference between the builds. Two pipelines were translated (ok) during that run and refused as manifest_absent until their translation was published, after which they drew. The PR worktree already had both in its translation cache from an earlier, aborted run. The fps and draw-count differences are therefore not evidence for or against this change either.

AI-assisted.

**@⁠JB2WIN** on GitHub · 2026-12-02 20:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#issuecomment-7357301951) · edited 2026-12-02 20:46 UTC Full application run for this PR, on a local retail package. No game files or captures leave this machine. Both builds are release builds launched with `tools/startup/run_preset.py --console x --gpu nvidia` on an RTX 3080 / Windows 11 and stopped after 900 s: | | `main` 46d465d9 | `main` 46d465d9 + this PR (4a4e420c) | |---|---|---| | exit | stopped at 907 s, no crash | stopped at 907 s, no crash | | frames presented / fps | 26,519 / 29.4 | 26,777 / 29.8 | | translated draws (not drawn) | 301,005 (4,196) | 317,268 (0) | | `RSSetViewports` / `RSSetScissorRects` repairs logged | – | 0 | | desktop pipelines with a DSV format | 1 | 1 | No regression. The repair log lines never fired in this window, so this run does not exercise the sanitizer. The 4,196 undrawn draws on `main` were cache warm-up, not a difference between the builds. Two pipelines were translated (`ok`) during that run and refused as `manifest_absent` until their translation was published, after which they drew. The PR worktree already had both in its translation cache from an earlier, aborted run. The fps and draw-count differences are therefore not evidence for or against this change either. AI-assisted.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 20:33 UTC · original · reviewed

I reproduced pigalot's viewport-only control on 4a4e420c. MSVC Debug baseline passed 5/5 (startup_viewport, both startup_viewport_device cases and both startup_slot57_depth cases) on Windows 11 build 26300 with WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. The device fixture had the D3D12 debug layer enabled. Replacing only list->RSSetViewports(count, copy.data()); with list->RSSetViewports(count, viewports); still passed both device cases with debug errors=0 removed=0x00000000. Disabling both sanitizers failed both cases with the inverted-scissor diagnostic (D3D12 message 1338). The current fixture clears the render target, so its observable result is independent of the forwarded viewport. Please add a draw with a known viewport-sensitive pixel or depth readback, and show that the one-line forwarding control fails on both adapters.

**@⁠R0Y00** on GitHub · 2026-12-02 20:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3195#pullrequestreview-6158479249) · **reviewed** I reproduced pigalot's viewport-only control on `4a4e420c`. MSVC Debug baseline passed 5/5 (`startup_viewport`, both `startup_viewport_device` cases and both `startup_slot57_depth` cases) on Windows 11 build 26300 with WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. The device fixture had the D3D12 debug layer enabled. Replacing only `list->RSSetViewports(count, copy.data());` with `list->RSSetViewports(count, viewports);` still passed both device cases with `debug errors=0 removed=0x00000000`. Disabling both sanitizers failed both cases with the inverted-scissor diagnostic (D3D12 message 1338). The current fixture clears the render target, so its observable result is independent of the forwarded viewport. Please add a draw with a known viewport-sensitive pixel or depth readback, and show that the one-line forwarding control fails on both adapters.
This pull request has changes conflicting with the target branch.
  • src/startup_stubs/d3d12_xs_device.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3197/head:github-bot/gh-3195'
git switch 'github-bot/gh-3195'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3195'
git switch 'github-bot/gh-3195'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3195'
git switch 'github-bot/gh-3195'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3195'
git switch 'main'
git merge --squash 'github-bot/gh-3195'
git switch 'main'
git merge --ff-only 'github-bot/gh-3195'
git switch 'main'
git merge 'github-bot/gh-3195'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.