D3D12.X: fix console_list::cl_reset initial PSO/rollback, oversized push, and null constants #1467

Open
b3IKK wants to merge 1 commit from upstream-pr/1477 into main
b3IKK commented 2026-11-24 16:41:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T16:41:37Z.


Fixes three safety and correctness bugs in crates/xcl/src/hle/d3d12x/console_list.rs:

  • cl_reset wiped st.chunks, st.arena, st.allocator, and st.uma before calling the PC list's Reset (destroying recording state if PC Reset failed) and never recorded a PIPE_MARKER packet when a non-null initial ConsolePso was passed (causing close() to start with pso = None and silently skip dispatches until a later SetPipelineState).
  • push allocated a fixed CHUNK-byte buffer even when 4 * words.len() exceeded CHUNK, overflowing the heap buffer on copy_nonoverlapping.
  • cl_set_root_constants dereferenced data without checking data.is_null() when n > 0.

This calls PC Reset before clearing state and emits cl_set_pipeline_state for non-null initial PSO on success, sizes new chunks to CHUNK.max(min_bytes + SLACK) via new_chunk_of, and guards data.is_null() in cl_set_root_constants.

What is in it

  • crates/xcl/src/hle/d3d12x/console_list.rs: fix cl_reset ordering and initial PSO recording, size new_chunk_of for oversized push records, guard data.is_null() in cl_set_root_constants, and add unit tests cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success (verified failing before the fix) and push_oversized_record_and_null_root_constants_are_safe.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 772 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib console_list: 8 passed, 0 failed (cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success failed before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: 86df8e857eed6f5f2789c3da345c2b2baf0e6de2
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1643)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14958 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited console_list.rs, wrote the fixes and unit tests, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5476382203 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T16:41:37Z. --- Fixes three safety and correctness bugs in `crates/xcl/src/hle/d3d12x/console_list.rs`: - `cl_reset` wiped `st.chunks`, `st.arena`, `st.allocator`, and `st.uma` before calling the PC list's `Reset` (destroying recording state if PC `Reset` failed) and never recorded a `PIPE_MARKER` packet when a non-null initial `ConsolePso` was passed (causing `close()` to start with `pso = None` and silently skip dispatches until a later `SetPipelineState`). - `push` allocated a fixed `CHUNK`-byte buffer even when `4 * words.len()` exceeded `CHUNK`, overflowing the heap buffer on `copy_nonoverlapping`. - `cl_set_root_constants` dereferenced `data` without checking `data.is_null()` when `n > 0`. This calls PC `Reset` before clearing state and emits `cl_set_pipeline_state` for non-null initial PSO on success, sizes new chunks to `CHUNK.max(min_bytes + SLACK)` via `new_chunk_of`, and guards `data.is_null()` in `cl_set_root_constants`. **What is in it** - `crates/xcl/src/hle/d3d12x/console_list.rs`: fix `cl_reset` ordering and initial PSO recording, size `new_chunk_of` for oversized `push` records, guard `data.is_null()` in `cl_set_root_constants`, and add unit tests `cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success` (verified failing before the fix) and `push_oversized_record_and_null_root_constants_are_safe`. **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 772 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`) - `cargo test -p xcl --lib console_list`: 8 passed, 0 failed (`cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success` failed before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: 86df8e857eed6f5f2789c3da345c2b2baf0e6de2 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1642 (PresentX 1643) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14958 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `console_list.rs`, wrote the fixes and unit tests, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
futurepro62 commented 2026-11-24 17:06:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:59:21Z.


