D3D12.X: read the late-release setting at adoption, not at first release #1789

Open
github-bot wants to merge 1 commit from github-bot/gh-1789 into main AGit
Owner

@⁠vakaobr on GitHub · 2026-11-24 20:44 UTC · original
vakaobr:d3d12x/late-release-read-at-adoption → main · +14 −0 · 2 files · 1 commits · open

On a Mac (CrossOver, D3DMetal), D3DMetal releases the resources of an executed command list from a native thread of its own, which has no Wine TEB. The first Release there calls late_release::enabled(), whose OnceLock reads XCL_LATE_RELEASE from the environment for the first time, and that read never returns on that thread. This reads the setting in real::adopt, on the Wine thread that creates the object, so the OnceLock is set before the host's thread can reach it. Nothing changes on Windows: the same value is read once, only earlier.

Part of #258. It is the first commit of the series Ahmet-Dedeler reviewed in #258; the rest (deferring a Release that arrives on a host thread) stays a separate PR, since no test here needs it yet (#258).

What is in it

  • crates/xcl/src/hle/d3d12x/late_release.rs: init(), which forces the one-time read.
  • crates/xcl/src/hle/d3d12x/real.rs: adopt calls it for every adopted object.

Tested

  • MacBook Pro M5 Pro (20-core GPU), 48 GB, macOS 27.2.1, CrossOver 26.3.0.39832 with D3DMetal 3.0, Rosetta 2. Rust 1.100.0, x86_64-pc-windows-gnu (mingw-w64 GCC 16.2.0), debug, DXC 1.9.2609. Each test in its own process (<test exe> --exact <test> --test-threads=1 --nocapture, 90 to 120 s timeout).
  • console_wave64_compute_through_the_pso_hook_dispatch_and_read_back (tests/gpu_compute_e2e.rs) and hle::d3d12x::title_textures::tests::gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes:
    • main 85e3826 + #553 + Ahmet-Dedeler's ddf3be7 (which fix the other hangs in these two tests on this host): both time out, the first 2 of 2.
    • the same + this commit: both pass, the first 2 of 2.
    • main 85e3826 alone, with and without this commit: no run passes; each times out or ends without a result, on the hangs #553 and ddf3be7 fix.
  • late_release unit tests (a_held_resource_goes_when_the_queue_is_past_its_batch, without_queues_a_batch_goes_at_once): pass.

Regression run

This changes runtime files, so it needs an xcl-smoke pair from someone with a title; I have none.

Not tested

  • Windows and the whole suite: I can't build for MSVC here. On Windows the change only moves the first read of XCL_LATE_RELEASE earlier.
  • A retail title, a release build, Linux Wine.
  • No new test: the failure is a hang on a D3DMetal thread, which the two tests above show on a Mac and which can't happen on Windows.

AI use

  • Claude Code. Claude Opus 4.6 wrote the change; Claude Opus 5.5 reviewed it, ran the tests above on this machine and wrote this description.
**@⁠vakaobr** on GitHub · 2026-11-24 20:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1789) `vakaobr:d3d12x/late-release-read-at-adoption` → `main` · +14 −0 · 2 files · 1 commits · open On a Mac (CrossOver, D3DMetal), D3DMetal releases the resources of an executed command list from a native thread of its own, which has no Wine TEB. The first `Release` there calls `late_release::enabled()`, whose `OnceLock` reads `XCL_LATE_RELEASE` from the environment for the first time, and that read never returns on that thread. This reads the setting in `real::adopt`, on the Wine thread that creates the object, so the `OnceLock` is set before the host's thread can reach it. Nothing changes on Windows: the same value is read once, only earlier. Part of #258. It is the first commit of the series Ahmet-Dedeler reviewed in https://git.gtahub.st/github/xcl-dev--xcl/issues/258; the rest (deferring a `Release` that arrives on a host thread) stays a separate PR, since no test here needs it yet (https://git.gtahub.st/github/xcl-dev--xcl/issues/258). **What is in it** - `crates/xcl/src/hle/d3d12x/late_release.rs`: `init()`, which forces the one-time read. - `crates/xcl/src/hle/d3d12x/real.rs`: `adopt` calls it for every adopted object. **Tested** - MacBook Pro M5 Pro (20-core GPU), 48 GB, macOS 27.2.1, CrossOver 26.3.0.39832 with D3DMetal 3.0, Rosetta 2. Rust 1.100.0, `x86_64-pc-windows-gnu` (mingw-w64 GCC 16.2.0), debug, DXC 1.9.2609. Each test in its own process (`<test exe> --exact <test> --test-threads=1 --nocapture`, 90 to 120 s timeout). - `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back` (`tests/gpu_compute_e2e.rs`) and `hle::d3d12x::title_textures::tests::gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes`: - `main` 85e3826 + #553 + Ahmet-Dedeler's `ddf3be7` (which fix the other hangs in these two tests on this host): both time out, the first 2 of 2. - the same + this commit: both pass, the first 2 of 2. - `main` 85e3826 alone, with and without this commit: no run passes; each times out or ends without a result, on the hangs #553 and `ddf3be7` fix. - `late_release` unit tests (`a_held_resource_goes_when_the_queue_is_past_its_batch`, `without_queues_a_batch_goes_at_once`): pass. **Regression run** This changes runtime files, so it needs an `xcl-smoke` pair from someone with a title; I have none. **Not tested** - Windows and the whole suite: I can't build for MSVC here. On Windows the change only moves the first read of `XCL_LATE_RELEASE` earlier. - A retail title, a release build, Linux Wine. - No new test: the failure is a hang on a D3DMetal thread, which the two tests above show on a Mac and which can't happen on Windows. **AI use** - Claude Code. Claude Opus 4.6 wrote the change; Claude Opus 5.5 reviewed it, ran the tests above on this machine and wrote this description.
D3DMetal calls Release on adopted resources from a native thread of its
own at submit time.  That thread has no Wine TEB, so the first-time
std::env::var read inside the OnceLock in late_release::enabled() enters
Wine's ntdll and never returns.

