Skip to content

D3D12.X: deduplicate concurrent stand-in creation and harden shell COM methods - #2369

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
Decodere:fix-625a0f3-standin-race-com
Nov 29, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
Decodere:fix-625a0f3-standin-race-com

Conversation

@Decodere

@Decodere Decodere commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1333
Part of #1566

What is in it

Follow-up to 625a0f3 in shared stand-in pipelines (crates/xcl/src/hle/d3d12x/standin.rs):

  1. Deduplicate concurrent shell() misses (shell):
    • On re-locking SHARED after a miss and out-of-lock make(), re-check whether another thread already populated key. If so, drop the lock, immediately unref the redundant driver pipeline outside SHARED.lock(), and reuse the winning Arc<Shared> without double-AddRefing key.root_signature or emitting duplicate power-of-two log lines.
  2. Harden query_interface (is_pipeline_iid, query_interface):
    • Always zero *ppv when ppv is non-null, including when riid is null.
    • Accept only the five single-inheritance ID3D12PipelineState hierarchy IIDs implemented by Shell's vtable (IUnknown, ID3D12Object, ID3D12DeviceChild, ID3D12Pageable, ID3D12PipelineState): validate with the underlying driver pipeline's QueryInterface, unref(out) the driver pointer (zero refcount leak), and return this with add_ref(this). Do not require out as usize == pipeline, because real d3d12.dll pipeline objects return a distinct subobject pointer for IUnknown/ID3D12Object/ID3D12DeviceChild/ID3D12Pageable without the debug layer (caught by @fromthemoonx). Return E_NOINTERFACE for any non-pipeline interface.
  3. Fix set_private_data validation and implement per-shell set_name (set_private_data, set_private_data_interface, set_name):
    • Reject guid.is_null() or (size != 0 && data.is_null()) with E_INVALIDARG without erasing existing private data, and clear the entry when size == 0 (regardless of whether data is null).
    • Reject null name in set_name with E_INVALIDARG and store the NUL-terminated UTF-16 name per shell under WKPDID_D3DDebugObjectNameW (keeping addref under the data lock in get_private_data to avoid TOCTOU UAF).
  4. Regression tests (standin::tests):
    • concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline: barrier-synchronized two-thread race confirming both shells share one driver pipeline, the loser pipeline drops to refs == 0, and root_signature refcount stays exact.
    • query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riid: checks null-riid *ppv zeroing, all five single-inheritance IIDs (including distinct subobject pointer for IUnknown releasing the driver ref cleanly without leaking), and secondary IID rejection.
    • query_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other: builds a real D3D12 compute ID3D12PipelineState, wraps it with shell(), and verifies S_OK + out == s for all five hierarchy IIDs (IUnknown, ID3D12Object, ID3D12DeviceChild, ID3D12Pageable, ID3D12PipelineState) and E_NOINTERFACE + out.is_null() for ID3D12DebugCommandList (cleanly skips if no DXC or D3D12/WARP device).
    • set_private_data_validation_and_per_shell_set_name: checks (size != 0, null) preservation, size == 0 clearing with non-null pointer, null set_name rejection, and per-shell WKPDID_D3DDebugObjectNameW UTF-16 round-trip.

Tested

  • Pre-fix failing-first (cargo test -p xcl --lib hle::d3d12x::standin::tests -- --test-threads=1 --nocapture): 2 passed, 3 failed — concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline kept both driver pipelines alive and double-logged 2 driver pipelines, query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riid left *ppv non-null on null riid, and set_private_data_validation_and_per_shell_set_name returned S_OK instead of E_INVALIDARG for (size = 4, null).
  • Post-fix (cargo test --release -p xcl --lib hle::d3d12x::standin::tests -- --test-threads=1 --nocapture at 0738c30f atop 889ef3e8): 6 passed, 0 failed, 0 ignored on both NVIDIA GeForce RTX 4060 (0.35 s, 0 skipped) and WARP (0.20 s, 0 skipped), including query_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other.
  • Full release workspace (cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture on NVIDIA GeForce RTX 4060, driver 621.14, DXC 1.9.2609.5): 37 test binaries, 1417 passed, 0 failed, 46 ignored; 29 pre-existing hardware/debug-layer SKIPPED lines (0 in standin::tests): 21 no wave64 (RTX 4060 is wave32-only), 3 per-lane form: refused (lower_dxil::tests wave32 per-lane), 3 no D3D12 debug layer / no d3d12SDKLayers.dll, 1 cannot disable the driver cache (shaders::tests::pso_measurement_compiles_an_exact_synthetic_record), 1 no heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form).

Regression run

