D3D12.X: prepare color targets for startup clears #1261

Open
github-bot wants to merge 2 commits from github-bot/gh-1261 into main AGit
Owner

@⁠gloger2003 on GitHub · 2026-11-24 13:57 UTC · original
gloger2003:fix/initial-render-target-preparation → main · +419 −10 · 5 files · 2 commits · open

Some placed color targets reach a startup clear in COMMON. On Windows, the clear requires RENDER_TARGET. A transition recorded in another list may already have prepared the target, so the PR uses submission order to choose which transitions to insert.

The stacked PR #1324 adds safeguards for unresolved queue waits and aliased targets. Review the two together before enabling the experiment.

What is in it

  • Track eligible placed render targets, record clears and transitions per list, and insert auxiliary command lists at submission.
  • Restore the original state when the title leaves it unchanged. Retain temporary GPU objects until the queue completes their work.
  • Keep the original title transition if auxiliary preparation fails. Restore the expected state in a separate barrier call.
  • Keep the behavior opt-in with XCL_TEST_PREP_SUBMITTED_TARGETS=1 and add coverage for replay and native D3D12 state transitions.

Tested

  • On rebased head 14dfb38, Windows 11 x64, Ryzen 7 5700X, Radeon RX 7800 XT.
  • cargo build --offline --locked --release -p xcl on main and the rebased head.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output on the rebased head. 961 reported passed, 0 failed, 43 ignored. Runtime skips: 7 (gpu, heap_window_out_of_memory_falls_back_to_the_switch_form).

Earlier testing on c0c80cf, its predecessor and the indicated integration tree:

  • Radeon RX 7800 XT with driver 32.0.32029.2010, Ryzen 7 5700X, Windows 11 build 26300.9974, Rust 1.100.0 MSVC.
  • cargo build --offline --locked --workspace and cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output with the flag enabled for tests. 753 passed, 0 failed, 41 ignored, 0 capability skips.
  • Minecraft Preview on Xbox Series at 1x with the D3D12 debug layer. Startup clear and transition errors fell from six to zero. Two existing warnings appeared in both runs. The experimental flag was enabled only for the PR run.
  • With temporary fault injection in the local build, Minecraft Preview submitted the title lists and exited normally when preparation was unavailable. The initial six errors were reported in that run.
  • On the initial revision cfa8fc8, RTX 5090 passed 753 workspace tests and RTX 3060 Ti passed 29 texture tests.
  • Supplemental integration on main c160d86 at local merge f4be315, which includes #1038, #1047, #1087, #1105, #1156, #1261 and #1324. On the RX 7800 XT, matched 30-second Minecraft Preview runs at 1x with the debug layer and DRED had six startup errors with preparation disabled (three each of IDs 527 and 538) and zero with it enabled. Both runs showed the menu, exited cleanly and reported two Input Layout warnings. The sampled frame at present 1340 had 124,446 and 124,432 non-dark samples out of 129,600.
  • On the same integration tree with preparation enabled, the workspace harness reported 868 passed, 0 failed and 42 ignored, including one optional heap-window test that reported a skip. That test passed in a separate opt-in heap-window run on the same tree. A 30-second run at 4x MSAA with direct DXIL and preparation both enabled showed 1,474 frames with no device removals, crashes or D3D12 debug-layer errors.

Regression run

Minecraft Preview at 1x, 30 seconds per build. XCL_TEST_PREP_SUBMITTED_TARGETS=1 was set for both runs.

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: AMD Radeon RX 7800 XT
title: c22a3829
seconds: 30
exit: 0x0
frames shown: 1556 (PresentX 1556)
presents per 2 s (last 3): 120 120 120
device removals: 0
crashes: 0
peak commit: 3384 MB
xcl-smoke v1
commit: 14dfb3891410f43890f3b8fe966def70de111798
gpu: AMD Radeon RX 7800 XT
title: c22a3829
seconds: 30
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 120 121 120
device removals: 0
crashes: 0
peak commit: 3350 MB

Not tested

  • Other titles, gameplay past the menu, other hardware drivers, and DRED on this exact revision.
  • Shared targets across queues remain an open case. A local synthetic reproduction confirmed that queue fences can put GPU work in a different order from CPU submissions. Aliasing and real driver allocation failures still need coverage.

AI use

  • OpenAI Codex (GPT-6.2 Sol, medium reasoning effort) investigated the issue, implemented the draft and tests, and ran the local checks.
  • OpenAI Codex (GPT-6.2 Sol, high reasoning effort, Fast mode) rebased the changes, resolved the upstream conflict and reran the checks.