Reading the setting once in adopt(), on the Wine thread that creates the
object, makes sure the OnceLock is already set before the host's thread
can reach it.

Part of #258.

Assisted-by: Claude Code (Claude Opus 4.6 (1M context))
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:19 +00:00
Author
Owner

@⁠eizispark on GitHub · 2026-11-24 21:04 UTC · original

Hardware test report — commit 2e85970

Verified 2e85970aa5f53c8617985b380e4f35920e6d041c (clean merge with main ea683a0): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64 (stable-x86_64-pc-windows-msvc, rustc 1.100.0 (0ef1bc386 2026-11-09)), debug tests + release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 875 passed, 0 failed, 42 ignored (2 skipped: shaders::tests::pso_measurement_compiles_an_exact_synthetic_record — Windows Developer Mode required (0x887A002D); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows)
  • hle::d3d12x::late_release::tests (a_held_resource_goes_when_the_queue_is_past_its_batch, without_queues_a_batch_goes_at_once), hle::d3d12x::title_textures::tests::gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back, and both native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware) passed cleanly on Windows 11 MSVC

Regression run (scripts/smoke.ps1, 60 s, warm shader/driver cache)
main (85e38262ff94aecd75d6f83fa8156a8b7697bd13):

xcl-smoke v1
commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1669 (PresentX 1669)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

PR (2e85970aa5f53c8617985b380e4f35920e6d041c):

xcl-smoke v1
commit: 2e85970aa5f53c8617985b380e4f35920e6d041c
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

Not tested

  • NVIDIA/Intel GPUs, XCL_D3D12_DEBUG=1 retail run, gameplay past the menus

AI use

  • Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).
**@⁠eizispark** on GitHub · 2026-11-24 21:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7144446157) ### Hardware test report — commit `2e85970` Verified `2e85970aa5f53c8617985b380e4f35920e6d041c` (clean merge with `main` `ea683a0`): **pass**. **Tested** - Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver `32.0.32015.16001`), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64 (`stable-x86_64-pc-windows-msvc`, `rustc 1.100.0 (0ef1bc386 2026-11-09)`), debug tests + release smoke - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `875 passed, 0 failed, 42 ignored` (`2 skipped`: `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record` — Windows Developer Mode required (`0x887A002D`); `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`) - `hle::d3d12x::late_release::tests` (`a_held_resource_goes_when_the_queue_is_past_its_batch`, `without_queues_a_batch_goes_at_once`), `hle::d3d12x::title_textures::tests::gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes`, `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back`, and both native RDNA4 wave64 GPU tests (`gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`) passed cleanly on Windows 11 MSVC **Regression run** (`scripts/smoke.ps1`, 60 s, warm shader/driver cache) `main` (`85e38262ff94aecd75d6f83fa8156a8b7697bd13`): ``` xcl-smoke v1 commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1669 (PresentX 1669) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14860 MB ``` PR (`2e85970aa5f53c8617985b380e4f35920e6d041c`): ``` xcl-smoke v1 commit: 2e85970aa5f53c8617985b380e4f35920e6d041c gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14862 MB ``` **Not tested** - NVIDIA/Intel GPUs, `XCL_D3D12_DEBUG=1` retail run, gameplay past the menus **AI use** - Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 23:41 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 23:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7147693339) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 03:20 UTC · original