Full-suite run, since this PR has no test report yet. Tested exact head 86df8e8 (on its base b7aa9f3).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success, push_oversized_record_and_null_root_constants_are_safe.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7138515082 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7138515082). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T16:59:21Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `86df8e8` (on its base `b7aa9f3`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **772 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success`, `push_oversized_record_and_null_root_constants_are_safe`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **772 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-24 19:07:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:17Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141291830 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7141291830). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:53:17Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
oni-swr commented 2026-11-25 18:04:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T17:09:49Z.


amd-win test report for 86df8e85 (exact head 86df8e857eed6f5f2789c3da345c2b2baf0e6de2) on AMD Radeon RX 7800 XT

Tested

  • AMD Radeon RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 build 26200; rustc 1.100.0 MSVC; DXC 1.8.2502.11 (Windows SDK 10.0.26100); debug build for the tests, release build for the smoke runs
  • The PR head exactly as pushed (its base is older than current main; the merged tree was not tested). Merges cleanly into origin/main 55d64c27 (git merge-tree)
  • Focused: cargo test -p xcl --lib console_list: 8 passed, 0 failed (includes the two new tests cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success and push_oversized_record_and_null_root_constants_are_safe)
  • Full suite, cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored; no SKIPPED lines printed

Regression run (own test title tests/testtitle, 60 s, release; same title and time for both. The test title exits with code 2 by design and shows no frames, so crashes: 1 is its normal exit and is the same on both)
PR head:

xcl-smoke v1
commit: 86df8e857eed6f5f2789c3da345c2b2baf0e6de2
gpu: AMD Radeon RX 7800 XT
title: testgame
seconds: 60
exit: 0x1
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 
device removals: 0
crashes: 1
peak commit: n/a MB

main (b7aa9f3):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: AMD Radeon RX 7800 XT
title: testgame
seconds: 60
exit: 0x2
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 
device removals: 0
crashes: 1
peak commit: n/a MB

Not tested

  • No retail title: this is a run of our own test title only, so the smoke run does not reach the code this PR changes and says nothing about frames or frame time
  • Other GPUs (NVIDIA / Intel), wave64-only paths on other adapters, and the merged tree on current main

AI use

  • Run and written up by Claude Code (Claude Sonnet 5.5) from real runs on the hardware named above, for oni-swr. No code was changed.
<!-- greyfinch-sync:ivall/xcl:comment:7169098748 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7169098748). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T17:09:49Z. --- **amd-win test report for `86df8e85` (exact head `86df8e857eed6f5f2789c3da345c2b2baf0e6de2`) on AMD Radeon RX 7800 XT** **Tested** - AMD Radeon RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 build 26200; rustc 1.100.0 MSVC; DXC 1.8.2502.11 (Windows SDK 10.0.26100); debug build for the tests, release build for the smoke runs - The PR head exactly as pushed (its base is older than current `main`; the merged tree was not tested). Merges cleanly into `origin/main` `55d64c27` (`git merge-tree`) - Focused: `cargo test -p xcl --lib console_list`: 8 passed, 0 failed (includes the two new tests `cl_reset_preserves_state_on_pc_failure_and_records_initial_pso_on_success` and `push_oversized_record_and_null_root_constants_are_safe`) - Full suite, `cargo test --workspace -- --test-threads=4`: 772 passed, 0 failed, 41 ignored; no SKIPPED lines printed **Regression run** (own test title `tests/testtitle`, 60 s, release; same title and time for both. The test title exits with code 2 by design and shows no frames, so `crashes: 1` is its normal exit and is the same on both) PR head: ``` xcl-smoke v1 commit: 86df8e857eed6f5f2789c3da345c2b2baf0e6de2 gpu: AMD Radeon RX 7800 XT title: testgame seconds: 60 exit: 0x1 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): device removals: 0 crashes: 1 peak commit: n/a MB ``` `main` (b7aa9f3): ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: AMD Radeon RX 7800 XT title: testgame seconds: 60 exit: 0x2 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): device removals: 0 crashes: 1 peak commit: n/a MB ``` **Not tested** - No retail title: this is a run of our own test title only, so the smoke run does not reach the code this PR changes and says nothing about frames or frame time - Other GPUs (NVIDIA / Intel), wave64-only paths on other adapters, and the merged tree on current `main` **AI use** - Run and written up by Claude Code (Claude Sonnet 5.5) from real runs on the hardware named above, for `oni-swr`. No code was changed.
throny commented 2026-11-25 19:08:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T18:10:49Z.


Two contributors checked independently and found that #806 solves the same problem in a different way: #1607, group D101. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7170550497 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7170550497). Originally posted by [throny](https://github.com/throny) on 2026-11-25T18:10:49Z. --- <!-- xcl-1607-hint:D101 --> Two contributors checked independently and found that #806 solves the same problem in a different way: #1607, group D101. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
github-actions[bot] commented 2026-11-29 20:44:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:18Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262318443 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7262318443). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:18Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:53:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:53:34Z.


Triage (#1607) – head 86df8e8

#806 makes the same oversized-record fix in console_list.rs (push / new chunk of CHUNK.max(need + SLACK) bytes). This PR has all of it, plus three more fixes:

  • cl_reset no longer clears the recorded stream when the PC reset fails.
  • cl_reset records the initial PSO as a PIPE_MARKER; close starts with pso = None, so this matters.
  • cl_set_root_constants ignores null data.
    None of these fixes is on main. The PR conflicts with main's cl_reset, which now calls title_textures::forget_list_closed and forward_reset; keep both when rebasing.

Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302249678 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7302249678). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:53:34Z. --- **Triage (#1607)** – head 86df8e8 #806 makes the same oversized-record fix in `console_list.rs` (`push` / new chunk of `CHUNK.max(need + SLACK)` bytes). This PR has all of it, plus three more fixes: - `cl_reset` no longer clears the recorded stream when the PC reset fails. - `cl_reset` records the initial PSO as a `PIPE_MARKER`; `close` starts with `pso = None`, so this matters. - `cl_set_root_constants` ignores null `data`. None of these fixes is on main. The PR conflicts with main's `cl_reset`, which now calls `title_textures::forget_list_closed` and `forward_reset`; keep both when rebasing. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1477:upstream-pr/1477'
git switch 'upstream-pr/1477'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1477'
git switch 'upstream-pr/1477'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1477'
git switch 'upstream-pr/1477'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1477'
git switch 'main'
git merge --squash 'upstream-pr/1477'
git switch 'main'
git merge --ff-only 'upstream-pr/1477'
git switch 'main'
git merge 'upstream-pr/1477'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1467
No description provided.