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

Open
github-bot wants to merge 1 commit from github-bot/gh-1477 into main AGit
Owner

@⁠b3IKK on GitHub · 2026-11-24 16:41 UTC · original
b3IKK:d3d12x/console-list-reset-and-bounds → main · +100 −16 · 1 files · 1 commits · open

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.
**@⁠b3IKK** on GitHub · 2026-11-24 16:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1477) `b3IKK:d3d12x/console-list-reset-and-bounds` → `main` · +100 −16 · 1 files · 1 commits · open 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.
Three safety/correctness bugs in console_list.rs:
- cl_reset cleared chunks/arena/allocator/uma before calling PC Reset
  (corrupting recording state if PC Reset failed) and never recorded
  a PIPE_MARKER packet when a non-null initial PSO was passed (causing
  close() to skip dispatches until a later SetPipelineState).
- push() allocated a fixed CHUNK-sized buffer even when a record
  exceeded CHUNK bytes, overflowing the heap allocation on copy.
- cl_set_root_constants() dereferenced `data` without checking
  `data.is_null()` when `n > 0`.

Call PC Reset before clearing state and emit cl_set_pipeline_state for
non-null initial PSO on success; size new chunks to at least
`min_bytes + SLACK`; and guard `data.is_null()` in cl_set_root_constants.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:06 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 16:59 UTC · original · edited 2026-11-24 17:07 UTC

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.
**@⁠futurepro62** on GitHub · 2026-11-24 16:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7138515082) · edited 2026-11-24 17:07 UTC 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 18:53 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-24 18:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7141291830) 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!
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 17:09 UTC · original

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.
**@⁠oni-swr** on GitHub · 2026-11-25 17:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7169098748) **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.
Author
Owner

@⁠throny on GitHub · 2026-11-25 18:10 UTC · original

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.

**@⁠throny** on GitHub · 2026-11-25 18:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1477#issuecomment-7170550497) <!-- 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.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/console_list.rs
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/1477/head:github-bot/gh-1477'
git switch 'github-bot/gh-1477'

Merge

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