Skip to content

D3D12.X: preserve startup clears when target state is unknown - #1324

Open
gloger2003 wants to merge 3 commits into
xcl-dev:mainfrom
gloger2003:fix/startup-clear-queue-order
Open

gloger2003 wants to merge 3 commits into
xcl-dev:mainfrom
gloger2003:fix/startup-clear-queue-order

Conversation

@gloger2003

@gloger2003 gloger2003 commented Nov 24, 2026 •

Copy link
Copy Markdown

Stacked on #1261. Only c3f17d3 belongs to this PR. Review the follow-up diff.

A queue can wait on producer work that has yet to be submitted, so CPU submission order alone cannot establish a target's state. An alias barrier can also change which texture is active inside a recorded list. Keep title commands in these cases and skip automatic preparation for affected targets.

What is in it

  • Track outstanding queue waits and serialize native submission with preparation planning and wait registration in the existing opt-in mode.
  • Invalidate inferred states after unresolved waits and alias barriers. Auxiliary lists stay outside title lists, so they cannot cross an activation or a deactivation.
  • Test a real D3D12 handoff with the consumer submitted first, expiry of waits, overlapping CPU calls, and named and unnamed alias barriers.

Tested

  • On rebased head c3f17d3, 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. 966 reported passed, 0 failed, 43 ignored. Runtime skips: 7 (gpu, heap_window_out_of_memory_falls_back_to_the_switch_form).

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

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: c3f17d382fa7e9abef05628e4da6b0cd288118db
gpu: AMD Radeon RX 7800 XT
title: c22a3829
seconds: 30
exit: 0x0
frames shown: 1623 (PresentX 1623)
presents per 2 s (last 3): 120 120 120
device removals: 0
crashes: 0
peak commit: 3345 MB

Not tested

  • Other titles, gameplay past the menu, other hardware drivers, and DRED on this revision.
  • The real-title run covers the normal startup path. The consumer-first queue order and alias fallbacks are covered by the local tests.

AI use

  • OpenAI Codex with GPT-6.2 Sol investigated the behavior, implemented the guard and tests, and ran the checks. The recorded reasoning effort was medium for the initial changes and high for the follow-up. Fast mode was selected in Codex for the high-effort work.
  • OpenAI Codex (GPT-6.2 Sol, high reasoning effort, Fast mode) rebased the changes, resolved the upstream conflict and reran the checks.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux, on a retail title.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1371 (PresentX 1371)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 8a48b441687ed8fd057618d3a93e985f9a1c18c6
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1333 (PresentX 1333)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The last main run: 1338 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the test suite on this head; native Windows; AMD.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

@gloger2003
gloger2003 marked this pull request as ready for review November 24, 2026 19:06
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)
An unresolved queue wait can put a submitted clear behind producer work that has not reached the GPU queue yet. Keep the title commands in this case and stop inferring states for the targets involved. Serialize the planning and submission with waits, and avoid inserting transitions across alias activation or deactivation.

Assisted-by: OpenAI Codex (GPT-6.2 Sol)
@gloger2003
gloger2003 force-pushed the fix/startup-clear-queue-order branch from 8a48b44 to c3f17d3 Compare November 24, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants