D3D12.X: remember only accepted private upload waits #3791

Open
Prime1997 wants to merge 1 commit from upstream-pr/3791 into main
Prime1997 commented 2026-12-03 14:48:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-12-03T14:48:18Z.


A failed wait on the private texture-upload fence could be recorded as satisfied. Later submits could then skip the wait. Record the mark only after valid fence completion or successful queue admission. Failed waits take the existing submission failure path.

What is in it

  • Reject the device-removal completion sentinel.
  • Leave failed marks pending and memoize accepted waits to suppress redundant queue calls.
  • #2558 addresses the related tile-mapping fence. This change targets the private texture-upload fence.

Tested

  • Exact head 989487393161cace0fb2882baf30a25d39d8d506 on Windows x64.
  • cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture --exact hle::d3d12x::title_textures::tests::private_upload_wait_keeps_failed_marks_pending_until_a_wait_succeeds. 1 passed, 0 failed, 0 ignored, 0 skips. The regression exercised a failed wait, retry, duplicate suppression, completed fence, and removed-device sentinel.

Regression run

  • The paired retail smoke is pending for this draft.

Not tested

  • Retail gameplay and the full workspace GPU suite.

AI use

  • OpenAI Codex (GPT-6) investigated the private wait path, wrote the patch and regression, and ran the targeted check.

Contributors can use this optional temporary Discord to coordinate testing and compare results.

<!-- greyfinch-sync:ivall/xcl:issue:5628808697 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3791). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-12-03T14:48:18Z. --- A failed wait on the private texture-upload fence could be recorded as satisfied. Later submits could then skip the wait. Record the mark only after valid fence completion or successful queue admission. Failed waits take the existing submission failure path. **What is in it** - Reject the device-removal completion sentinel. - Leave failed marks pending and memoize accepted waits to suppress redundant queue calls. - #2558 addresses the related tile-mapping fence. This change targets the private texture-upload fence. **Tested** - Exact head `989487393161cace0fb2882baf30a25d39d8d506` on Windows x64. - `cargo test --locked -p xcl --lib -- --test-threads=1 --nocapture --exact hle::d3d12x::title_textures::tests::private_upload_wait_keeps_failed_marks_pending_until_a_wait_succeeds`. 1 passed, 0 failed, 0 ignored, 0 skips. The regression exercised a failed wait, retry, duplicate suppression, completed fence, and removed-device sentinel. **Regression run** - The paired retail smoke is pending for this draft. **Not tested** - Retail gameplay and the full workspace GPU suite. **AI use** - OpenAI Codex (GPT-6) investigated the private wait path, wrote the patch and regression, and ran the targeted check. Contributors can use this [optional temporary Discord](https://discord.gg/gK3y7WRRY) to coordinate testing and compare results.
Gevroska commented 2026-12-03 17:45:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-03T17:45:38Z.


@Prime1997 I tested the ordinary submission path on 98948739 and its parent (a815de93). With completion at 3, I made the wait for mark 4 fail. The parent remembered 4 as satisfied and returned past the submission gate. The PR kept 3 and took the stop path before reaching the point where driver submission could proceed.

I also injected UINT64_MAX as the completion value. The PR again kept 3 and stopped. The controls behaved as expected: a duplicate after an accepted wait was suppressed, and the same mark on a different queue still required its own wait.

I checked 60 observations across six fresh Windows processes. The fixture supplied the D3D12 responses and intercepted the terminal call, so this confirms the wait bookkeeping and submission decision. Actual driver failure and device-removal recovery remain untested.

AI disclosure: OpenAI Codex GPT-6.2 Sol wrote the fixture and ran the comparison. An independent Codex reviewer checked all 60 observations. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7387017616 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3791#issuecomment-7387017616). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-12-03T17:45:38Z. --- @Prime1997 I tested the ordinary submission path on `98948739` and its parent (`a815de93`). With completion at 3, I made the wait for mark 4 fail. The parent remembered 4 as satisfied and returned past the submission gate. The PR kept 3 and took the stop path before reaching the point where driver submission could proceed. I also injected `UINT64_MAX` as the completion value. The PR again kept 3 and stopped. The controls behaved as expected: a duplicate after an accepted wait was suppressed, and the same mark on a different queue still required its own wait. I checked 60 observations across six fresh Windows processes. The fixture supplied the D3D12 responses and intercepted the terminal call, so this confirms the wait bookkeeping and submission decision. Actual driver failure and device-removal recovery remain untested. AI disclosure: OpenAI Codex GPT-6.2 Sol wrote the fixture and ran the comparison. An independent Codex reviewer checked all 60 observations. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
Foniass commented 2026-12-03 17:49:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T17:49:23Z.


