Skip to content

D3D12.X: add depth+UAV color twins, format-aliased placed texture copies, and dual-twin UAV barriers - #1989

Open
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/lit-world-d3d12x-v2
Open

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/lit-world-d3d12x-v2

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Adds two D3D12.X translation layers for console texture behaviors not natively allowed on PC D3D12:

  1. Depth+UAV shadow/color twins (depth_uav.rs): tracks console depth-stencil textures created with ALLOW_UNORDERED_ACCESS (including CreatePlacedResource #29 via dev_create_placed_resource_x), creates typeless/UAV-compatible color (and optional stencil) twin resources (TwinPlan, plan_for_console_format), redirects CreateUnorderedAccessView to the twin (resolve_uav, integrating uav_companion_srv + null_uav_desc and pointing slot.pc_srv at the twin resource), synchronizes dirty per-subresource planes across both legacy ResourceBarrier (filter_transition, on_uav_barrier), Enhanced Barriers (#146 D3D12_BARRIER_GROUP texture & global barriers in filter_enhanced_barriers), wildcard global UAV barriers (on_global_uav_barrier), and DSV binds/clears (before_bind_dsv, on_clear_dsv, keeping STATE_COMMON targets in legal DEPTH_READ/DEPTH_WRITE via note_dsv flags and unifying RowPitch = max(src_pitch, dst_pitch) across 2-plane copy_plane_through_buffer), emits post-DepthToTwin UAV barriers, and restores internal-pass graphics/compute root signatures, PSO state, and dynamic depth bias (restore_after_internal_pass).
  2. Format-aliased placed texture copies (format_alias.rs): tracks aliased placed textures at overlapping GPU addresses with per-subresource state tracking (COMPUTE_VALID_STATES = 0xC48), copies/synchronizes between incompatible formats via RAII OwnedCopyLoc buffer-through passes (copy_one_subresource_through_buffer with max(src_pitch, dst_pitch) pitch alignment, try_copy_texture_region), and routes evicted/orphaned descriptors and heaps through late_release::hold (is_adopted-guarded).

Part of #1833.

What is in it

  • crates/xcl/src/hle/d3d12x/depth_uav.rs & mod.rs: TwinPlan / DepthSyncKind / PlaneMask / SyncOp per-subresource state machine (filter_enhanced_barriers, on_global_uav_barrier, note_dsv, pc_states_depth, pc_states_stencil, split_uav_*, copy_direct_subs, transition_plane_subs, on_uav_barrier), post-DepthToTwin UAV barrier, late_release::hold teardown, plus unit & WARP GPU tests (depth_uav::tests, including enhanced_barriers_handle_texture_subresources_uav_and_discard and gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test).
  • crates/xcl/src/hle/d3d12x/format_alias.rs: placed texture alias tracking (list_reset), RAII OwnedCopyLoc buffer-through sync (max(src_pitch, dst_pitch)), COMPUTE_VALID_STATES = 0xC48, element byte width / block-scaled dimension checks in try_copy_texture_region, and unit tests in format_alias::tests.
  • crates/xcl/src/hle/d3d12x/bind.rs, device_x.rs, late_release.rs, list_x.rs, real.rs: rs_cs + rs_gfx restoration (restore_after_internal_pass), is_adopted-guarded late_release::drain_known, dev_create_placed_resource_x + dev_create_uav_x integration (#1914 companion SRV + slot.pc_srv twin SRV), and Enhanced Barrier (#146) / UAV (#26) routing in list_x.rs.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), WARP (XCL_ADAPTER=warp, XCL_D3D12_DEBUG=1), rebased cleanly onto 96331383 (51ee197c).
  • XCL_ADAPTER=warp cargo test -p xcl --lib "hle::d3d12x::" -- --test-threads=4 --skip pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa (2 consecutive runs): 214 passed, 0 failed, 2 ignored (--skip excludes only pre-existing main test conflict fixed separately in Tests: align device_x UAV strip and pso cache marker tests with main #2233).
  • XCL_ADAPTER=warp XCL_D3D12_DEBUG=1 cargo test -p xcl --lib -- --nocapture --test-threads=1 "hle::d3d12x::depth_uav" "hle::d3d12x::format_alias": 9 passed, 0 failed (0.09s, 0 D3D12 debug errors, including enhanced_barriers_handle_texture_subresources_uav_and_discard and gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test).

Regression run

  • Standalone scripts/smoke.ps1 pair on 51ee197c vs 96331383 has not been run yet. AMD and NVIDIA reviewers are invited to test on 51ee197c vs 96331383 (including scripts/smoke.ps1, depth_uav/format_alias GPU tests, and world lighting/depth-UAV workloads) and post results in the comments.

Not tested

  • 60 s scripts/smoke.ps1 pair on 51ee197c, full cargo test --workspace suite on 51ee197c, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation, WARP debug-layer diagnostics, rebase onto 96331383, and unit/GPU tests; the author reviewed the diff and test output.

@gsucristo

Copy link
Copy Markdown
Contributor

Technical review findings:

Blocking

  1. Guaranteed COM refcount leak on every buffer-through copy (depth_uav.rs:873-899 copy_plane_through_buffer, format_alias.rs:696-722 copy_one_subresource_through_buffer): Both populate D3D12_TEXTURE_COPY_LOCATION::pResource with ManuallyDrop::new(Some(res.clone())) (AddRef), then call std::mem::forget(...) without ManuallyDrop::drop. This leaks +1 ref on src, +1 ref on dst, and +2 refs on the per-list CopyScratch buffer per subresource per copy, preventing res_release cleanup and leaking VRAM monotonically.
  2. Missing UAV barrier after FullscreenPass DepthToTwin compute dispatch (depth_uav.rs:1429-1438 execute_syncs, list_x.rs:3857-3861 resource_barrier_x): resource_barrier_x emits the global UAV barrier before depth_uav::execute_syncs. In DepthToTwin (FullscreenPass), the compute shader writes twin_res via UAV while twin_res stays in UNORDERED_ACCESS and returns without a UAV barrier on twin_res, racing subsequent title compute dispatches.
  3. restore_after_internal_pass clobbers PC root signatures, root parameters, and dynamic depth-bias PSO state (list_x.rs:134-147, depth_uav.rs:1317-1336, 1423-1435): FullscreenPass calls SetGraphicsRootSignature/SetComputeRootSignature and SetPipelineState on the PC list (invalidating bound root parameters), but restore_after_internal_pass doesn't restore the title's PC root signature/root args or handle using_fallback_pso/pso_dirty/RSSetDepthBiasX.
  4. Multi-subresource barrier corruption & StateBefore mismatches (depth_uav.rs:197-198, 563-642, 763-774, 802-827):
    • Entry tracks only one pc_state_depth/pc_state_stencil per plane instead of per subresource, so a single-subresource barrier transitions all 0..per_plane subresources.
    • entering_uav sets before_depth/before_stencil to the title's before instead of prev_d/prev_s.
    • In before_bind_dsv, PlaneMask::Both transitions both planes to e.pc_state_depth without updating e.pc_state_stencil.
  5. GPU UAF on unadopted pass descriptor heaps (depth_uav.rs:1128, 1147, 1179, 328-346): pass_dsv_heap and pass_srv_uav_heap are created via orig_fn(dev_raw, 14) (bypassing late_release), so depth_uav::forget drops them immediately even if a command list that bound them is still in flight on the GPU.
  6. Invalid RENDER_TARGET state allowed on COMPUTE lists (format_alias.rs:755 sync_pair): The non-DIRECT guard st & !0xC4F != 0 permits 0x4 (RENDER_TARGET), 0x2 (INDEX_BUFFER), and 0x1 (VERTEX_AND_CONSTANT_BUFFER), which are illegal on COMPUTE command lists.

Major

  • placed_uavs/placed_srvs in format_alias.rs own ID3D12Resources permanently (never evicted on forget or VA reuse), and on_uav_barrier copies every PlacedUav pair on the device on global bind::activity() changes.
  • note_title_transition returns early when ACTIVE_PAIRS == 0 (leaving pc_state stale for textures that transitioned before their alias peer was created) and ignores subresource / split-barrier BEGIN_ONLY flags.
  • try_copy_texture_region skips can_copy_through_buffer and only compares rows/RowPitch/Depth, which can silently alias incompatible bytes-per-texel formats that share the same 256-byte-aligned RowPitch.
  • dev_create_uav_x (real.rs:2435-2449) creates the paired SRV (slot.pc_srv) on the original depth res rather than uav_res (twin_res).

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 3443fd3 (on its base 8c4a46a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 991 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: twin_plans_cover_console_depth_formats, uav_format_and_plane_classification, state_machine_handles_split_and_async_compute_transitions, uav_barrier_returns_zero_for_untracked_resources, r32_uint_and_r9g9b9e5_alias_needs_buffer_through, placed_uav_and_srv_descs_are_sanitized, alias_table_links_in_both_creation_orders.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1001 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 7994cd1 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run for this PR: head 3443fd3, based on main 80f4819. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, in one batch with the main run.

main 80f4819:

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1588 (PresentX 1589)
presents per 2 s (last 3): 47 56 27
device removals: 0
crashes: 0
peak commit: 25184 MB

this PR:

xcl-smoke v1
commit: 3443fd31adb9a16dde42b7ecbe6793ef3841d514
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1592 (PresentX 1593)
presents per 2 s (last 3): 45 56 20
device removals: 0
crashes: 0
peak commit: 26294 MB

No device removals or crashes; 100 % of main's frames, 104 % of its peak commit.

Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings: XCL_DIRECT_DXIL and XCL_HEAP_WINDOWS unset).

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

@raylitebull
raylitebull force-pushed the feat/lit-world-d3d12x-v2 branch from 3443fd3 to 39d08cc Compare November 25, 2026 01:53
@raylitebull

Copy link
Copy Markdown
Member Author

Thanks for the exhaustive review and every single catch, @gsucristo!

Updated #1989 cleanly onto bf9eebd (39d08cc), addressing all 6 Blocking + 4 Major findings:

  1. RAII buffer-copy cleanup (depth_uav.rs, format_alias.rs): replaced ManuallyDrop::new(Some(res.clone())) + mem::forget with RAII OwnedCopyLoc (ManuallyDrop::drop) so COM refcounts and VRAM never leak.
  2. Post-DepthToTwin UAV barrier (depth_uav.rs): emitted an explicit D3D12_RESOURCE_BARRIER_TYPE_UAV on twin immediately after FullscreenPass DepthToTwin dispatches.
  3. Internal-pass state restoration (bind.rs, list_x.rs): tracked bind::rs_cs alongside rs_gfx and updated list_x::restore_after_internal_pass(list, clobbered_gfx, clobbered_cs) to restore PC root signatures, bound_pso, using_fallback_pso/pso_dirty, and dynamic RSSetDepthBias.
  4. Per-subresource depth_uav tracking: replaced scalar plane states with per-subresource pc_states_depth/pc_states_stencil + split_uav_*, used tracked prev states on entering_uav, preserved separate per-subresource depth/stencil states on before_bind_dsv PlaneMask::Both, and scoped transitions/copies (copy_direct_subs, transition_plane_subs) to the targeted subresources.
  5. Deferred heap release (late_release.rs, depth_uav.rs, format_alias.rs): guarded late_release::drain_known with real::is_adopted and routed pass_dsv_heap/pass_srv_uav_heap teardown + evicted alias textures through late_release::hold.
  6. Compute-list state mask (format_alias.rs::sync_pair): replaced 0xC4F with COMPUTE_VALID_STATES = 0x8 | 0x40 | 0x400 | 0x800 (0xC48).
  7. Major catches (depth_uav.rs, format_alias.rs, real.rs): evicted stale/orphaned placed_uavs/placed_srvs on forget and VA reuse (late_release::hold), scoped on_uav_barrier to specific barrier targets when non-global, tracked note_title_transition before peer creation with per-subresource pc_states + BEGIN_ONLY ignore, validated element byte width and block-scaled dimensions in try_copy_texture_region, and pointed dev_create_uav_x's paired SRV (slot.pc_srv) at twin_res instead of depth res.

Compiled cleanly in release (0 errors) and pushed 39d08cc for GitHub Actions Build and test + reviewer verification.

@raylitebull
raylitebull force-pushed the feat/lit-world-d3d12x-v2 branch from 39d08cc to 197b104 Compare November 25, 2026 01:58
@raylitebull

Copy link
Copy Markdown
Member Author

Fixed the Build and test compile error in 197b104 (rebased cleanly onto 1e4fc10):

  • Passed None as the specific_targets argument to super::format_alias::on_uav_barrier(this, None) at crates/xcl/src/hle/d3d12x/list_x.rs:2889.
  • Removed the unused desc binding in crates/xcl/src/hle/d3d12x/real.rs.

@JJAutoCompare

Copy link
Copy Markdown

PR #1989 GPU verification

PR head 197b104b7a97a0fd9f68c7602291660802f552c4 was fetched from origin at refs/pull/1989/head and tested in a clean detached worktree. Fetched origin/main was aaa093657bd96a146c05c0c1a9b61149fe761453.

git merge-tree --write-tree origin/main HEAD exited 0 with tree c301c54bdb36c4dc9be3e1b1c779e01438160404 and no conflicts.

Tested

  • STOR-WINLAB, Intel Arc A770 16 GiB (driver 32.0.101.9175, DoublePrecisionFloatShaderOps=0, wave size 8–32), AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation build 26200.9974. rustc 1.100.0 (0ef1bc386 2026-11-09). DXC and DXIL 1.9.2609.5.
  • cargo build --workspace and cargo test --workspace --no-run both succeeded in unoptimized profiles with debug info and incremental compilation disabled.
  • cargo test -p xcl --lib hle::d3d12x::depth_uav::tests -- --show-output reported 4 passed, 0 failed, 0 ignored, 0 skips.
  • cargo test -p xcl --lib hle::d3d12x::format_alias::tests -- --show-output reported 3 passed, 0 failed, 0 ignored, 0 skips.
  • Under the shared Arc A770 lock, cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output completed in one pass. Cargo exit 101. Across 20 harness summaries, libtest reported 1100 passed, 28 failed, 46 ignored. There were 27 SKIPPED lines across 17 tests, including partial skips. The harness pass count includes early returns. Skipped paths are excluded from coverage.
  • The library target had 27 failures. In 22, CreateComputePipelineState returned 0x80070057. The other five reported result mismatches in FMA contraction, implicit LOD sampling, split-wave reduction tails, 16/64-bit VALU, and pixel-shader whole-wave reductions.
  • The e2e target had one failure in test_title_runs_and_game_folder_is_untouched. Its dynamic depth-bias check (Split wave64: masks read only lane by lane stay in their half #94) read blue [0, 0, 255, 255] where the test expected green after RSSetDepthBiasX(-1000.5).
  • Full output is in the local suite log at L:\XclTooling\sol-slot-9\tmp\pr1989-suite.log.

SKIPPED output

SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)
SKIPPED placed_title_textures_share_vram_and_preserve_pixels: tiled tier < 2
SKIPPED test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

Not tested

  • Retail-title smoke runs on main and the PR head, execution of the synthetic merge tree, and AMD or NVIDIA adapters. This run had no main baseline for the failures.
  • The suite reported missing XCL_SAMPLE_RPF, XCL_SAMPLE_TTPF, and XCL_SAMPLE_AWC inputs. The seven targeted CPU tests covered format, state, and alias tracking logic. Retail GPU execution of depth/UAV twin synchronization, alias copies, and dual-twin barriers remains unverified.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the build and tests and drafted this report. Coordinator #2 handles verification and publication.

Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against pr1989-suite.log and published this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@Toons29

Toons29 commented Nov 25, 2026 •

Copy link
Copy Markdown

Regression run of 51ee197c on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14561 MB
xcl-smoke v1
commit: 51ee197c69a3ba6ff37740457d4ecd39968c6e89
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15027 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 103 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; both blocks are exactly as printed, and I approved posting this.

@CharlyRien

Copy link
Copy Markdown

A test of this PR in the retail title's world, on the case that matters most there: a 2560 × 1440 D24S8 target that a compute program writes through its two UAVs and that the title's tiled lighting then tests with EQUAL. Full write-up, setup and numbers on #970: #970 (comment)

Setup in short: 197b104 merged three-way into a local tree (main 689f2db + a stack of open PRs, listed in the linked comment; 9 conflicts, both sides kept), RTX 3090 24 GB (driver 616.56), Windows 11 22631.

  • The routing works: 257 UAVs routed to twins, no null view left.
  • The twin → depth copy never runs for this target: twins are marked dirty by resource-specific UAV barriers or legacy transitions (on_uav_barrier / filter_transition), and this title uses enhanced barriers (list Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146), which end up as a global UAV barrier. So before_bind_dsv finds nothing dirty and the depth target stays 100 % zero.
  • With a local switch that copies the depth twin at every DSV bind of a D24S8, the target is written, but with two values only (0 and 1.0) where the title needs per-pixel values for its EQUAL test. I have not found yet whether that is the twin's content, the conversion of the R24_UNORM plane, or a later overwrite.

AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the merge and the runs) did this and drafted the comment.

@raylitebull
raylitebull force-pushed the feat/lit-world-d3d12x-v2 branch from 197b104 to 3c86172 Compare November 25, 2026 11:03
@raylitebull

Copy link
Copy Markdown
Member Author

Thanks so much for catching the D24S8 Enhanced Barriers sync issue on RTX 3090, @CharlyRien (#issuecomment-7158762448)!

Rebased #1989 cleanly onto f087b998 (3c86172c) and fixed the Enhanced Barriers / global UAV sync path plus two additional bugs uncovered under the WARP D3D12 Debug Layer:

  1. Enhanced Barriers (#146 list_x::uav_barrier_x) & global UAV barriers (#26 res == 0):
    • Added depth_uav::filter_enhanced_barriers to parse D3D12_BARRIER_GROUP (D3D12_BARRIER_TYPE_TEXTURE and D3D12_BARRIER_TYPE_GLOBAL) on slot #146, executing TwinToDepth / DepthToTwin / TransitionOnly directly on DIRECT lists (handling Access*, Layout* including queue-specific layouts, DISCARD, UNDEFINED, and per-plane Subresources) and deferring cleanly on COMPUTE lists.
    • Added depth_uav::on_global_uav_barrier to mark materialized twins dirty on #146 global barriers and #26 wildcard UAV barriers only when !plane_dirty (so compute-written depth+UAV targets flush on before_bind_dsv without overwriting graphics-rendered depth targets).
  2. before_bind_dsv STATE_COMMON legal state & CreatePlacedResource #29 hook:
    • Recorded D3D12_DSV_FLAGS (READ_ONLY_DEPTH/READ_ONLY_STENCIL) in note_dsv so flushing a target still in STATE_COMMON transitions to legal DEPTH_READ/DEPTH_WRITE instead of illegal STATE_COMMON.
    • Hooked depth_uav::register_if_depth_uav into real.rs::dev_create_placed_resource_x (#29) and integrated upstream #1914 uav_companion_srv + null_uav_desc in dev_create_uav_x.
  3. 2-plane RowPitch mismatch in copy_plane_through_buffer (depth_uav.rs, format_alias.rs):
    • R24G8_TYPELESS plane 1 (stencil) can report RowPitch = 512 while its R8_TYPELESS twin reports 256, previously dropping the stencil copy on src_fp.RowPitch != dst_fp.RowPitch. Unified both footprints to max(src_pitch, dst_pitch) in both depth_uav.rs and format_alias.rs.

Verified on WARP (XCL_ADAPTER=warp, XCL_D3D12_DEBUG=1): cargo check --workspace --tests PASS (0 warnings in touched files) and hle::d3d12x::depth_uav + hle::d3d12x::format_alias 9 passed, 0 failed (0.07s), including enhanced_barriers_handle_texture_subresources_uav_and_discard and GPU draw test gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test (D24_UNORM_S8_UINT and D16_UNORM_S8_UINT DepthFunc = EQUAL + stencil preservation, 0 D3D12 debug errors). Pushed 3c86172c!

@raylitebull
raylitebull force-pushed the feat/lit-world-d3d12x-v2 branch from 3c86172 to 51ee197 Compare November 25, 2026 11:12
@raylitebull

Copy link
Copy Markdown
Member Author

Fixed the 0xc0000005 crash in gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test under --test-threads=4 in commit 51ee197c (rebased cleanly onto 96331383):

  • Root cause (test heap vtable ABI): the test called real::adopt(dev, Kind::Device) before creating its own test PC heaps/resources (uav_heap, dsv_heap, rtv_heap, PSOs, depth targets), causing uav_heap to be adopted with the console heap_cpu_start_x RAX-return ABI instead of PC's hidden out-param when called via windows-rs.
  • Fix (depth_uav.rs): created all test PC heaps, resources, footprints, and depth targets before adopting dev and list, used orig_fn(dev, 21) for CreateDepthStencilView after adoption, and cleaned up PIPELINES for dev on test exit.
  • Verified on WARP:
    • XCL_ADAPTER=warp cargo test -p xcl --lib "hle::d3d12x::" -- --test-threads=4 --skip pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa (2 consecutive runs): 214 passed, 0 failed, 2 ignored (0 crashes).
    • XCL_ADAPTER=warp XCL_D3D12_DEBUG=1 cargo test -p xcl --lib -- --nocapture --test-threads=1 "hle::d3d12x::depth_uav" "hle::d3d12x::format_alias": 9 passed, 0 failed (0.09s, 0 D3D12 debug errors).

Pushed 51ee197c!

@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

The crash in gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test (0xc0000005, the CI failure of 51ee197 looks like it) is the test, not the twin code: fix below. With it, all tests of this PR pass on AMD.

On AMD RDNA4, Windows, DXC 1.8.2502.11, 51ee197 merged into my tree (main + other open PRs), debug, the test crashed every time without the debug layer and passed with XCL_D3D12_DEBUG=1.

Backtrace: list_x::transition (list_x.rs:124) ← execute_syncs ← before_bind_dsv ← phase 2 of the test, reading the vtable slot before the list's vtable at 0xffffffffffffffff. The runtime's Reset puts its own vtable back on the list; the title's path restores XCL's (preserve_vtable, called in list_x::reset_pc). The test calls the original Reset at both phase changes and does not. The debug layer's list does not swap it, so the test passed there.

// the runtime's Reset puts its own vtable back (as `list_x::reset_pc` knows)
let ext = *(list.as_raw() as *const usize);
assert_eq!(reset_orig(list.as_raw(), alloc.as_raw(), std::ptr::null_mut()), 0);
real::preserve_vtable(list.as_raw(), ext);

After both resets: cargo test -p xcl --lib -- hle::d3d12x --test-threads=4: 254 passed, 0 failed, 2 ignored (merged tree, so not only your tests).

Not checked: the D16_UNORM_S8 change you described (the stencil-read depth as R16_UINT times asfloat(0x37800080)) is not in 51ee197, so I have not run it; and no title run with this PR yet.

AI use: Claude Code (Claude Opus 5.5) found it, wrote the fix and this on the maintainer's behalf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants