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

Open
vakaobr wants to merge 1 commit from upstream-pr/1789 into main
vakaobr commented 2026-11-24 20:44:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-24T20:44:47Z.


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://github.com/xcl-dev/xcl/issues/258#issuecomment-7137896678; the rest (deferring a Release that arrives on a host thread) stays a separate PR, since no test here needs it yet (https://github.com/xcl-dev/xcl/issues/258#issuecomment-7143690405).

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.
<!-- greyfinch-sync:ivall/xcl:issue:5480027415 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789). Originally posted by [vakaobr](https://github.com/vakaobr) on 2026-11-24T20:44:47Z. --- 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://github.com/xcl-dev/xcl/issues/258#issuecomment-7137896678; the rest (deferring a `Release` that arrives on a host thread) stays a separate PR, since no test here needs it yet (https://github.com/xcl-dev/xcl/issues/258#issuecomment-7143690405). **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.
eizispark commented 2026-11-24 21:09:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T21:04:45Z.


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).
<!-- greyfinch-sync:ivall/xcl:comment:7144446157 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7144446157). Originally posted by [eizispark](https://github.com/eizispark) on 2026-11-24T21:04:45Z. --- ### 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).
DavidM1911 commented 2026-11-25 00:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:41:50Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7147693339 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7147693339). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T23:41:50Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
JJAutoCompare commented 2026-11-25 04:10:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T03:20:43Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7151826739 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7151826739). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T03:20:43Z. --- # 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.
bmjask commented 2026-11-25 20:58:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:58:37Z.

Review: COMMENTED


No confirmed source defect found. Initializing late-release configuration on the Wine adoption thread preserves Windows behavior and addresses the D3DMetal host-thread situation. Merge readiness needs evidence reconciliation: independent reports show a clean suite/smoke, but the visible PR-description check fails. Residual validation includes no automated host-thread-without-TEB or D3DMetal integration regression, plus no NVIDIA/Intel Windows smoke.

<!-- greyfinch-sync:ivall/xcl:review:6064895797 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789#pullrequestreview-6064895797). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:58:37Z. **Review:** COMMENTED --- No confirmed source defect found. Initializing late-release configuration on the Wine adoption thread preserves Windows behavior and addresses the D3DMetal host-thread situation. Merge readiness needs evidence reconciliation: independent reports show a clean suite/smoke, but the visible PR-description check fails. Residual validation includes no automated host-thread-without-TEB or D3DMetal integration regression, plus no NVIDIA/Intel Windows smoke.
github-actions[bot] commented 2026-11-30 08:40:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:40:05Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7273192897 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7273192897). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:40:05Z. --- 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.
Foniass commented 2026-12-01 06:47:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:47:35Z.


Triage (#1607) – head a0087f2

Not on main: late_release::enabled() is still first read in res_release. #2445 and #2498 are stacked on this PR. #2445's bottom commit (9ac7d636) is this same change rebased, and #2498 is on top of #2445. They are not duplicates of it.
No problems found in the diff. The failing check is PR description; Build and test is green.
Recommendation: keep open.

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

<!-- greyfinch-sync:ivall/xcl:comment:7303281005 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1789#issuecomment-7303281005). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:47:35Z. --- **Triage (#1607)** – head a0087f2 Not on main: `late_release::enabled()` is still first read in `res_release`. #2445 and #2498 are stacked on this PR. #2445's bottom commit (9ac7d636) is this same change rebased, and #2498 is on top of #2445. They are not duplicates of it. No problems found in the diff. The failing check is `PR description`; `Build and test` is green. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1789:upstream-pr/1789'
git switch 'upstream-pr/1789'

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