merge-check
base: 16c2fd082a
head: 9894873931
merge: clean
build: ok
tests: 3019 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 4 medium, 3 nits (below)
performance: 60 s smoke run: 1683 → 1665 frames (98 % of main), peak commit 18505 → 17546 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 236 s there, 0 device removals, 0 crashes, 3.7 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: it is a draft, and PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: The PR makes the title queue's Wait on XCL's private texture-upload fence count as done only after the fence has really completed or the Wait was queued. A failed Wait, or the device-removed value (UINT64_MAX), now stops the title through the existing MappingUnmarked path. Before, the mark was saved anyway and later submits skipped the Wait. The logic is correct, the lock order (queue lease, then OWN_WAITED) matches native_queue_wait, and I found no deadlock. Nothing blocks it: what is left is an extra queue-lease acquisition on every submit, untested wiring, and a textual conflict with #3790.

Medium

  1. Queue lease taken on every submit, even when nothing needs a Wait. wait_for_own_uploads (title_textures.rs ~2743) now enters queue_submit::with before it checks OWN_WAITED. Once XCL's own queue has uploaded anything, every title submit takes its queue's lease inside refresh while holding the global REFRESH mutex, even when the saved mark already covers the value. If another thread holds that queue's lease for a chunk submit (wait_for_previous_submits, the driver call), every queue's refresh waits behind it. Before, the lease was taken only when a Wait was actually queued. Checking OWN_WAITED first and returning true before taking the lease would be just as safe, because a saved mark means the Wait is already on the queue. Otherwise measure the cost.
  2. No test of the stop path. The unit test covers only the extracted order_own_upload helper. Nothing checks that a failed wait_for_own_uploads makes refresh_once return MappingUnmarked when the outcome was Ready or RetryRequired (~1920), or that upload_all turns it into UploadError::MappingUnmarked and puts the batch back on RETRY (~2922). Those two call sites are the actual fix. A test with a stubbed wait result, or at least an assertion on the returned outcome, would cover them.
  3. Textual conflict with #3790. #3790, from the same author, changes the same lines in upload_all (title_textures.rs ~2919: submit_on(dev, &q, &mut items) next to the wait_for_own_uploads(&q) call that this PR replaces), and git merge-tree reports a conflict between the two heads. The conflict is easy to resolve, but whichever PR merges second needs a rebase and a new test run. #3789 (DirectStorage) does not overlap.
  4. No issue linked. The description links no issue (Fixes #N / Part of #N). It also cites #2558 as handling the tile-mapping fence, but #2558 is closed and was not merged.

Nit

  1. GPU test ignores the new return value. gpu_every_queue_waits_once_for_the_uploads_on_the_own_queue (~4504) calls wait_for_own_uploads(q) twice and drops the bool. assert!(wait_for_own_uploads(q)) would make a wait failure show up directly, instead of only through the later "queue went on" assertion.
  2. README note in the wrong section. The new README sentence (~418) sits inside the XCL_PAGE_MAPPINGS bullet, but it is about private texture uploads, not page mappings, and it describes an internal fail-closed case that most users will not need. Move it or drop it.
  3. MappingUnmarked now covers more than mappings. The variant now also covers a failed Wait on texture uploads. The doc comment (sparse.rs ~2415) and the stop message (real.rs ~12143) were updated, but the name no longer matches. Renaming it would be a separate change, so this is just a note.
Checked and fine
  • Device removal: fence_completed returning u64::MAX now counts as "not ordered", and prepare_title_submission calls stop_if_device_removed first, so the stop reason stays device removal
  • Lock order: the queue lease is re-entrant, and native_queue_wait already took it inside OWN_WAITED before, so taking the lease first and then OWN_WAITED cannot invert an existing order, and REFRESH followed by the lease was already the order on the upload path
  • title_queue_for returns the same queue as the submit's title queue, so the lease in upload_all is the one the submit thread may already hold, not a second queue
  • ExecutedUntracked still wins over the new MappingUnmarked in refresh_once, and both stop the title
  • The new unit test covers a failed wait, a retry, skipping a Wait already queued, an already completed fence and the device-removed value, and it asserts the saved mark stays unchanged after each failure
  • No assertions deleted or weakened, no generated files, no game data, about 70 changed lines in one logical change, merges cleanly onto origin/main a815de932
How this was tested
  • Merged onto main 16c2fd08, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 16c2fd08 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7387116180 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3791#issuecomment-7387116180). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T17:49:23Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: 989487393161cace0fb2882baf30a25d39d8d506 merge: clean build: ok tests: 3019 passed, 0 failed, 56 ignored; 28 skipped, the same as on main review: 4 medium, 3 nits (below) performance: 60 s smoke run: 1683 → 1665 frames (98 % of main), peak commit 18505 → 17546 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 236 s there, 0 device removals, 0 crashes, 3.7 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: it is a draft, and `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** The PR makes the title queue's Wait on XCL's private texture-upload fence count as done only after the fence has really completed or the Wait was queued. A failed Wait, or the device-removed value (UINT64_MAX), now stops the title through the existing MappingUnmarked path. Before, the mark was saved anyway and later submits skipped the Wait. The logic is correct, the lock order (queue lease, then OWN_WAITED) matches native_queue_wait, and I found no deadlock. Nothing blocks it: what is left is an extra queue-lease acquisition on every submit, untested wiring, and a textual conflict with #3790. #### Medium 1. **Queue lease taken on every submit, even when nothing needs a Wait.** wait_for_own_uploads (title_textures.rs ~2743) now enters queue_submit::with before it checks OWN_WAITED. Once XCL's own queue has uploaded anything, every title submit takes its queue's lease inside refresh while holding the global REFRESH mutex, even when the saved mark already covers the value. If another thread holds that queue's lease for a chunk submit (wait_for_previous_submits, the driver call), every queue's refresh waits behind it. Before, the lease was taken only when a Wait was actually queued. Checking OWN_WAITED first and returning true before taking the lease would be just as safe, because a saved mark means the Wait is already on the queue. Otherwise measure the cost. 2. **No test of the stop path.** The unit test covers only the extracted order_own_upload helper. Nothing checks that a failed wait_for_own_uploads makes refresh_once return MappingUnmarked when the outcome was Ready or RetryRequired (~1920), or that upload_all turns it into UploadError::MappingUnmarked and puts the batch back on RETRY (~2922). Those two call sites are the actual fix. A test with a stubbed wait result, or at least an assertion on the returned outcome, would cover them. 3. **Textual conflict with #3790.** #3790, from the same author, changes the same lines in upload_all (title_textures.rs ~2919: `submit_on(dev, &q, &mut items)` next to the `wait_for_own_uploads(&q)` call that this PR replaces), and `git merge-tree` reports a conflict between the two heads. The conflict is easy to resolve, but whichever PR merges second needs a rebase and a new test run. #3789 (DirectStorage) does not overlap. 4. **No issue linked.** The description links no issue (`Fixes #N` / `Part of #N`). It also cites #2558 as handling the tile-mapping fence, but #2558 is closed and was not merged. #### Nit 5. **GPU test ignores the new return value.** gpu_every_queue_waits_once_for_the_uploads_on_the_own_queue (~4504) calls wait_for_own_uploads(q) twice and drops the bool. `assert!(wait_for_own_uploads(q))` would make a wait failure show up directly, instead of only through the later "queue went on" assertion. 6. **README note in the wrong section.** The new README sentence (~418) sits inside the XCL_PAGE_MAPPINGS bullet, but it is about private texture uploads, not page mappings, and it describes an internal fail-closed case that most users will not need. Move it or drop it. 7. **MappingUnmarked now covers more than mappings.** The variant now also covers a failed Wait on texture uploads. The doc comment (sparse.rs ~2415) and the stop message (real.rs ~12143) were updated, but the name no longer matches. Renaming it would be a separate change, so this is just a note. <details><summary>Checked and fine</summary> - Device removal: fence_completed returning u64::MAX now counts as "not ordered", and prepare_title_submission calls stop_if_device_removed first, so the stop reason stays device removal - Lock order: the queue lease is re-entrant, and native_queue_wait already took it inside OWN_WAITED before, so taking the lease first and then OWN_WAITED cannot invert an existing order, and REFRESH followed by the lease was already the order on the upload path - title_queue_for returns the same queue as the submit's title queue, so the lease in upload_all is the one the submit thread may already hold, not a second queue - ExecutedUntracked still wins over the new MappingUnmarked in refresh_once, and both stop the title - The new unit test covers a failed wait, a retry, skipping a Wait already queued, an already completed fence and the device-removed value, and it asserts the saved mark stays unchanged after each failure - No assertions deleted or weakened, no generated files, no game data, about 70 changed lines in one logical change, merges cleanly onto origin/main a815de932 </details> <details><summary>How this was tested</summary> - Merged onto main `16c2fd08`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `16c2fd08` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3791:upstream-pr/3791'
git switch 'upstream-pr/3791'

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/3791'
git switch 'upstream-pr/3791'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3791'
git switch 'upstream-pr/3791'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3791'
git switch 'main'
git merge --squash 'upstream-pr/3791'
git switch 'main'
git merge --ff-only 'upstream-pr/3791'
git switch 'main'
git merge 'upstream-pr/3791'
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!3791
No description provided.