D3D12.X: deduplicate concurrent stand-in creation and harden shell COM methods #2369
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2369
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2369"
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?
@Decodere on GitHub · 2026-11-25 16:50 UTC · original
Decodere:fix-625a0f3-standin-race-com→main· +160 −29 · 1 files · 1 commits · openPart of #1333
Part of #1566
What is in it
Follow-up to
625a0f3in shared stand-in pipelines (crates/xcl/src/hle/d3d12x/standin.rs):shell()misses (shell):SHAREDafter a miss and out-of-lockmake(), re-check whether another thread already populatedkey. If so, drop the lock, immediatelyunrefthe redundant driver pipeline outsideSHARED.lock(), and reuse the winningArc<Shared>without double-AddRefingkey.root_signatureor emitting duplicate power-of-two log lines.query_interface(is_pipeline_iid,query_interface):*ppvwhenppvis non-null, including whenriidis null.ID3D12PipelineStatehierarchy IIDs implemented byShell's vtable (IUnknown,ID3D12Object,ID3D12DeviceChild,ID3D12Pageable,ID3D12PipelineState): validate with the underlying driver pipeline'sQueryInterface,unref(out)the driver pointer (zero refcount leak), and returnthiswithadd_ref(this). Do not requireout as usize == pipeline, because reald3d12.dllpipeline objects return a distinct subobject pointer forIUnknown/ID3D12Object/ID3D12DeviceChild/ID3D12Pageablewithout the debug layer (caught by@fromthemoonx). ReturnE_NOINTERFACEfor any non-pipeline interface.set_private_datavalidation and implement per-shellset_name(set_private_data,set_private_data_interface,set_name):guid.is_null()or(size != 0 && data.is_null())withE_INVALIDARGwithout erasing existing private data, and clear the entry whensize == 0(regardless of whetherdatais null).nameinset_namewithE_INVALIDARGand store the NUL-terminated UTF-16 name per shell underWKPDID_D3DDebugObjectNameW(keepingaddrefunder thedatalock inget_private_datato avoid TOCTOU UAF).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 torefs == 0, androot_signaturerefcount stays exact.query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riid: checks null-riid*ppvzeroing, all five single-inheritance IIDs (including distinct subobject pointer forIUnknownreleasing 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 computeID3D12PipelineState, wraps it withshell(), and verifiesS_OK+out == sfor all five hierarchy IIDs (IUnknown,ID3D12Object,ID3D12DeviceChild,ID3D12Pageable,ID3D12PipelineState) andE_NOINTERFACE+out.is_null()forID3D12DebugCommandList(cleanly skips if no DXC or D3D12/WARP device).set_private_data_validation_and_per_shell_set_name: checks(size != 0, null)preservation,size == 0clearing with non-null pointer, nullset_namerejection, and per-shellWKPDID_D3DDebugObjectNameWUTF-16 round-trip.Tested
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_pipelinekept both driver pipelines alive and double-logged2 driver pipelines,query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riidleft*ppvnon-null on nullriid, andset_private_data_validation_and_per_shell_set_namereturnedS_OKinstead ofE_INVALIDARGfor(size = 4, null).cargo test --release -p xcl --lib hle::d3d12x::standin::tests -- --test-threads=1 --nocaptureat0738c30fatop889ef3e8):6 passed, 0 failed, 0 ignoredon both NVIDIA GeForce RTX 4060 (0.35 s,0skipped) and WARP (0.20 s,0skipped), includingquery_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other.cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocaptureon NVIDIA GeForce RTX 4060, driver621.14, DXC1.9.2609.5):37test binaries,1417 passed, 0 failed, 46 ignored;29pre-existing hardware/debug-layerSKIPPEDlines (0instandin::tests):21no wave64(RTX 4060 is wave32-only),3per-lane form: refused(lower_dxil::testswave32 per-lane),3no D3D12 debug layer/no d3d12SDKLayers.dll,1cannot disable the driver cache(shaders::tests::pso_measurement_compiles_an_exact_synthetic_record),1no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form).Regression run
Base (
origin/main889ef3e8aa7f267323ab4879e735e65da6bcef10):PR head (
0738c30f4cf8705c953d6cab8f06dff1cca5d3ab):Not tested
d3d12SDKLayers.dllis 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 on GitHub · 2026-11-25 17:44 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
9c48d84b46f80849611a7c44ae7c6a5adb381600(clean detached checkout, no local changes).Tested
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 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused 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.hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline,query_interface_rejects_secondary_interfaces_and_zeroes_out_on_null_riid, andset_private_data_validation_and_per_shell_set_name.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 18:50 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@SlopTart on GitHub · 2026-11-25 19:06 UTC · original
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 targetx86_64-pc-windows-gnurun 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_2seed 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.
@Decodere on GitHub · 2026-11-25 20:49 UTC · original
Great catch
@fromthemoonx— fixed in0738c30f!query_interfacestill 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 returnsthis(add_ref(this)) without requiringout == pipeline, so reald3d12.dllsubobject pointers succeed while non-pipeline IIDs still returnE_NOINTERFACE. Addedquery_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_othertesting a real D3D12 computeID3D12PipelineStatewrapped byshell()across all five hierarchy IIDs +ID3D12DebugCommandList(6/0on both RTX 4060 and WARP; workspace1417 passed, 0 failed; paired 60 s smoke1550vs1540frames,0crashes/removals).(Re
@bmjask:KNOWN = 765a30f3-f624-4c6f-a828-ace948622445isID3D12PipelineState::IID, soa_shell_has_the_drivers_interfaces_and_its_own_references_and_private_datapasses on all runs.)@fromthemoonx on GitHub · 2026-11-25 19:40 UTC · original · edited 2026-11-25 21:08 UTC
Rerun on the new head
0738c30: fixed on NVIDIA. The stand-in answers all five pipeline IIDs on a real driver pipeline, and the newquery_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_othercatches the old pointer check.cargo test --workspace --no-fail-fast -- --test-threads=4,0738c30merged ontomain6d12f58(clean)SKIPPEDlines; the new test ran (not skipped) and passed0738c30(base889ef3e)SKIPPEDif out as usize != pipeline { return E_NOINTERFACE; }put back (scratch)real pipeline QI failed for 00000000-0000-0000-C000-000000000046(IUnknown)EnableDebugLayer()and an info-queue dumpstandin::tests::(6 tests) at--test-threads=8, 40 runsFirst run, on
9c48d84: On a real driver pipeline,query_interfacerefusedIUnknown,ID3D12Object,ID3D12DeviceChildandID3D12Pageable(E_NOINTERFACE), whichmainanswers withS_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 returnsthis, 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 withshell(). For each IID it records the shell's QI result, and whether the driver's own QI returned the same pointer as the PSO:main, eitherIUnknownE_NOINTERFACE(driver: other pointer)E_NOINTERFACE(other pointer)S_OKID3D12Object/ID3D12DeviceChild/ID3D12PageableE_NOINTERFACE(other pointer)S_OK(same pointer)S_OKID3D12PipelineStateS_OKS_OKS_OKID3D12DebugCommandList(not a pipeline IID)E_NOINTERFACEE_NOINTERFACEE_NOINTERFACESo without the debug layer, a title's
QueryInterfaceforIUnknown, or forID3D12Object(forSetName), on a stand-in pipeline now fails. Answering the five pipeline IIDs withthiswhenever the driver's QI succeeds, without comparing pointers, would keepmain'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 ontomain2898511(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.cargo test --workspace --no-fail-fast -- --test-threads=4, mergedSKIPPEDlines (no wave64, refused per-lane forms)9c48d84SKIPPEDconcurrent_shell_miss_reuses_winner_and_releases_loser_pipelinealone, 40 runs;standin::tests::(5 tests), 10 runsif let Some(existing) = None::<Arc<Shared>>)standin.rs:399Not 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.
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
@ClosetPie107 on GitHub · 2026-11-26 06:49 UTC · original
AMD RDNA4 / Linux (Proton Experimental) test report on head
0738c30f(merged cleanly ontomainb49be183):Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnuIsolated unit tests (
mainb49be183+ #23690738c30f, 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,
mainb49be183+ #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressingApast menus):exit=0), 0 crashes, 0 device removals,2,014PresentXframes,131,072translated draws,660,943dispatches (44,546chained split-compute dispatches),102,631Opus packets (0 errors).Not tested
AI use
main, ran the Proton unit tests and combined retail run on this machine, and drafted this report.@bmjask on GitHub · 2026-11-25 20:20 UTC · original · reviewed
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.
@oni-swr on GitHub · 2026-11-26 07:47 UTC · original
Independent amd-win test report for head
0738c30f4cf8705c953d6cab8f06dff1cca5d3ab(clean detached checkout, no local changes) against its exact parent889ef3e8aa7f267323ab4879e735e65da6bcef10. Claimed in #1607.Tested
stable-x86_64-pc-windows-msvc), debug build,-j 4, synthetic fixtures only.cargo test -p xcl --lib standin -- --test-threads=1at the head: 7 passed, 0 failed, 0 ignored, noSKIPPEDlines. This includesquery_interface_on_real_d3d12_pipeline_accepts_hierarchy_and_rejects_other(it ran on the real driver pipeline) andconcurrent_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:SKIPPEDlines0738c30f889ef3e8gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722:res[30] = 0x1, CPU0x7fffffff). It is a baseline failure unrelated to this diff, which touches onlyhle/d3d12x/standin.rs. The 4 extra passes at the head match the 4 tests the PR adds.SKIPPEDlines are identical on both sides: 6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu(per-lane form refused) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows). They are not coverage.Not tested
scripts/smoke.ps1regression run and no retail title; no game files were used.AI use
Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report; coordinated by Codex (gpt-6.2-sol).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.