XGameRuntime: XTaskQueueIsEmpty counts delayed callbacks not yet due #1671
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1681"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T19:14:51Z.
XTaskQueueIsEmptylooked only at a port's queued items and the callbacks in flight. A callback submitted with a delay (XTaskQueueSubmitDelayedCallback, orXAsyncSchedulewith a delay) waits in the task queue's timer heap until it is due, so while it waited the port read as empty. libHttpClient's task queue, which XTaskQueue is, counts those entries.TaskQueuePortImpl::IsEmptyis(m_queueList->empty()) && (m_pendingList->empty()) && (m_processingCallback == 0), and a delayed entry goes tom_pendingList(TaskQueue.cpp).A title that dispatches until the port is empty before it terminates a queue, or that uses
XTaskQueueIsEmptyto tell whether its timers are done, stopped too early. The delayed callback then ran canceled at termination.XTaskQueueIsEmptynow also looks for the queue's entries on that port in the timer heap. The locks are taken in the ordersubmit_delayedalready uses: the timer heap, then the port's items, then the queue state. No path takes the timer lock while it holds the other two.What is in it
crates/xcl/src/hle/xgameruntime/taskqueue.rs:XTaskQueueIsEmptycounts delayed callbacks not yet due. Testis_empty_counts_delayed_callbacks_not_yet_due: a 60 s delayed callback keeps the work port non-empty and leaves the completion port empty, and termination cancels it.Tested
cargo test --workspace -- --test-threads=4onc53eed3: 859 passed, 0 failed, 42 ignored; SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)XTaskQueueIsEmpty: it fails atassert!(!XTaskQueueIsEmpty(h, PORT_WORK), "a delayed callback not yet due is still queued")Regression run
main:
this PR:
Not tested
XTaskQueueIsEmptywith delayed callbacks pending; the smoke title's run is a regression check only.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by mantavisual on 2026-11-24T20:46:59Z.
Test report for
c53eed33ef16on NVIDIA, which the PR lists as not tested.Tested
cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 859 passed, 0 failed, 42 ignored. The new test ran.4178e88: 892 passed, 0 failed, 42 ignored.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Does the test notice a broken fix?
Arc::ptr_eq(&t.queue, &q)removed, so that delayed callbacks of any queue count, all 11taskqueuetests still pass. The timer heap is shared by all queues and the test makes one. Creating a second queue while the callback is pending and assertingXTaskQueueIsEmpty(other, PORT_WORK)passes normally and fails with that break.Not tested: AMD, retail title, concurrent use.
AI use: Claude Code (Claude Opus 5.5) ran this on my machine, wrote the report and posted it for me.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T21:37:47Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by MiharaxD on 2026-11-24T21:44:21Z.
Test report on an NVIDIA card, head
c53eed3(onmainc160d86), which covers the "NVIDIA" line.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4(debug) onc53eed3: 859 passed, 0 failed, 42 ignored (lib tests 810 / 0 / 22).gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64).is_empty_counts_delayed_callbacks_not_yet_duepasses.Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60(release builds, start screen, no input).mainisc160d86:main:
this PR's head:
Not tested
XTaskQueueIsEmptywith delayed callbacks pending: the smoke run is a regression check only.AI use: Claude Code (Claude Opus 5.5) built the PR, ran the tests and both smoke runs, read the logs and wrote this report; I checked it before posting.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:55:20Z.
XCL PR #1681 compatibility verification
Commit
c53eed33ef1625568c739ca854e4eb34db8d1775on STOR-WINLAB. Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. The adapter reportsDoublePrecisionFloatShaderOps=0and a wave range of 8–32.d3d12SDKLayers.dllis absent. DXC/DXIL 1.9.2609.5 and rustc 1.100.0 (0ef1bc386 2026-11-09), unoptimized builds with debug info disabled.Tested
cargo build --workspaceandcargo test --workspace --no-runsucceeded. Both emitted two deprecation warnings forAtomic::fetch_update(duplicated in the test build).cargo test -p xcl xgameruntime -- --nocaptureunder the Arc lock reported 75 passed, 0 failed, 0 ignored, 0 SKIPPED lines. All 74 unit tests ran. The libHttpClient integration test returned early becauseXCL_SAMPLE_DLLSwas unset. The new regression passed here and in the workspace run. In a manual queue it verified that a not-yet-due callback makes the work port nonempty, leaves the completion port empty, and clears on termination.cargo test --workspace --no-fail-fast -- --test-threads=4ran once under the Arc lock and exited 101. Across 20 harness summaries,pr1681-suite.logrecorded 841 passed, 18 failed, 42 ignored and 3 SKIPPED lines. The harness totals include early returns. Two explicit skips cited no wave64 and one cited no heap windows. These skips provide no test coverage.Of the 18 failures, 13 GPU tests reported
CreateComputePipelineStatereturning0x80070057. Four other GPU tests reported mismatches in fused multiply-add, implicit texture LOD, f16 lane preservation, and wave64 pixel reduction. The test-title e2e failed the D3D12.X dynamic depth-bias check (RSSetDepthBiasX), which produced a blue pixel where green was expected.Not tested
Main-branch baseline, retail-title smoke runs, optional
XCL_SAMPLE_*fixtures, and other GPU adapters.AI use
T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1681-suite.logand published.Imported from ivall/xcl. Originally posted by throny on 2026-11-28T06:50:17Z.
merge-check claim
head:
c53eed33efImported from ivall/xcl. Originally posted by throny on 2026-11-28T07:07:00Z.
merge-check
base:
e429936chead:
c53eed33efmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2127 passed, 9 failed, 48 ignored (26 SKIPPED lines). The 9 failures are main's own at
e429936con this GPU (reported with a bisect on #3041: they arrive with the merge of #2959); the set is identical with and without this PR. Base alone: 2126 passed, 9 failed, 48 ignored.review: no blocking finding. Lock order is timer, then items, then state, and no path on main takes them the other way round. Minor: the timer thread drops the heap lock between popping an entry and submitting it, so IsEmpty can briefly say true in that gap (still better than main). Test gap from the thread: removing the queue-identity comparison still passes all tests.
performance: XTaskQueueIsEmpty now takes the process-wide timer lock and scans the delayed heap; small unless a title polls it hard with many timers (not measured).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-30T00:01:07Z.
merge-check
base:
53e85fb124head:
c53eed33efmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2793 passed, 1 failed, 49 ignored; SKIPPED: 29 (mostly "no wave64"); failing:
hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which fails on the base53e85fbalone too (#2369's test againstmain'slate_release, see #2369), not this PRreview: none blocking, after reading the whole diff (
xgameruntime/taskqueue.rs). Lock order:XTaskQueueIsEmptynow takes timer, thenitems, thenstate. The other timer-lock sites fit that order:submit_delayedtakes timer thenstate(is_terminated), the timer thread drops the heap lock beforesubmit_now, andXTaskQueueTerminatereleases the timer lock before takingstate. No path takes timer while holdingitemsorstate.is_empty_counts_delayed_callbacks_not_yet_duepasses 30/30 alone andhle::xgameruntime::taskqueue::(11 tests) 30/30 at--test-threads=8. With the newdelayedcondition disabled (scratch), the test fails ("a delayed callback not yet due is still queued").performance: one more mutex (the shared timer heap) and a scan of the pending delayed callbacks per
XTaskQueueIsEmpty; nothing per frame unless a title polls it. Reasoned, not measured.verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug / Claude Code (Claude Opus 5.5)