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 with real::preserve_vtable across test Reset calls).
  • 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 + #2280 pc_clear_for_desc), 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), rebased cleanly onto 569f0fc5 (bfafdf77).
  • cargo check --workspace --tests: passed (0 warnings in touched files).
  • Debug layer OFF (matching CI, 0 skips): XCL_ADAPTER=warp cargo test -p xcl --lib "hle::d3d12x::" -- --test-threads=4: 251 passed, 0 failed, 2 ignored (4.25s, 0 crashes).
  • Debug layer ON: 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.11s, 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 bfafdf77 vs 569f0fc5 has not been run yet. AMD and NVIDIA reviewers are invited to test on bfafdf77 vs 569f0fc5 (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 bfafdf77, full cargo test --workspace suite on bfafdf77, 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 569f0fc5, 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
Contributor

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.

@raylitebull
raylitebull force-pushed the feat/lit-world-d3d12x-v2 branch from 51ee197 to ced4891 Compare November 25, 2026 18:15
@raylitebull

Copy link
Copy Markdown
Member Author

Thanks for tracking down the debug-layer-off Reset vtable overwrite on RDNA4/CI and sharing the exact fix, @ivall (#issuecomment-7166572303)!

Updated #1989 cleanly onto 73e3aba6 (ced48914):

  • Test Reset vtable preservation (depth_uav.rs): wrapped both reset_orig calls in gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test with let ext = *(list.as_raw() as *const usize); assert_eq!(reset_orig(...), 0); real::preserve_vtable(list.as_raw(), ext); so the PC runtime's Reset does not overwrite XCL's vtable when XCL_D3D12_DEBUG=0.
  • Re D16_UNORM_S8_UINT depth/stencil note: for console D16_UNORM_S8_UINT (118..=120), depth_uav.rs allocates an R16_TYPELESS (53) depth twin and binds the FullscreenPass SRV as DXGI_FORMAT_R16_UNORM (56), which converts u16 depth directly in hardware without needing an explicit asfloat(0x37800080) scale (and if a title performs a separate stencil-view read on a D16_UNORM_S8_UINT texture, we can check that in a dedicated follow-up).
  • Verified on WARP (ced48914):
    • Debug layer OFF (matching CI): XCL_ADAPTER=warp cargo test -p xcl --lib "hle::d3d12x::" -- --test-threads=4 --skip pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa -> 236 passed, 0 failed, 2 ignored (4.25s, 0 crashes).
    • Debug layer ON: 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 ced48914!

@raylitebull
raylitebull force-pushed the feat/lit-world-d3d12x-v2 branch from ced4891 to bfafdf7 Compare November 25, 2026 18:24
@raylitebull

Copy link
Copy Markdown
Member Author

Rebased #1989 cleanly onto 569f0fc5 in commit bfafdf77, resolving the real.rs adjacency conflict cleanly alongside #2280 (pc_clear_for_desc + effective_st).

Verified on WARP (bfafdf77):

  • cargo check --workspace --tests PASS (0 warnings in touched files).
  • Debug layer OFF (0 skips): XCL_ADAPTER=warp cargo test -p xcl --lib "hle::d3d12x::" -- --test-threads=4 -> 251 passed, 0 failed, 2 ignored (4.25s).
  • Debug layer ON: 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.11s).

Pushed bfafdf77!

raylitebull added a commit that referenced this pull request Nov 25, 2026
Bring in 36 upstream PRs from origin/main (#2310..#587) onto amd-dev (c7a18d8) while preserving all local AMD RDNA4 work (#615 pipelined presenter SRVs, #495/#1405 XCL_PAGE_ALIAS=1 hooks, #2306 level tiling timers, #1989 vtable fix, mesh user SGPRs).

Resolved 4 conflicts:
- console_list.rs: kept both mesh_arguments_go_in_user_sgprs_from_s16 and #2323 dispatch-heap tests
- real.rs: kept both effective_st depth-UAV tracking and #2280 pc_clear_for_desc
- vram.rs: kept Step::Tiling timer around level_tiling
- kernelx.rs: kept XCL_PAGE_ALIAS=1 hooks in physical_pages_live and XMemMapPhysicalPagesScatter

Assisted-by: Antigravity (Gemini 4 Neon High)
@CharlyRien

Copy link
Copy Markdown
Contributor

Test report, RTX 3090: a title-placed R32_UINT writer never reaches its R9G9B9E5 PlacedSrv reader when the title moves it with enhanced barriers. Copying it at the reader's bind, with copy buffers of its own, fills the screen-probe radiance atlas: from 0–10 KB to 2.5 MB non-zero of 4.96 MB. The picture is still over-exposed, so this is one missing piece, not a fix of the frame. One run per arm.

What happens (read in format_alias.rs)

  • The pair is created (buffer_through true). It is synced only from a legacy transition out of a write state, or from a UAV barrier for PlacedUav writers. This title uses enhanced barriers and a TitlePlaced writer, so neither path fires and the reader stays zero.

Local changes (local commits on our tree, not pushed)

  1. At the reader's bind: at each translated bind, the first 64 T#s of each table are resolved to resources. sync_pair runs for any PlacedSrv reader whose pair has a TitlePlaced writer. A UAV barrier and a null aliasing barrier come before the copy.
  2. Copy buffers of their own: the buffer-through copy took its intermediate from the per-list copy scratch, which is held until the list's reset and capped for all lists. That pool was exhausted, so 94 % of the copies were skipped, silently. Each list type now gets its own grown, kept staging buffer.
  3. Direct reinterpret copy: R32_UINT / R32_SINT ↔ R9G9B9E5 are on the "Reinterpret copy" list of CopyResource on Microsoft Learn, as 1:1 pairs. We copy texture to texture, with no intermediate buffer. Measured bit-exact on this 3090, with 0 debug-layer messages.

Measured (in the title, captures of the reading pass and of the frame)

run writer at the read reader at the read atlas after the filter pass
without (1)–(3), several runs (some with earlier copy variants) 199–250 KB non-zero 0–5,632 B 0–10,070 of 4,961,280 bytes
(1) without (2) – copies skipped (94 %, scratch exhausted) –
(1) + (2) 2,030,430 non-zero 2,030,430 (equal) 2.52 MB non-zero
(1) + (2) + (3), lighting run – 50 pairs copied, 0 copies not done –

Setup

Not tested: other GPUs; other pair formats.

AI use: Claude Code (Claude Opus 5.5, coordinating session and agents). The agents read captures and code, wrote the local switches and the analysis scripts, and drafted this report; the coordinating session ran the in-title runs and checked the numbers.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

@St5sz2Jk

St5sz2Jk commented Nov 26, 2026 •

Copy link
Copy Markdown

Correction (edited): the same assert also happened with this PR's features switched off (XCL_FORMAT_ALIAS=0 XCL_DEPTH_UAV_TWIN=0, at 476 s), so it is probably not caused by this PR. Details are in #2092.


The title assert I noted earlier with this PR came back today: two more of two long runs, AMD / Linux. It is 0x80000003 at +0x5149aec, from several threads at once, and the earlier run was the same.

Setup

Runs

  • One ended at 554 s.
  • One ran into its 600 s limit after the assert.
  • The same stack without this PR ran 1,500 s today without it. Shorter runs with this PR (400–480 s) ended before it would show. That is too few runs to call it proven.

Format-alias side, for reference

  • 59 R32_UINT → R9G9B9E5 pairs in the cutscene, 57 synced. They were copied with a direct CopyResource (a reinterpret pair), which avoids the per-list scratch.
  • The R32_UINT writer is all zero here, but in this tree the world geometry is not drawn at all (details in #2092). So nothing can be concluded about the copy itself.

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

@andrewDoing

Copy link
Copy Markdown
Contributor

RTX 5070 verification of depth and UAV synchronization

All nine focused tests passed on the clean head of PR #1989, commit bfafdf77a42a39bff689a5e7e9a92c2d085799c5. The run finished in 0.63 seconds, with zero failures, ignored tests, or reported skips.

The live GPU fixture performed depth comparisons and stencil readback for D24S8 and D16S8 across enhanced and global UAV barriers. The format-alias tests checked descriptor handling, resource pairing, and the need for a buffer intermediate. They are unit tests. The run requested the D3D12 debug layer. The GPU fixture asks D3D12 for the default hardware device when WARP is not requested. A separate default-device probe identified the RTX 5070, LUID 0:0000e7ea. Focused log · Default-device probe

Command: cargo test --locked --offline -p xcl --lib -- --nocapture --test-threads=1 hle::d3d12x::depth_uav hle::d3d12x::format_alias, with XCL_D3D12_DEBUG=1, XCL_ADAPTER=RTX 5070, and XCL_REQUIRE_GPU=mesh. The focused tests used synthetic resources. Retail world lighting, title stability, and a comparison against the parent remain unmeasured.

AI use: OpenAI Codex selected and ran the existing tests, inspected the device-selection and readback code, and wrote this report.

@imnicho

imnicho commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Test report, RTX 5080 16 GB, this PR merged into an nvidia-dev tree: the twins route the lighting target and the scene's lighting draws get through (the room after the opening cutscene is lit for the first time here). The frames are heavier for it and this tree's GPU hang comes sooner; a smaller loop budget for pixel programs moved the first stop in 5 of 7 runs and cured nothing.

Setup

  • RTX 5080 16 GB (driver 610.47, 32-lane waves), Intel Core i7-7700K, 16 GB RAM, Windows 10 22H2 (19045), release build.
  • Tree: nvidia-dev d1be8103 plus other open nvidia-dev PRs (D3D12.X: two-pass ExecuteIndirect uses plain signatures, with Wine's barrier #3012, VFS: XCL_DRIVER_SHADER_CACHE=0 refuses the driver its shader cache file #3048 among them) and local test changes; ray tracing in amd-dev's every-ray-misses mode (XCL_RT_GATE=miss, 1aebe666, ported locally). This PR's head bfafdf77a merged into it.
  • The merge: 27 conflict hunks in 7 files (bind.rs, device_x.rs, late_release.rs, list_x.rs, mod.rs, real.rs, and depth_uav.rs, which nvidia-dev has as a module of its own since 25 Nov). I kept nvidia-dev's module as it is (off: its XCL_DEPTH_UAV_TWIN is 0 unless set) and put this PR's beside it under another name with a switch of its own, the PR's calls renamed. dev_create_uav_x asks this PR's resolve_uav first. late_release::hold and title_textures::note_gpu_write take a second argument on nvidia-dev (false, and list 0), tracked_root_sigs reads nvidia-dev's sharded list state, and restore_after_internal_pass (which nvidia-dev has too, for another pass) became a second function on nvidia-dev's per-list state. Views by address (recomp: run wave64 compute programs as two wave32 halves on 32-lane GPUs #70 / GPU tests: run wave64 kernels as two wave32 halves on 32-lane GPUs #71) stayed nvidia-dev's: one placed resource per address and description, in the title's memory.
  • Runs: a retail title into its world, Series S profile, 600 s limit, warm shader caches, XCL_FORMAT_ALIAS=0 in all of them (the format-alias half is not tested here).

1. What the twins do in this title

  • Two-plane depth buffers tracked: two D32S8 (1280x720 and 1280x736) and one of console format 118 (D16_UNORM_S8_UINT, 1280x720, R24G8 on the PC). The last one is the depth target the scene's lighting draws test with EQUAL (D3D12.X: a console depth buffer that is also a UAV gets a null UAV – shader writes to the retail title's shadow maps are dropped #970); its 16 bits are why their vertex shader writes z = permutation / 65535.
  • Its depth UAV goes to an R16_UNORM twin, its stencil UAV to an R8 twin. With all buffers on, more than 250 single-plane D16 buffers (shadow maps) are tracked as well.
  • By a local log line: 256 twin-to-plane SV_Depth passes and 64 plane-to-twin compute copies in the first 170 s of the world.

2. The picture (described; no screenshots of the title)

  • Before (the same tree without this PR): the room after the opening cutscene shows only what the sun hits directly, as orange specks on black. nvidia-dev's own twins do not change that: they give the depth plane of an R24G8 buffer no twin, and their copies hang on legacy transitions into and out of UNORDERED_ACCESS, which this title does not issue for these buffers (0 copies in three runs).
  • With this PR: the character's clothes with their lettering, the window frame, the furniture and the lamps outside are lit. Still wrong here: no sky, no hair (those draws are already wrong in the G-buffer, so not this PR's matter), an orange tone, and blown-out frames in the cutscene.

3. The GPU hang, which is this tree's and not shown to be the PR's

  • Before the merge, of 9 runs of this tree on the same day 3 lost the device (204 to 396 s after the world's set-up, at the compute pass of a two-pass mesh draw), 3 ran the full 600 s and 3 ended on stops of the title's own.
  • With the PR, 4 of 4 runs stopped 113 to 129 frames (91 to 122 s) after the set-up; Windows logged three nvlddmkm 153 and then Display 4101 each time. Two of them show as the title's own assert (its 2 s GPU wait timed out) and two, run with XCL_WAIT_TIMEOUT_MS=15000, as device removed. Twins for two-plane buffers only gave the same.
  • With a loop budget of 1,024 passes a lane for pixel-stage programs only (a local switch in both translators; Recompiler: XCL_LOOP_BUDGET sets the loop iteration budget of a lane #1284 has the switch for every stage), 7 runs: 2 stopped in that same range (105 and 115 frames), 4 stopped at 169 to 174 frames (2 as device hangs, 2 on the title's no-frame watchdog while the pixel pipelines were being made anew), 1 ran the full 600 s (323 frames, 0 GPU wait timeouts). So 5 of 7 got past where 4 of 4 had stopped, with numbers this small.
  • A loop budget and a wait bound of 1,024 for mesh-stage programs as well (4 runs), and the tree's work-skipping switches set back to their defaults (2 runs so far): device hangs in 2 of 4 and 1 of 2. Neither is a cure.

Not tested

  • The format-alias half (XCL_FORMAT_ALIAS on), the PR on its own base, AMD, the Series X profile.
  • A like-for-like number for the HDR scene target with and without the PR: my dumps are of different frames, because most runs do not reach the room.
  • The suite in the merged tree. Of the PR's own tests there, enhanced_barriers_handle_texture_subresources_uav_and_discard passes; gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test ends in an access violation right after its first SV_Depth pass is recorded (also with the vtable kept across the test's Reset, as amd-dev's 98be4785 does). I have not found out why; in the title the same pass runs hundreds of times a run. So take my merge as a test tree, not as a port.

AI use: Claude Code with Claude Fable 5.2 did the merge, ran the runs and wrote this comment.

@imnicho

imnicho commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Plan: this PR's format-alias copies for nvidia-dev, as one focused PR, with the title's enhanced barriers as the trigger. With them the retail title's room, sky and yard are lit here for the first time.

Measured on an RTX 5080 16 GB (driver 610.47), tree and run conditions as in my report above, with nvidia-dev's own depth_uav module plus my draft for the R24G8 depth plane in place of this PR's twins:

  • The pairs. The title places 59 pairs of textures at one address each: one R32_UINT with ALLOW_UNORDERED_ACCESS that its compute programs write, one R9G9B9E5 without flags that its shaders sample. 11 of 1280x720, 8 of 640x360, 5 of 480x272, 5 volumes of 40x23x64, 3 of 128x128x8, two cubes of 128x128 and one of 64x64, two of 2048x120 with 4 levels, 2304x576, 2048x512, 1280x320, 768x192, 1024x1024, 192x108 and smaller ones.
  • Why the sampled one is stale on nvidia-dev. The written one is GPU-owned (vram). The sampled one is a texture of its own, kept in step with the title's memory (title_textures), which nothing writes. Many of the pairs are at addresses that are not on 64 KiB pages, where the two cannot share pages either.
  • What the title does between the write and the read. It moves the written texture with an enhanced barrier (list Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146): access UNORDERED_ACCESS to SHADER_RESOURCE, layout 3 to 6, all subresources. nvidia-dev makes one UAV barrier for all resources of that call and drops what it names (D3D12.X: translate list #146 Enhanced Barriers to legacy ResourceBarrier #1025 is not on nvidia-dev), so no legacy barrier names these textures: 121 frames into the world of one run my counters stood at 459 enhanced barriers of written textures of a pair, and 0 legacy transitions, 0 aliasing barriers and 0 UAV barriers naming one.
  • With the copy. Written to sampled through a buffer (two CopyTextureRegion a level, as this PR does it), recorded right after that barrier: 32,768 copies were logged by 582 s of a 600 s run (736 frames after the world's set-up at 157 s), no device loss. Frame captures: the room's walls, the window with the sunset sky, the yard, the fence and the bunk are lit; before, all of that was black except what the lamps hit. A second run lost the device 171 s after the set-up, which this tree also does without the copies.

Plan for the PR (against nvidia-dev, behind XCL_ALIAS_COPY=1, default unchanged):

  1. The title's placed textures kept by address at CreatePlacedResourceX; a pair is a written one (render target or UAV) and a sampled one at the same address with the same size, levels, layers and texel width and another format.
  2. The copy at the Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146 texture barrier of the written one whose access before is RENDER_TARGET or UNORDERED_ACCESS, and at a legacy transition out of those states. Only the fields of the barrier are read; translating enhanced barriers into states stays D3D12.X: translate list #146 Enhanced Barriers to legacy ResourceBarrier #1025's.
  3. A buffer for each pair, made at its first copy; the states of the two textures as nvidia-dev has them (their creation states) around the copy.
  4. Tests with synthetic textures on WARP: an R32_UINT texture written, its R9G9B9E5 pair sampled after the barrier.

Not in it: views by address (#70 / #71), CopyResource between format families, the depth twins. The mechanism is @raylitebull's from this PR and will be credited as such. If you would rather bring it to nvidia-dev yourself, say so and I stop.

AI use: Claude Code with Claude Fable 5.2 read the logs and the code, wrote the local version and this comment.

@Anon64

Anon64 commented Nov 28, 2026

Copy link
Copy Markdown

@imnicho the pairs you describe are in the log on an RTX 3060 12 GB too, and the scene there is black past world load in the same way.

Tree: nvidia-dev with #3039 (7cce7d3d) and #2975 (4e52050c) merged locally, release, XCL_TEXTURE_LEVEL_PAGES=1 XCL_TEXTURE_SYSMEM=1 XCL_DIRECT_DXIL=1, 900 s. Its CreatePlacedResourceX log lines name R9G9B9E5 textures (format 67, no flags) placed over R32_UINT ones (format 42, flags 0x300004, so with ALLOW_UNORDERED_ACCESS), with the same size: 1280x720 among them, also 2304x576, 2048x512, 1280x320 and 768x192. The log names the first ones only, so that isn't a count.

What the run shows past world load: the title's in-play UI over a black scene. XCL_DUMP_TARGETS on two in-play frames: the 2560x1440 targets of format 28 and 29 are 0 throughout, with ~98 % of their draws run (details on #2055). That fits a lighting input that is never updated.

When the focused PR against nvidia-dev is up, I'll run it on this card on the same tree, with frame and target dumps before and after, and report here.

RTX 3060 12 GB (driver 581.80), i9-14900KF, 64 GB RAM, Windows 11 26200.

AI use: Claude Code (Claude Opus 5.5) read the run's log and wrote this comment.

imnicho added a commit to imnicho/xcl that referenced this pull request Nov 28, 2026
…e plane before its DSV is bound

With XCL_DEPTH_UAV_TWIN=1 a UAV of the depth plane of an R24G8 buffer (a
console D16S8 or D24S8) was a null view ("its depth plane has no twin
yet"). It is now a view of a twin of the plane: R16 for the console's
16-bit depth, R32 otherwise.

No D3D12 copy puts either into a 24-bit plane, and a title that writes
such a plane from a compute program need not move the buffer into
UNORDERED_ACCESS first, so this twin is not copied at transitions. A pass
of XCL's own draws it into the plane, writing SV_Depth, before the title
binds a DSV of the buffer, when something was dispatched since the last
such pass. A 16-bit twin is read as a count and written as
count * (1.0f / 65535), the product a title's vertex shader makes, so an
EQUAL test at that depth passes.

The pass moves the depth plane to DEPTH_WRITE and back where the title
has it elsewhere. It does not move the stencil plane: its DSV names that
plane read only where the title has it in DEPTH_READ.

The pass and the 16-bit steps follow xcl-dev#1989 by raylitebull and
its follow-up on amd-dev (3cda5be).

Not in it: what a draw or a clear writes into such a plane does not reach
the twin, and a stencil twin is, as before, not put into its plane.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@imnicho

imnicho commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@Anon64 thank you. The focused PR is up: #3094 (XCL_ALIAS_COPY=1, against nvidia-dev). Two things for your run:

  • The scene's lighting draws need the lighting target's depth plane as well, which is D3D12.X: the depth plane of an R24G8 buffer has a twin, drawn into the plane before its DSV is bound #3089 (XCL_DEPTH_UAV_TWIN=1, also against nvidia-dev). The two do not touch the same lines except one helper's neighbourhood in list_x.rs; my runs had both.
  • The module logs the pairs it finds ("alias copy: at ... is written as format 42 and read as format 67 (n such pairs so far)") and its copies at powers of two with what was left out, so a log tells whether the copies ran on your card.

What I measured, and what I did not, is in the PR's description: on my tree the copies light the scene, and runs with them end at that tree's GPU hang earlier than runs without.

AI use: Claude Code with Claude Fable 5.2 wrote this comment.

@CharlyRien

Copy link
Copy Markdown
Contributor

Thanks for #1989. Its format-alias pairing (R32_UINT writer / R9G9B9E5 reader at one address) is the piece main is missing for the retail title's TAA history. Because the PR leaves the view out of title_textures, the view keeps its tiles mapped; credit for that idea goes to this PR. We hit the same problem on a local lab tree and found three remaining gaps. A suggested fix is on a branch stacked on this PR, linked at the end.

Stack

  • PR test: main 753e8b1a + D3D12.X: add depth+UAV color twins, format-aliased placed texture copies, and dual-twin UAV barriers #1989 bfafdf77, cherry-picked as 2313cfb4.
    • First applied onto main 2c717a04, with one trivial conflict in list_x::reset_pc: main's reset_own_alloc(this) is kept, followed by format_alias::list_reset.
    • Then rebased onto 753e8b1a with no further conflict.
  • Suggested commits on top, in order:
    • 3b491e77 (trim): a reader's pages end where its writer's copy does;
    • 1df47cf5 (remap): an unmapped reader is mapped again before its copy;
    • a6a9a2f3 (test): the GPU test below;
    • 5e996e33 (generation): the remap looks at the pages again only after some placed texture lost its tiles.
  • The GPU tests below ran on the same commits before the rebase (on 2c717a04). The rebase changed only the base; the commits are the same.
  • Game measurements (WIN5 / WIN6 / WIN7): from our local lab tree, NOT main. That tree is merge base b49be183 plus local commits that are not public, and it does the alias copy with its own mechanism, not D3D12.X: add depth+UAV color twins, format-aliased placed texture copies, and dual-twin UAV barriers #1989's. The cause sits in the same code in both trees: title_textures → vram::unmap_superseded, with the same xg::optimal_mode.
  • Machine: RTX 3090 24 GB (Resizable BAR off), driver 616.56, Windows 11.

What we measured (lab tree, retail title, reference scene: the window behind the character)

  • MEASURED: the TAA reads its history from two 1280x720 R9G9B9E5 views. Each sits at the address of an R32_UINT UAV texture.
    • Before the fix, at every copy, both views were on the shared pages with no tile mapped (mapped false, pages used 0, not evicted).
    • Right after its copy, a view read 100 % zero, while its R32_UINT source held the lit window.
    • The window was black: mean luminance of the window region 1.8 / 255 over 100 world frames.
  • MEASURED: the console layouts logged for the two views are 2 (XG 64KB_D, 3 932 160 bytes) and 0 (XG 4KB_S, 3 768 320 bytes). The title places the pairs 3 686 400 bytes apart, the size of the linear R32_UINT texture.
    • Each view's range therefore overlaps the next placement.
    • title_textures::insert shadows the older view and unmaps its tiles. In our log, the first view loses its tiles 2 ms after creation, to the second view placed 3 686 400 bytes further on.
  • MEASURED, with each view mapped again before its copy and its pages cut to the copy's size:
    • right after the copy, the view equals its source (window luminance 2.81 in the HDR target);

    • the window is lit: 193.2 / 255 over 85 world frames, 99 % of them above 40;

    • without any probe or dump, in our reference run's env, with the same binary (one run each):

      remap on (WIN7) remap off (WIN7C)
      window luminance, world frames (0-255) 197.4 (97 frames, 100 % above 40) 4.8 (99 frames, 0 %)
      mean change from one dumped frame to the next (every 8th present) 4.3 1.0
      presents/s over the whole world 2.84 2.91
      views mapped again / views that lost their tiles 11 / 13 0 / 13
    • All 11 remaps happen before the world (173-267 s; the world starts at about 290 s).

    • With the remap, the pace is 2.4 % lower. These are single runs and the 30 s slices overlap (2.82-3.04 against 2.82-3.14 after the first slice), so it may be noise.

    • It may also come from checking the pages at every copy (a lock, about 1600 copies a second). 5e996e33 skips that check until some placed texture loses its tiles. The pace after that change is not measured yet in game.

What remains in #1989 (READ in the diff, DEDUCED for this title)

  1. Neighbouring views share their tail tiles.
    • The reader keeps its console size on the pages (60 tiles for the 3840 KiB view), while the next pair starts 3600 KiB later. Its last 3-4 tiles are therefore the next reader's first tiles, keyed by address.
    • Since D3D12.X: add depth+UAV color twins, format-aliased placed texture copies, and dual-twin UAV barriers #1989 copies into both views, each copy overwrites a corner of the other view's history (bottom-right of one, top-left of the next).
    • 3b491e77 cuts the reader's pages to the bytes of a copy of its subresources when format_alias pairs it at creation. Its tail tiles are then its own.
  2. A view created before its writer.
    • It is registered in title_textures, then retired with its tiles unmapped when the GPU-owned writer is placed over it (retire_overlapping). The pair still forms, but the copy lands nowhere.
    • 1df47cf5 maps an unmapped reader again in sync_pair, before the copy, with the same cut. It does nothing for a mapped reader.
  3. Nothing checks the reader's tiles before a copy.
    • A copy into a reserved texture with no tile mapped is dropped without any error, and the reader reads zero.
    • Point 2 is the case we know of. The remap in 1df47cf5 covers any other unmapping by unmap_superseded.
    • 5e996e33 keeps that check cheap: vram keeps an unmap generation, and each reader remembers the generation at which it was last found with its tiles.

None of these three points is touched by the format-alias follow-ups on amd-dev (b2a2fec9, 33709155, 3ca3e457, c093211e). #2270, which orders unmap_superseded after the work already submitted, is a separate question: it changes when the unmapping happens, not whether a copy lands after it.

Test (a6a9a2f3, plus a step (C) from 5e996e33, GPU): format_alias::tests::gpu_format_aliased_views_keep_their_tiles_and_take_their_copies.

  • Through create_placed_resource_x, it places two pairs one writer apart, plus a view before its writer.
  • It checks that:
    • the views share no tile;
    • the early view was unmapped by its writer;
    • after sync_title_writers, each view holds its own writer's texels whole;
    • (C) a view unmapped once more after that is mapped again by its next copy.
  • Results on the RTX 3090 (debug test build, same commits before the rebase):
    • XG gives the writer 3 686 400 bytes and the view 3 932 160;
    • the two neighbouring views share 0 tiles;
    • the view placed before its writer is mapped, then unmapped once the writer is placed;
    • after the syncs, each of the three views holds 921 600 of 921 600 of its writer's texels;
    • (C): the view is unmapped, and its next copy holds 921 600 of 921 600;
    • 1 passed.
  • D3D12.X: add depth+UAV color twins, format-aliased placed texture copies, and dual-twin UAV barriers #1989's own depth_uav::tests::gpu_d24s8_and_d16s8_enhanced_barrier_twin_sync_passes_equal_depth_test also passes on main + D3D12.X: add depth+UAV color twins, format-aliased placed texture copies, and dual-twin UAV barriers #1989 + these commits.
  • After the rebase onto 753e8b1a: cargo check and the CPU tests of format_alias / depth_uav pass (9 tests).
  • Not run on WARP.

Smokes on main + #1989: not run on main. In our setup, main does not reach the world on this card without a translated-shader cache: we have one 200 s smoke, which showed loading screens only. The game numbers above come from our lab tree; on main + #1989, the evidence is the GPU test.

About #3094 (the focused port, which triggers the copies at the enhanced barriers): for comparison, on the RTX 3090 our lab runs with alias copies tonight had no GPU hang. That is 8 runs of about 10 minutes, each stopped by our watcher 240 s into the world: 0 device removals and 0 hangs. Our lab tree does its copies with its own mechanism, so this does not test #3094's code.

Suggestion. The branch is https://github.com/CharlyRien/xcl/tree/pr/alias-view-remap (4 commits on top of this PR, on main 753e8b1a; compare with this PR's branch). Take what you want into #1989, or we can open it as a stacked PR.

  • Both switches default on and can be turned off for comparison: XCL_FORMAT_ALIAS_TRIM=0 and XCL_FORMAT_ALIAS_REMAP=0.
  • The trim only affects readers that format_alias pairs, at the cost of up to 3-4 extra 64 KiB tiles per view.
  • The remap only acts on an unmapped reader.

Open question. Why does XG lay these views out longer than the linear writer at the same address? If the console's library gives them the writer's layout, xg::optimal_mode is the deeper cause, and other textures could be affected.

AI use: Claude Code, model Claude Opus 5.5, found the cause from the logs and probes, wrote the four commits and the test, ran them on the machine above and wrote this. The person running these tests asked for this post.

🤖 Generated with Claude Code

@Anon64

Anon64 commented Nov 28, 2026 •

Copy link
Copy Markdown

@imnicho I ran #3094 (839b33a1) with #3089 (3b12e0b2) on the RTX 3060 12 GB, as promised. The copies run, but the scene there stays black.

Tree: nvidia-dev with #3039 (7cce7d3d) and #2975 (4e52050c) merged locally, then #3094 and #3089. There was one conflict, in sparse.rs: #3039's system-memory pools now keep their free tiles in #3094's FreePools. Release build, XCL_TEXTURE_LEVEL_PAGES=1 XCL_TEXTURE_SYSMEM=1 XCL_DIRECT_DXIL=1 XCL_ALIAS_COPY=1 XCL_DEPTH_UAV_TWIN=1, a run of about 13 minutes, stopped by hand.

  • The copies ran. The log names 32 format 42 / format 67 pairs by 258 s. It counted 16 384 copies at enhanced barriers and 0 at legacy transitions by 736 s, with 0 left out for each of the three reasons.
  • First present at 251 s, as without the two PRs. In play: 12–15 k draws per 2 s, 0.7–2 fps. No device removal in this run.
  • XCL_DUMP_TARGETS on two in-play frames: the 2560x1440 targets 0, 1, 3, 4, 5 (formats 28 and 29) and 7 (format 42) still read 0. Target 2 has content, as before. Target 6 (format 10) changed: it read nearly 0 without the PRs and now has content. The frame on screen is a dark blue-grey instead of black, but nothing of the scene shows.

So on this card the copy reaches part of the lighting but not the colour targets. One difference from your runs: here XCL_TEXTURE_LEVEL_PAGES takes texture pages away to fit 12 GB. That could leave a reader with no tiles mapped, the case CharlyRien's remap commit covers above. A run with XCL_TEXTURE_LEVEL_PAGES=0 to test that device-hung at 279 s, at 18.9 GB of local video memory, before any dump.

Edit, with the remap: I ported CharlyRien's remap commit (1df47cf5) onto #3094's copy (in record, before each copy: a sampled texture with no tiles mapped gets them again through vram::remap_superseded). Same tree and switches, 900 s: 3 331 frames, no device removal, no crash, peak commit 40.4 GB. The remap acted 11 times, all before 214 s (before world load), and the log counted 65 536 copies. The targets of two in-play frames read as before: 0, 1, 3, 4, 5 and 7 are 0; 2 and 6 have content. So on this card an unmapped reader isn't what keeps the colour targets at 0 either.

Edit, fresh graphics pipelines: after Joori's report on the title's issue, I moved the 5 630 stored gfx-*.pso driver blobs out (there were no mesh-*.pso) and ran the same tree again, so those pipelines were built in the run. The first in-play target dump (frame 1515) reads as before: targets 0, 1, 3, 4, 5 and 7 are 0, and 2 and 6 have content. So a stale graphics blob isn't the cause here either. The run then device-hung (0x887a0006) at 489 s while it was still building pipelines.

Edit, 16 windows: XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16, also with XCL_UMA_DRIVER=mixed:1536:1792 as in KDenKC's 5090 run. Four tries on this tree, with 8 or 4 preparation threads. Each time shader preparation took xcl.exe to ~41 GB of commit within a few minutes, before the title made its window, and my RAM watchdog ended it (free under 4 GB, 64 GB machine). The same window count on the tree without #3094 / #3089 peaks at about 34 GB in the first 180 s, so the merges aren't the cause: the 16-window preparation just doesn't fit next to the rest of the machine. So the view-window lead can't be tested on this 64 GB machine through re-translation. #3096 + #3097 would avoid that, but they're on main, which lacks #3039's system-memory pools that this card needs.

Edit, 16 windows reach play and light the G-buffer: the RAM problem above was shader preparation, so XCL_PREPARE=0 skips it and pipelines build as the title needs them. Four more runs on the same tree with nvidia-dev 54225f58 merged on top (#3090; its "console flag bits" warning never appears for this title, so it changes nothing here), XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16:

  • With XCL_UMA_DRIVER=mixed:1536:1792: RAM fits (~35 GB commit), but local video memory goes 1.5 GB over the 10.9 GB budget at ~430 s and submits stop. The 1 792 MB GPU_UPLOAD range is local memory, about that overage.
  • Without it (the NVIDIA default, coherent windows in system memory): one device hang (0x887a0006) at 76 s in the menus, then a run that froze at ~102 s. At 101.4 s the two-pass buffers alive reached the 340 MiB XCL_TWO_PASS_MB cap, two-pass ExecuteIndirects were skipped ("two-pass ExecuteIndirect skipped"), and within a second five queues were in Wait64BitValueX >= 0x713 (wait-before-signal, producer queue 1) that never completed: 0 draws for the remaining ~13 minutes, no device removal.
  • Same with XCL_TWO_PASS_MB=2048: no skip and no freeze, in play from about 4 minutes, ~15 000 draws per 2 s. The two-pass buffers alive peaked at 794 MiB. In-play target dump (frame 1825): target0 95.6 % non-black, target1 22.8 %, target3 53.6 %, target4 53.6 %, target5 41.0 % (2 and 6 as before, 7 ~1 %). Before this, 0, 1, 3, 4, 5 and 7 were 0 in every run on this card. The presented frames now show the scene (40–89 % non-black), not the black of every earlier run. Local video memory still climbs past the budget later (13.1 GB in use, 2.1 GB over, at 789 s). The 900 s run ended cleanly: exit 0x0, 2 146 frames, 0 device removals, 0 crashes, peak commit 43.8 GB, local video memory peak 13.4 GB.

So the 16 view windows are what lights the G-buffer on 12 GB too, as on KDenKC's 5090. Separately, skipping a two-pass ExecuteIndirect at the XCL_TWO_PASS_MB cap can deadlock a title whose later queue waits depend on that work. 340 MiB is too low for 16 windows here; waiting for buffers to come free instead of skipping would avoid the deadlock.

RTX 3060 12 GB (driver 581.80), i9-14900KF, 64 GB RAM, Windows 11 26200.

AI use: Claude Code (Claude Opus 5.5) merged the trees, ran the title, read the log and the dumps, and wrote this comment.

@KDenKC

KDenKC commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@Anon64, that matches our RTX 5090 exactly, and we think the remaining zeros are a separate cause from the copies. With a port of the same R32_UINT -> R9G9B9E5 fix on nvidia-dev, our format-10 lighting target and the luminance chain went from black to lit, like your target 6, while the 2560x1440 format 28/29 set stayed at 0.

On our side those zeros are the G-buffer, and the cause traced back to the view windows, not the alias copies:

Two ways to test it on the 3060, if you want to:

AI use: an agent swarm: Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.

imnicho added a commit to imnicho/xcl that referenced this pull request Nov 28, 2026
…format is copied from it (XCL_ALIAS_COPY=1)

A retail title packs light as R9G9B9E5 into R32_UINT textures with
unordered access and samples the same memory through R9G9B9E5 textures
it places at the same addresses (59 pairs: its sky, its light probes, the
bounced light its lighting pass adds). On the console the two are one
memory. Here the written one is GPU-owned and the sampled one is a
texture of its own, kept in step with title memory nothing writes, so
what is read through it is stale.

alias_copy keeps the title's placed textures by address. Where a sampled
one lies in the memory of a written one of the same size, levels, layers
and texel width, the written one's texels are copied into it on the GPU
through a buffer, where the title says the written one is written no
more for now: at its enhanced barrier of that texture (list xcl-dev#146) whose
access before is render target or unordered access, and at its legacy
transition out of those states. Only that is read of an enhanced
barrier; the two textures are moved to the copy states and back from the
states the legacy barriers left them in.

Off by default: with the switch off nothing is kept and each hook is one
atomic load.

The pairs by address and shape and the copy through a buffer follow the
format-aliased copies of xcl-dev#1989 by raylitebull.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Anon64

Anon64 commented Nov 28, 2026

Copy link
Copy Markdown

@KDenKC thanks, that fits what the 3060 shows. I tried XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 on the same tree (with #3094, #3089 and the remap port): twice, with 8 and then 4 preparation threads, xcl.exe reached ~41 GB of commit within about 2 minutes, before the title made its window, and my RAM watchdog ended it (64 GB machine). An earlier 16-window run on the tree without #3094 / #3089 got past that point, so I'm checking now which merge makes the difference. After that I'll try #3096 + #3097, which avoid the re-translation, and report the targets here.

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

@KDenKC

KDenKC commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@Anon64, a data point for your bisect, from the RTX 5090 (nvidia-dev-based, without #3094 / #3089): we don't see that commit spike with 16 windows in preparation. Our offline 16-window build peaked at 4.1 GB of process commit, and a launch preparation on that cache stayed in the same range. The ~36 GB our process shows comes later, in the title, and a 4-window run reaches the same level, so it isn't the windows here. That supports your reading that one of the merges on your tree makes the difference, not the 16 windows alone.

AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.

@Anon64

Anon64 commented Nov 28, 2026

Copy link
Copy Markdown

@KDenKC thanks. One thing against the merges, though: I ran the 16-window preparation on three trees for 180 s each, the base without #3094 / #3089 (nvidia-dev + #3039 + #2975), that plus #3094, and that plus #3089. All three peaked at 33.5–34.6 GB of process commit, so on this machine the spike shows without those two. What the three share and your tree may not is #3039 + #2975, plus 8 preparation threads here. I haven't split those yet.

It no longer blocks the test: with XCL_PREPARE=0 the 16-window run skips preparation and gets the G-buffer lit on the 3060 (numbers in my edited comment above, and the XCL_TWO_PASS_MB deadlock it hit on the way).

AI use: Claude Code (Claude Opus 5.5) checked the earlier run notes and wrote this reply.

imnicho added a commit to imnicho/xcl that referenced this pull request Nov 30, 2026
…e plane before its DSV is bound

A retail title's tiled lighting tests a console D16_UNORM_S8_UINT buffer
(R24G8 on the PC) with EQUAL, after a compute program wrote a count for
each pixel into its depth plane through a UAV. The title keeps the buffer
in a depth state all the while, so no transition says when the plane was
written, and a D3D12 copy cannot put a colour texture into a 24-bit plane.

With XCL_DEPTH_UAV_TWIN_R24=1 (off by default; the other depth twins stay
as they are) the depth plane of an R24G8 buffer gets a twin in depth_uav:
R16 for the console's 16-bit depth formats, else R32. resolve_uav makes
the title's UAV a view of it, and before_dsv_bind draws it into the plane,
by a pass of XCL's own that writes SV_Depth, before the title's bind of a
DSV of the buffer, when a dispatch was recorded since the buffer's last
pass. A 16-bit twin is read as a count and written as count * (1.0f /
65535), the product the title's vertex shader makes. The planes' states
are followed as the PC gets the title's transitions (PARK where the title
has the buffer in UNORDERED_ACCESS); the pass moves the depth plane to
DEPTH_WRITE and back and does not move the stencil plane.

After review of the first version on nvidia-dev:
- a clear of the twin makes the next bind draw it again (thehollowedone);
- the pass's views are kept one set an object of the buffer, and the
  object itself keeps their two heaps until the PC destroys it, so a
  recorded list never names a heap that is gone (thehollowedone);
- the pass's pipelines are made on a thread of their own where the twin
  is made, not on the recording thread at the first bind; a bind that
  comes before they are ready is left out and the next one draws
  (CharlyRien).

The SV_Depth pass and the 16-bit steps are raylitebull's, from xcl-dev#1989 and
its follow-up on amd-dev (3cda5be).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
imnicho added a commit to imnicho/xcl that referenced this pull request Nov 30, 2026
…format is copied from it

A retail title packs light as R9G9B9E5 into R32_UINT textures with
unordered access and samples the same memory through R9G9B9E5 textures it
places at the same addresses. On the console the two are one memory; here
the sampled one is a texture of its own that nothing writes.

With XCL_ALIAS_COPY=1 (off by default) the title's placed textures are
kept by address (alias_copy). Where a written texture leaves RENDER_TARGET
/ UNORDERED_ACCESS, as the PC list gets the transition in
resource_barrier_x (a legacy ResourceBarrier, or an enhanced barrier of
list xcl-dev#146 that barrier_groups made a transition of), its texels are copied
into each sampled texture of the same shape and texel width and another
format at its address, through a buffer made at the pair's first copy.

After review of the first version on nvidia-dev:
- the copies are planned from the barriers as the PC gets them, not from
  the console's (thehollowedone);
- a pair's buffer is made with the table's lock released (andrewDoing),
  and goes with the pair: late_release::hold_own lets it go once every
  queue is past the work submitted before (KDenKC);
- what a copy puts into the sampled texture is not read back into the
  title's memory: it gets no GPU writer in title_textures
  (claudetools-gh, who found that XG lays the sampled format out in more
  bytes than the written texture has under it);
- on a COMPUTE list a copy is left out, and counted, when a texture is in
  a state such a list cannot name (KDenKC).

The pairs by address and shape and the copy through a buffer are
raylitebull's, from xcl-dev#1989.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head bfafdf7, diff read, not a merge-check; it conflicts with main and CI / PR description are red, so not built or run):

  • Mostly superseded. Main's depth twins are based on this PR (credited in depth_uav.rs ~23): D32 / D16 / D32S8 depth twins, stencil twins and the Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146 barrier groups are on main (6580640, 48bc9f1, 7a3ac94, 4dd049f, 2b75212). Main copies only around the title's own transitions, so the twin sync on UAV barriers / DSV binds / clears isn't needed. The R9G9B9E5-over-R32_UINT format aliasing (format_alias.rs, XCL_FORMAT_ALIAS) is handled on main by textures sharing tiles on the same pages (placements.rs same_texels, c0258dc, 2c2bce3).
  • Still missing on main: a D24S8 / D16S8 depth-plane twin, which main refuses on purpose (~336-339). This PR's version is R32_FLOAT / R16_UNORM filled by a conversion pass (~98-116), but an R32_UINT view of it is created as R32_UINT (~162-166), so a shader reading raw bits gets float bits instead of the console's depth value.
  • About 4,350 lines, two unrelated features, no reason given for not splitting, no smoke run; AI use names no model.

Recommendation: close. If a game needs the D24S8 depth-plane twin, re-propose it on its own on top of main's depth_uav.rs, saying how a title's integer view reads it.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

imnicho added a commit to imnicho/xcl that referenced this pull request Dec 1, 2026
…format is copied from it

A retail title packs light as R9G9B9E5 into R32_UINT textures with
unordered access and samples the same memory through R9G9B9E5 textures it
places at the same addresses. On the console the two are one memory; here
the sampled one is a texture of its own that nothing writes.

With XCL_ALIAS_COPY=1 (off by default) the title's placed textures are
kept by address (alias_copy). Where a written texture leaves RENDER_TARGET
/ UNORDERED_ACCESS, as the PC list gets the transition in
resource_barrier_x (a legacy ResourceBarrier, or an enhanced barrier of
list xcl-dev#146 that barrier_groups made a transition of), its texels are copied
into each sampled texture of the same shape and texel width and another
format at its address, through a buffer made at the pair's first copy.

After review of the first version on nvidia-dev:
- the copies are planned from the barriers as the PC gets them, not from
  the console's (thehollowedone);
- a pair's buffer is made with the table's lock released (andrewDoing),
  and goes with the pair: late_release::hold_own lets it go once every
  queue is past the work submitted before (KDenKC);
- what a copy puts into the sampled texture is not read back into the
  title's memory: it gets no GPU writer in title_textures
  (claudetools-gh, who found that XG lays the sampled format out in more
  bytes than the written texture has under it);
- on a COMPUTE list a copy is left out, and counted, when a texture is in
  a state such a list cannot name (KDenKC).

The pairs by address and shape and the copy through a buffer are
raylitebull's, from xcl-dev#1989.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
imnicho added a commit to imnicho/xcl that referenced this pull request Dec 1, 2026
…e plane before its DSV is bound

A retail title's tiled lighting tests a console D16_UNORM_S8_UINT buffer
(R24G8 on the PC) with EQUAL, after a compute program wrote a count for
each pixel into its depth plane through a UAV. The title keeps the buffer
in a depth state all the while, so no transition says when the plane was
written, and a D3D12 copy cannot put a colour texture into a 24-bit plane.

With XCL_DEPTH_UAV_TWIN_R24=1 (off by default; the other depth twins stay
as they are) the depth plane of an R24G8 buffer gets a twin in depth_uav:
R16 for the console's 16-bit depth formats, else R32. resolve_uav makes
the title's UAV a view of it, and before_dsv_bind draws it into the plane,
by a pass of XCL's own that writes SV_Depth, before the title's bind of a
DSV of the buffer, when a dispatch was recorded since the buffer's last
pass. A 16-bit twin is read as a count and written as count * (1.0f /
65535), the product the title's vertex shader makes. The planes' states
are followed as the PC gets the title's transitions (PARK where the title
has the buffer in UNORDERED_ACCESS); the pass moves the depth plane to
DEPTH_WRITE and back and does not move the stencil plane.

After review of the first version on nvidia-dev:
- a clear of the twin makes the next bind draw it again (thehollowedone);
- the pass's views are kept one set an object of the buffer, and the
  object itself keeps their two heaps until the PC destroys it, so a
  recorded list never names a heap that is gone (thehollowedone);
- the pass's pipelines are made on a thread of their own where the twin
  is made, not on the recording thread at the first bind; a bind that
  comes before they are ready is left out and the next one draws
  (CharlyRien).

The SV_Depth pass and the 16-bit steps are raylitebull's, from xcl-dev#1989 and
its follow-up on amd-dev (3cda5be).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.