PR #1789 compatibility verification on STOR-WINLAB

Tested commit 2e85970aa5f53c8617985b380e4f35920e6d041c. The diff initializes the cached XCL_LATE_RELEASE value during D3D12.X object adoption, before the release hook can read it.

Tested

  • Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175). Adapter wave range 8–32, DoublePrecisionFloatShaderOps=0, and d3d12SDKLayers.dll absent. Rust 1.100.0, DXC and DXIL 1.9.2609.5, unoptimized builds with debug info disabled.
  • cargo build --workspace and cargo test --workspace --no-run succeeded.
  • cargo test -p xcl late_release -- --nocapture returned 2 passed, 0 failed, 0 ignored, 0 skips. The existing tests verified that a held resource drains after the queue passes its fence and that a batch drains immediately when there are no queues. Both also passed in the workspace run.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock and returned exit code 101. Across 20 libtest summaries, including doctests, the totals were 857 passed, 18 failed, 42 ignored. The log contains 4 SKIPPED lines. Those skipped paths supply no coverage even where libtest reports the enclosing test as passed.

Failures and skips

  • Library tests accounted for 17 failures. Thirteen reported CreateComputePipelineState error 0x80070057, including FP64 tests. Four reported assertion mismatches in fused F32 overflow, implicit texture LOD, F16 high-half preservation, and pixel-shader wave reductions.
  • The test-title e2e failed check #94. RSSetDepthBiasX(-1000.5) left the top-right pixel blue when the test expected green.
  • The four skip lines covered two wave64-dependent paths, one driver-cache test requiring Windows Developer Mode, and one heap-window fallback test.

Not tested

Wine/D3DMetal and the native release thread without a Wine TEB, a main-branch baseline, retail-title smoke runs, sample-dependent paths, and other GPU vendors. This run establishes Windows behavior for the tested head. A baseline would be needed to attribute the suite failures to the PR.

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 pr1789-suite.log and published this report.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 03:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7151826739) # PR #1789 compatibility verification on STOR-WINLAB Tested commit `2e85970aa5f53c8617985b380e4f35920e6d041c`. The diff initializes the cached `XCL_LATE_RELEASE` value during D3D12.X object adoption, before the release hook can read it. **Tested** - Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175). Adapter wave range 8–32, `DoublePrecisionFloatShaderOps=0`, and `d3d12SDKLayers.dll` absent. Rust 1.100.0, DXC and DXIL 1.9.2609.5, unoptimized builds with debug info disabled. - `cargo build --workspace` and `cargo test --workspace --no-run` succeeded. - `cargo test -p xcl late_release -- --nocapture` returned **2 passed, 0 failed, 0 ignored, 0 skips**. The existing tests verified that a held resource drains after the queue passes its fence and that a batch drains immediately when there are no queues. Both also passed in the workspace run. - `cargo test --workspace --no-fail-fast -- --test-threads=4` ran once under the shared Arc lock and returned exit code 101. Across 20 libtest summaries, including doctests, the totals were **857 passed, 18 failed, 42 ignored**. The log contains **4 `SKIPPED` lines**. Those skipped paths supply no coverage even where libtest reports the enclosing test as passed. **Failures and skips** - Library tests accounted for 17 failures. Thirteen reported `CreateComputePipelineState` error `0x80070057`, including FP64 tests. Four reported assertion mismatches in fused F32 overflow, implicit texture LOD, F16 high-half preservation, and pixel-shader wave reductions. - The test-title e2e failed check #94. `RSSetDepthBiasX(-1000.5)` left the top-right pixel blue when the test expected green. - The four skip lines covered two wave64-dependent paths, one driver-cache test requiring Windows Developer Mode, and one heap-window fallback test. **Not tested** Wine/D3DMetal and the native release thread without a Wine TEB, a main-branch baseline, retail-title smoke runs, sample-dependent paths, and other GPU vendors. This run establishes Windows behavior for the tested head. A baseline would be needed to attribute the suite failures to the PR. **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 `pr1789-suite.log` and published this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1789/head:github-bot/gh-1789'
git switch 'github-bot/gh-1789'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1789'
git switch 'github-bot/gh-1789'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1789'
git switch 'github-bot/gh-1789'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1789'
git switch 'main'
git merge --squash 'github-bot/gh-1789'
git switch 'main'
git merge --ff-only 'github-bot/gh-1789'
git switch 'main'
git merge 'github-bot/gh-1789'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.