**@⁠gloger2003** on GitHub · 2026-11-24 13:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/1261) `gloger2003:fix/initial-render-target-preparation` → `main` · +419 −10 · 5 files · 2 commits · open Some placed color targets reach a startup clear in COMMON. On Windows, the clear requires RENDER_TARGET. A transition recorded in another list may already have prepared the target, so the PR uses submission order to choose which transitions to insert. The stacked PR #1324 adds safeguards for unresolved queue waits and aliased targets. Review the two together before enabling the experiment. **What is in it** - Track eligible placed render targets, record clears and transitions per list, and insert auxiliary command lists at submission. - Restore the original state when the title leaves it unchanged. Retain temporary GPU objects until the queue completes their work. - Keep the original title transition if auxiliary preparation fails. Restore the expected state in a separate barrier call. - Keep the behavior opt-in with `XCL_TEST_PREP_SUBMITTED_TARGETS=1` and add coverage for replay and native D3D12 state transitions. **Tested** - On rebased head `14dfb38`, Windows 11 x64, Ryzen 7 5700X, Radeon RX 7800 XT. - `cargo build --offline --locked --release -p xcl` on main and the rebased head. - `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output` on the rebased head. 961 reported passed, 0 failed, 43 ignored. Runtime skips: 7 (gpu, heap_window_out_of_memory_falls_back_to_the_switch_form). Earlier testing on `c0c80cf`, its predecessor and the indicated integration tree: - Radeon RX 7800 XT with driver 32.0.32029.2010, Ryzen 7 5700X, Windows 11 build 26300.9974, Rust 1.100.0 MSVC. - `cargo build --offline --locked --workspace` and `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output` with the flag enabled for tests. 753 passed, 0 failed, 41 ignored, 0 capability skips. - Minecraft Preview on Xbox Series at 1x with the D3D12 debug layer. Startup clear and transition errors fell from six to zero. Two existing warnings appeared in both runs. The experimental flag was enabled only for the PR run. - With temporary fault injection in the local build, Minecraft Preview submitted the title lists and exited normally when preparation was unavailable. The initial six errors were reported in that run. - On the initial revision `cfa8fc8`, [RTX 5090](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1261) passed 753 workspace tests and [RTX 3060 Ti](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1261) passed 29 texture tests. - Supplemental integration on main `c160d86` at local merge `f4be315`, which includes #1038, #1047, #1087, #1105, #1156, #1261 and #1324. On the RX 7800 XT, matched 30-second Minecraft Preview runs at 1x with the debug layer and DRED had six startup errors with preparation disabled (three each of IDs 527 and 538) and zero with it enabled. Both runs showed the menu, exited cleanly and reported two Input Layout warnings. The sampled frame at present 1340 had 124,446 and 124,432 non-dark samples out of 129,600. - On the same integration tree with preparation enabled, the workspace harness reported 868 passed, 0 failed and 42 ignored, including one optional heap-window test that reported a skip. That test passed in a separate opt-in heap-window run on the same tree. A 30-second run at 4x MSAA with direct DXIL and preparation both enabled showed 1,474 frames with no device removals, crashes or D3D12 debug-layer errors. **Regression run** Minecraft Preview at 1x, 30 seconds per build. `XCL_TEST_PREP_SUBMITTED_TARGETS=1` was set for both runs. ``` xcl-smoke v1 commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331 gpu: AMD Radeon RX 7800 XT title: c22a3829 seconds: 30 exit: 0x0 frames shown: 1556 (PresentX 1556) presents per 2 s (last 3): 120 120 120 device removals: 0 crashes: 0 peak commit: 3384 MB ``` ``` xcl-smoke v1 commit: 14dfb3891410f43890f3b8fe966def70de111798 gpu: AMD Radeon RX 7800 XT title: c22a3829 seconds: 30 exit: 0x0 frames shown: 1642 (PresentX 1642) presents per 2 s (last 3): 120 121 120 device removals: 0 crashes: 0 peak commit: 3350 MB ``` **Not tested** - Other titles, gameplay past the menu, other hardware drivers, and DRED on this exact revision. - Shared targets across queues remain an open case. A local synthetic reproduction confirmed that queue fences can put GPU work in a different order from CPU submissions. Aliasing and real driver allocation failures still need coverage. **AI use** - OpenAI Codex (GPT-6.2 Sol, medium reasoning effort) investigated the issue, implemented the draft and tests, and ran the local checks. - OpenAI Codex (GPT-6.2 Sol, high reasoning effort, Fast mode) rebased the changes, resolved the upstream conflict and reran the checks.
Track the submitted state of eligible placed textures. Add transitions around startup clears when needed and keep auxiliary lists alive until the GPU has finished.

Keep the path opt-in while testing more queue and resource patterns.

Assisted-by: OpenAI Codex (GPT-6)
Keep the title transition when building the submission preparation fails. Restore the expected state in a separate barrier call to avoid a duplicate-subresource diagnostic, and exercise normal and fallback behavior in the texture-state test.

Assisted-by: OpenAI Codex (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:48:44 +00:00
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 14:01 UTC · original

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@930e8b4 (baseline 751 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
753 passed; 0 failed; 41 ignored   (exit 0)

Two more passing tests than the baseline; preparing colour targets for startup clears ships its coverage and it runs green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

**@⁠dcastell1** on GitHub · 2026-11-24 14:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/1261#issuecomment-7133704177) Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@930e8b4` (baseline **751 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 753 passed; 0 failed; 41 ignored (exit 0) ``` Two more passing tests than the baseline; preparing colour targets for startup clears ships its coverage and it runs green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 14:05 UTC · original

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

  • cargo test -p xcl lib texture: 29 passed, 0 failed.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1261#issuecomment-7133824746) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl lib texture: 29 passed, 0 failed. Thanks!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:41 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 04:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1261#issuecomment-7182810395) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.rs
  • crates/xcl/tests/texture_states.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/1261/head:github-bot/gh-1261'
git switch 'github-bot/gh-1261'

Merge

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