Skip to content

Task queues: terminating cancels delayed callbacks before the termination callback - #54

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:taskqueue-terminate-delayed
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:taskqueue-terminate-delayed

Conversation

@gefydev

@gefydev gefydev commented Nov 22, 2026

Copy link
Copy Markdown
Member

XTaskQueueTerminate (taskqueue.rs) cancels the callbacks queued on the queue's ports, but not delayed callbacks (XTaskQueueSubmitDelayedCallback, also used by XAsyncSchedule with a delay) that are still waiting in the timer heap. Those only count in inflight once they are due. So the wait in Terminate doesn't hold the termination callback for them: it runs first, and the delayed callback runs later, canceled, up to its full delay after the queue was terminated. A title often frees in the termination callback what it passed as those callbacks' context.

libHttpClient moves a terminating port's pending delayed entries to its active list (CancelPendingEntries(cxt, true) in TaskQueuePortImpl::Terminate), so they are invoked canceled before termination completes. Terminate now takes the queue's entries out of the timer heap and invokes them canceled before the termination callback, the same way it already handles the port items. Delayed callbacks of other queues stay in the heap.

Validation

  • New test terminate_cancels_delayed_callbacks_before_its_own_callback: a 60 s delayed callback, then Terminate(wait = true) with a termination callback. On main only ["terminated"] is recorded; with the change it is ["delayed, canceled", "terminated"].
  • cargo test -p xcl --lib: 340 passed, 0 failed, on Windows GNU under Wine.

…tion callback

XTaskQueueTerminate canceled the callbacks queued on the queue's ports,
but not delayed ones still waiting in the timer heap. Those count as in
flight only once due, so the termination callback ran first and the
delayed callback ran (canceled) up to its delay later – when a title may
already have freed what it passes as the callback's context.

They are now taken out of the timer heap and invoked canceled before the
termination callback, as libHttpClient's CancelPendingEntries does when a
port terminates.
@ivall
ivall merged commit 2e000cb into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
Like XTaskQueueSubmitDelayedCallback since #57 (libHttpClient schedules through it): E_ABORT,
so XAsyncRun / XCL's own operations on a terminated queue fail through the block (#56) and
their work never runs. Test async_work_on_a_terminated_queue_is_aborted; the task queue
module comment follows #54 / #57.
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (2e000cb). The module comment of taskqueue.rs now describes termination as it is after this and #57 (e38cb65).

Tested on Windows 11 (RX 9070): cargo test --workspace green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#1286-xcl-dev#1291, xcl-dev#1294, xcl-dev#1296-xcl-dev#1297, xcl-dev#1300

Prevent background shader preloading and concurrent DXC/RADV compiles from exhausting host RAM under Wine, and integrate 11 open upstream PRs:
- dxc.rs & real.rs: check free physical RAM (ullAvailPhys.min(ullAvailPageFile)) under Wine instead of swap-inclusive ullAvailPageFile, avoid bypassing the guard after 60 s under Wine, and serialize giant (>= 4 MiB DXIL) driver compiles with BIG_COMPILES under Wine.
- pso_async.rs: cap background preload workers to 1 under Wine.
- title_textures.rs: use real::create_raw_fence in submit_on_title_queue and read coherent-window hash bytes safely via with_title_bytes.
- Integrate upstream PRs xcl-dev#968 (sparse::queue lock-free for late_release), xcl-dev#1286 (v_dot2_f32_f16 NEG_HI abs), xcl-dev#1287 (XMA >8 channels), xcl-dev#1288 (Sleep pauses during PSO bind waits), xcl-dev#1289 (pipeline stream bounds check), xcl-dev#1290 (root signature MAX_ARGS cap), xcl-dev#1291 (console UAV clears xcl-dev#53/xcl-dev#54), xcl-dev#1294 (shadowed PENDING accuracy), xcl-dev#1296 (16-bit compare low halves), xcl-dev#1297 (fence_x pre-cell signal arming), xcl-dev#1300 (log driver compute PSO refusal).

Verified on RX 9060 XT under GE-Proton11-14 (MemoryMax=12G, 80 s): committed RAM stays flat at 4830 MB (down from 27.6 GB OOM), 1493 frames shown, exit 0x0.

Assisted-by: Antigravity (Google DeepMind)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
…PC descriptors

The command list's console xcl-dev#53 / xcl-dev#54 (ClearUnorderedAccessViewUint /
Float) were remapped straight to PC xcl-dev#49 / xcl-dev#50 (`console_remap`) with no
override, so a title's call reached the PC method with its handles as
they were. Console code takes its descriptor handles from heap xcl-dev#9 / xcl-dev#10,
which give it the address of its console heap slots in unified memory
(`console_heap::start`), not PC descriptor handles: the PC clear got a
GPU handle outside the bound shader-visible heap and a CPU handle
pointing at T# words. Only the opt-in console-list replay
(XCL_CONSOLE_LISTS=1) translated them.

xcl-dev#53 / xcl-dev#54 now go to `list_x::clear_uav_uint_x` / `clear_uav_float_x`
(same arguments as the PC methods): two console slots become their PC
UAVs (GPU: `pc_gpu_uav`, in the heap lists bind; CPU: `pc_uav`, in the
title's CPU-only heap), as the replay does; two PC handles go through as
they are; a mix, or a slot without a shader-visible UAV, is skipped and
logged once.

Test on WARP: an R32_UINT buffer UAV in a CPU-only and a shader-visible
console heap, xcl-dev#53 with the console handles and 0xDEADBEEF. With the
handles passed through (the old path) the test process dies with
STATUS_ACCESS_VIOLATION in the PC clear; with the translation the buffer
reads back 0xDEADBEEF.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
Add standalone integration tests (Part of xcl-dev#480) comparing XCL's CreateHeap (xcl-dev#28), CreateHeap1 (xcl-dev#54), and QueryInterface (#0) hooks against the unhooked host D3D12 driver (real::orig_fn) and verifying XCL's console heap fallbacks and synthetic IDXGIDevice2 adapter surface without console game files.

Assisted-by: Antigravity (Gemini 4 Hydrogen)
emirduran707 added a commit to emirduran707/xcl that referenced this pull request Nov 25, 2026
…PC descriptors

The command list's console xcl-dev#53 / xcl-dev#54 (ClearUnorderedAccessViewUint /
Float) were remapped straight to PC xcl-dev#49 / xcl-dev#50 (`console_remap`) with no
override, so a title's call reached the PC method with its handles as
they were. Console code takes its descriptor handles from heap xcl-dev#9 / xcl-dev#10,
which give it the address of its console heap slots in unified memory
(`console_heap::start`), not PC descriptor handles: the PC clear got a
GPU handle outside the bound shader-visible heap and a CPU handle
pointing at T# words. Only the opt-in console-list replay
(XCL_CONSOLE_LISTS=1) translated them.

(same arguments as the PC methods): two console slots become their PC
UAVs (GPU: `pc_gpu_uav`, in the heap lists bind; CPU: `pc_uav`, in the
title's CPU-only heap), as the replay does; two PC handles go through as
they are; a mix, or a slot without a shader-visible UAV, is skipped and
logged once.

Test on WARP: an R32_UINT buffer UAV in a CPU-only and a shader-visible
console heap, xcl-dev#53 with the console handles and 0xDEADBEEF. With the
handles passed through (the old path) the test process dies with
STATUS_ACCESS_VIOLATION in the PC clear; with the translation the buffer
reads back 0xDEADBEEF.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
raylitebull added a commit that referenced this pull request Nov 25, 2026
…andles

D3D12.X: console UAV clears (#53 / #54) get the slots' PC descriptors
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.

2 participants