Skip to content

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

Open
gloger2003 wants to merge 2 commits into
xcl-dev:mainfrom
gloger2003:fix/initial-render-target-preparation
Open

gloger2003 wants to merge 2 commits into
xcl-dev:mainfrom
gloger2003:fix/initial-render-target-preparation

Conversation

@gloger2003

@gloger2003 gloger2003 commented Nov 24, 2026 •

Copy link
Copy Markdown

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:

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.

@dcastell1

Copy link
Copy Markdown

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

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

Thanks!

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)
@gloger2003
gloger2003 force-pushed the fix/initial-render-target-preparation branch from c0c80cf to 14dfb38 Compare November 24, 2026 21:58
@DavidM1911

Copy link
Copy Markdown
Contributor

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.

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 14dfb38

#1324 contains this PR's two commits plus its own (c3f17d3); it is stacked on this one, not a duplicate. No other open or merged PR prepares color targets for startup clears.
No problems found in the diff; the behaviour is behind XCL_TEST_PREP_SUBMITTED_TARGETS. The PR conflicts with main.
Recommendation: keep open.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants