Repository navigation
D3D12.X: deduplicate concurrent stand-in creation and harden shell COM methods - #2369
Conversation
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested: current PR head merged onto current 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. |
|
Rerun on the new head
First run, on Why: d3d12.dll's pipeline object answers those four IIDs with a pointer other than the pipeline's own, so the check
So without the debug layer, a title's Tested:
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
left a comment
There was a problem hiding this comment.
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.
9c48d84 to
0738c30
Compare
|
Great catch
(Re |
|
AMD RDNA4 / Linux (Proton Experimental) test report on head Hardware & environment
Isolated unit tests (
Combined 300 s retail sanity run (release,
Not tested
AI use
|
|
Independent amd-win test report for head Tested
Not tested
AI use |
|
merge-check claim |
|
merge-check |
|
merge-check claim |
|
merge-check |
|
@Decodere after the merge, this PR's race test fails on The cause is the test's expectation, not the dedup. Since this branch was made, RTX 3060 (driver 610.88), Rust 1.100.0, debug. The rest of AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. |
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.
|
This PR's new test
So it comes from the interaction with something 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. |
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>
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):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.