Base (origin/main 889ef3e8aa7f267323ab4879e735e65da6bcef10):

xcl-smoke v1
commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1550 (PresentX 1550)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13981 MB

PR head (0738c30f4cf8705c953d6cab8f06dff1cca5d3ab):

xcl-smoke v1
commit: 0738c30f4cf8705c953d6cab8f06dff1cca5d3ab
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13982 MB

Not tested

  • Wave64-capable hardware (RTX 4060 is wave32-only) and AMD/Intel GPUs.
  • D3D12 debug layer tests (d3d12SDKLayers.dll is not installed on this host).

AI use

Google Antigravity (Gemini 4 Neon) assisted with implementing the concurrency deduplication and COM method hardening in standin.rs, writing the mock-COM regression tests, and running the workspace and smoke verification suite.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 9c48d84b46f80849611a7c44ae7c6a5adb381600 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1285 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • All 3 PR tests passed: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riid, and set_private_data_validation_and_per_shell_set_name.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 9c48d84b46f80849611a7c44ae7c6a5adb381600
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1601 (PresentX 1601)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14216 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@Decodere Decodere closed this Nov 25, 2026
@Decodere Decodere reopened this Nov 25, 2026
@Decodere Decodere closed this Nov 25, 2026
@Decodere Decodere reopened this Nov 25, 2026
@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).
suite: 145/3 = the three known baseline failures on this lane (fuzz_validate_and_gpu_2 seed 1003, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed). Targeted runs of the three new shell tests (concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riid, set_private_data_validation_and_per_shell_set_name): 3 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@fromthemoonx

fromthemoonx commented Nov 25, 2026 •

Copy link
Copy Markdown

Rerun on the new head 0738c30: fixed on NVIDIA. The stand-in answers all five pipeline IIDs on a real driver pipeline, and the new query_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other catches the old pointer check.

result
cargo test --workspace --no-fail-fast -- --test-threads=4, 0738c30 merged onto main 6d12f58 (clean) 1427 passed, 0 failed, 46 ignored; 25 SKIPPED lines; the new test ran (not skipped) and passed
same at the head 0738c30 (base 889ef3e) 1417 passed, 0 failed, 46 ignored; 25 SKIPPED
the new real-pipeline test with if out as usize != pipeline { return E_NOINTERFACE; } put back (scratch) fails 3 of 3: real pipeline QI failed for 00000000-0000-0000-C000-000000000046 (IUnknown)
the new test with a scratch EnableDebugLayer() and an info-queue dump passes, 0 stored messages
the new test, 3 runs; the race test alone, 40 runs; standin::tests:: (6 tests) at --test-threads=8, 40 runs 3 / 40 / 40, no failures

First run, on 9c48d84: On a real driver pipeline, query_interface refused IUnknown, ID3D12Object, ID3D12DeviceChild and ID3D12Pageable (E_NOINTERFACE), which main answers with S_OK. The suite passed on NVIDIA, and the new race test passed 40 of 40 and failed without the re-check.

Why: d3d12.dll's pipeline object answers those four IIDs with a pointer other than the pipeline's own, so the check if out as usize != pipeline { return E_NOINTERFACE; } (standin.rs:154) rejects them. The new tests use fake COM objects whose QI returns this, so they don't see it. I made a scratch test (not pushed) that builds a real compute PSO on the RTX 3060 and wraps it with shell(). For each IID it records the shell's QI result, and whether the driver's own QI returned the same pointer as the PSO:

IID PR, no debug layer PR, debug layer on main, either
IUnknown E_NOINTERFACE (driver: other pointer) E_NOINTERFACE (other pointer) S_OK
ID3D12Object / ID3D12DeviceChild / ID3D12Pageable E_NOINTERFACE (other pointer) S_OK (same pointer) S_OK
ID3D12PipelineState S_OK S_OK S_OK
ID3D12DebugCommandList (not a pipeline IID) E_NOINTERFACE E_NOINTERFACE E_NOINTERFACE

So without the debug layer, a title's QueryInterface for IUnknown, or for ID3D12Object (for SetName), on a stand-in pipeline now fails. Answering the five pipeline IIDs with this whenever the driver's QI succeeds, without comparing pointers, would keep main's behaviour and still refuse other interfaces. With the debug layer on, the info queue had 0 messages.

Tested: 9c48d84, and the same commit merged onto main 2898511 (clean). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.

result
cargo test --workspace --no-fail-fast -- --test-threads=4, merged 1366 passed, 0 failed, 46 ignored; 25 SKIPPED lines (no wave64, refused per-lane forms)
same at the head 9c48d84 1287 passed, 0 failed, 46 ignored; 25 SKIPPED
concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline alone, 40 runs; standin::tests:: (5 tests), 10 runs 40 of 40; 10 of 10
the same test with the re-check removed (scratch: if let Some(existing) = None::<Arc<Shared>>) fails 5 of 5 at standin.rs:399

Not tested: a title, a release build, AMD / Intel (another driver's objects may answer these IIDs differently).

AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch QI test, and wrote this report.

…M methods

Part of xcl-dev#1333
Part of xcl-dev#1566

Follow-up to 625a0f3 in shared stand-in pipelines (`hle/d3d12x/standin.rs`):

- In `shell()`, re-check `SHARED` on re-lock after concurrent `make()` misses
  so losing threads reuse the winning `Arc<Shared>`, skip double-AddRefing
  `root_signature`, suppress duplicate power-of-two log lines, and release the
  redundant driver pipeline outside `SHARED.lock()`.
- In `query_interface()`, zero `*ppv` even when `riid` is null, accept only the
  five single-inheritance `ID3D12PipelineState` IIDs (`IUnknown`,
  `ID3D12Object`, `ID3D12DeviceChild`, `ID3D12Pageable`, `ID3D12PipelineState`),
  validate via the underlying pipeline's `QueryInterface` and release its
  returned pointer (allowing real `d3d12.dll` subobject pointers distinct from
  `pipeline` for base IIDs), and return `E_NOINTERFACE` for any other interface.
- In `set_private_data()`, reject `(size != 0, data.is_null())` with
  `E_INVALIDARG` without erasing existing data and clear the entry when
  `size == 0`; in `set_name()`, reject null with `E_INVALIDARG` and store the
  NUL-terminated UTF-16 name per shell under `WKPDID_D3DDebugObjectNameW`.
- Add unit tests covering concurrent `shell()` races, `QueryInterface` on both
  synthetic tearoff/secondary mocks and a real D3D12 compute
  `ID3D12PipelineState`, `SetPrivateData` validation/clearing, and per-shell
  `SetName` round-trips.

Assisted-by: Google Antigravity (Gemini 4 Neon)

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: head 9c48d84 appears to make an existing unit test deterministically fail. is_pipeline_iid at standin.rs:137-139 allows only five D3D12 IIDs, and query_interface returns E_NOINTERFACE before forwarding any other IID (:141-146). But the existing a_shell_has_the_drivers_interfaces_and_its_own_references_and_private_data test still expects query_interface(s, &KNOWN, &mut out) == S_OK at :350-359; KNOWN (765a30f3-f624-4c6f-a828-ace948622445) is none of the five allowed IIDs. Please update/remove that legacy assertion to use a pipeline IID, or preserve the intended previous QI behavior, and rerun the tests from the current head.

@Decodere
Decodere force-pushed the fix-625a0f3-standin-race-com branch from 9c48d84 to 0738c30 Compare November 25, 2026 20:49
@Decodere

Copy link
Copy Markdown
Contributor Author

Great catch @fromthemoonx — fixed in 0738c30f!

query_interface still gates on the five single-inheritance pipeline IIDs (IUnknown, ID3D12Object, ID3D12DeviceChild, ID3D12Pageable, ID3D12PipelineState), validates with the driver pipeline, releases the returned driver pointer (unref(out)), and returns this (add_ref(this)) without requiring out == pipeline, so real d3d12.dll subobject pointers succeed while non-pipeline IIDs still return E_NOINTERFACE. Added query_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other testing a real D3D12 compute ID3D12PipelineState wrapped by shell() across all five hierarchy IIDs + ID3D12DebugCommandList (6/0 on both RTX 4060 and WARP; workspace 1417 passed, 0 failed; paired 60 s smoke 1550 vs 1540 frames, 0 crashes/removals).

(Re @bmjask: KNOWN = 765a30f3-f624-4c6f-a828-ace948622445 is ID3D12PipelineState::IID, so a_shell_has_the_drivers_interfaces_and_its_own_references_and_private_data passes on all runs.)

@ClosetPie107

Copy link
Copy Markdown

AMD RDNA4 / Linux (Proton Experimental) test report on head 0738c30f (merged cleanly onto main b49be183):

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv b540c8a2 + relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu

Isolated unit tests (main b49be183 + #2369 0738c30f, debug, --test-threads=1):

  • xcl.exe hle::d3d12x::standin:: -- --test-threads=1: 6 passed, 0 failed, 0 ignored (0 skipped).

Combined 300 s retail sanity run (release, main b49be183 + #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressing A past menus):

  • Completed full 300 s (exit=0), 0 crashes, 0 device removals, 2,014 PresentX frames, 131,072 translated draws, 660,943 dispatches (44,546 chained split-compute dispatches), 102,631 Opus packets (0 errors).

Not tested

AI use

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent amd-win test report for head 0738c30f4cf8705c953d6cab8f06dff1cca5d3ab (clean detached checkout, no local changes) against its exact parent 889ef3e8aa7f267323ab4879e735e65da6bcef10. Claimed in #1607.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Windows 11 Pro 26200, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug build, -j 4, synthetic fixtures only.
  • cargo test -p xcl --lib standin -- --test-threads=1 at the head: 7 passed, 0 failed, 0 ignored, no SKIPPED lines. This includes query_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other (it ran on the real driver pipeline) and concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline. The concurrent test also passed 20 of 20 repeated single-test runs.
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
commit passed failed ignored SKIPPED lines
head 0738c30f 1416 1 46 7
parent 889ef3e8 1412 1 46 7
  • The only failure at both commits is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff). It is a baseline failure unrelated to this diff, which touches only hle/d3d12x/standin.rs. The 4 extra passes at the head match the 4 tests the PR adds.
  • The 7 SKIPPED lines are identical on both sides: 6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu (per-lane form refused) and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). They are not coverage.

Not tested

  • No scripts/smoke.ps1 regression run and no retail title; no game files were used.
  • Other vendors and wave32-only GPUs.
  • No code review is included here.

AI use
Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report; coordinated by Codex (gpt-6.2-sol).

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 0738c30

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 6089122
head: 0738c30
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1469 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: none blocking. The loser of a creation race releases its pipeline outside the lock and the root signature is not AddRef'd twice; the race test fails without the fix. The QueryInterface list covers the shell's vtable and zeroes the out pointer first. Scope: two changes in one PR (the deduplication, and the COM method changes including a SetName that now stores the name).
performance: runs only when a stand-in pipeline is created and saves duplicate driver pipelines; a name per shell costs a little memory; nothing per frame (reasoned).
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).

@KOLESNiii

Copy link
Copy Markdown
Contributor

merge-check claim
head: 0738c30

@KOLESNiii

Copy link
Copy Markdown
Contributor

merge-check
base: 2c717a0
head: 0738c30
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1470 passed, 0 failed, 47 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: none. The suite ran on this PC at the same time as six other PRs' suites, in one queued job.
review: none. Whole diff read (standin.rs: shell() concurrent-miss path, query_interface, set_private_data(_interface), set_name, 4 tests). The losing driver pipeline is released outside the lock and the winner reused; root-signature addref now only for the inserted entry. QI now refuses IIDs outside the 5-interface pipeline chain (before it returned the shell's vtable for any IID the driver accepted).
performance: reasoned, not measured: stand-in creation path only; one extra map lookup under the existing lock.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 1a8e74a2c0a82fc7de0c1deb46dc9b259696bffa (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).

@Prime1997 Prime1997 added the test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md) label Nov 29, 2026
@Prime1997
Prime1997 merged commit 7b8e20e into xcl-dev:main Nov 29, 2026
5 checks passed
@fromthemoonx

Copy link
Copy Markdown

@Decodere after the merge, this PR's race test fails on main: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline fails 30 of 30 alone on main 53e85fb, and from this merge commit 7b8e20e6 on. It passes at this PR's head 0738c30.

standin.rs:459: assertion `left == right` failed
  left: (0, 1, 1)
 right: (0, 0, 1)

The cause is the test's expectation, not the dedup. Since this branch was made, main sends the last shell's driver pipeline through late_release::hold_pipeline (standin.rs:384: "released once the queues are past the lists that may bind it"). So right after both release calls the winner still holds one reference. With XCL_LATE_RELEASE=0 the test passes 3 of 3. The test next to it (a_driver_pipeline_let_go_is_released_once_the_queues_are_past_it) drains let_go_taken() before it checks the counts; doing the same here before the last assert_eq! should fix it.

RTX 3060 (driver 610.88), Rust 1.100.0, debug. The rest of main's suite passes here (2792 passed, this 1 failed, 49 ignored).

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment.

dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 30, 2026
Takes the upstream sync after 5b0d5fa. Headline changes:
- 8c9e83f/e618b742/16f2f5c1 (xcl-dev#3263): compact DXIL form for branch-heavy
  programs of 2000+ blocks, splitting repeated memory ops and dead SGPR
  stores; compact block PC/literal plumbing in lower.rs and kernel.rs.
- 45dbd47 (xcl-dev#2341): per-lane compute size caps (MAX_INSTS 20,000,
  MAX_DXIL_BYTES 1 MiB) so giant compute programs fall back to compact.
- a7f059b (xcl-dev#2148): SSA trivial-phi/0-pred-phi fixes; 1933324 (xcl-dev#2060):
  reject image_gather4h/8h instead of a 2x2 Gather; 0738c30 (xcl-dev#2369):
  dedupe concurrent stand-in creation and harden shell COM; e9d7aef
  (xcl-dev#2398): saturate 16-bit integer valu16 with CLAMP=1; 6376287 (xcl-dev#1878)
  dxbc digest rounds.

Conflict resolutions:
| file | resolution |
| --- | --- |
| gpu/dxil/lower_wide.rs | took upstream's 32-bit exact CLAMP lowering for the 16-bit integer adds/subs/mads and deleted our T-021 64-bit signed duplicate; kept our v_mul_lo_u16 CLAMP arm (upstream does not cover it) and all our T-124 wave64/OMOD changes; removed the now-unused sat_i16 helper from prelude.rs |
| gpu/recomp/lower_dxil.rs | took upstream's MAX_INSTS/MAX_DXIL_BYTES cap and its size check; kept our marks thread-local propagation (marks::enabled / set_thread) in the per-lane thread |
| gpu/dxil/core_tests.rs | not a merge conflict, but the direct CLAMP test asserted the removed lowering: now expects 3x icmp sgt/slt i32 for valu16, no IMax/IMin, and 3x icmp sgt/slt i64 for the wide signed mads |
| hle/d3d12x/standin.rs | auto-merged upstream's concurrent dedupe and COM hardening; kept our mainline's immediate unref in Drop (our late_release exposes hold(), not hold_pipeline()) and upstream's new tests |
| compact.rs, compact_tests.rs, recomp/ssa.rs, lower_image.rs, kernel.rs, lower.rs | upstream's changes; lower_image keeps our watertight ray/triangle alongside upstream's gather4h/8h rejection |

Build (only possible target for this crate; native Linux fails on
testgame-mw's raw-dylib and retour's stdcall):
  cargo build --release --workspace --locked --target x86_64-pc-windows-gnu
  Finished in 55.12s; 47.01s incremental after the dead-helper removal.

Focused lib tests (Windows test binary under Wine, builtin DXGI, no GPU):
  gpu::dxil:   309 passed; 0 failed; 3 ignored; 80 SKIPPED
  gpu::recomp: 548 passed; 0 failed; 20 ignored; 320 SKIPPED
  hle::d3d12x::standin: 6 passed; 0 failed; 1 SKIPPED (no GPU or WARP)

Direct sweep (xcl.exe under Wine, --sample 0 --threads 8):
  CS 1636/1636  GS 195/390  MS 8724/8724  PS 9511/9511  VS 2184/2184
  total 22250/22445; the 195 unsupported are split-wave64 geometry (ES
  phase exchanges at group barriers). xcl-dev#2060 moved nothing here: the
  corpus has no image_gather4h/8h program in the direct set.
  coverage_gate.py --run-json --skip-recomp: "coverage gate: no
  regressions" (exit 0); baseline stays 22250/22445.

Upstream commits keep their authors; this merge commit only records the
resolutions.
@afpruivo

Copy link
Copy Markdown

This PR's new test hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline fails on main since the merge, every run, also on the no-GPU CI (seen on #2590's CI run, whose diff doesn't touch D3D12.X).

  • At this PR's head 7b8e20e6^2: passes.
  • At the merge 7b8e20e6 and at main 53e85fb1: fails 6 of 6 runs (cargo test --release -p xcl --lib concurrent_shell_miss_reuses_winner):
    panicked at crates\xcl\src\hle\d3d12x\standin.rs:459:9:
    assertion `left == right` failed
      left: (0, 1, 1)
     right: (0, 0, 1)
    
    So after both shells are released one of the two pipelines still holds a reference. The assertion before it (winner 1, loser 0, root signature 2) passes.

So it comes from the interaction with something main gained between this PR's base and the merge; I didn't look for which change, and I don't know whether it is a real leak or the test's expectation.

RTX 3090, 621.40, Windows 11 26300, rustc 1.99.1, release.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

Prime1997 pushed a commit that referenced this pull request Nov 30, 2026
concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (#2369)
expected the winner's driver pipeline to be released with the last
shell. On main the last shell lets it go through late_release (it is
held until the queues are past the lists that may bind it), so the
test found one reference left and failed on every run. The test now
keeps what let_go is given on its thread, as the other stand-in tests
do, checks that it is the winner's pipeline, and releases it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.