Skip to content

D3D12.X: clear BlendEnable on integer RTVs, strip unsupported UAVs, set T# levels, and pipeline PresentX - #1988

Open
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/world-d3d-gameplay-fixes
Open

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/world-d3d-gameplay-fixes

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes four D3D12.X / PC translation mismatches across graphics pipelines, resource allocation, texture views, and presentation:

  1. Integer RTV blend sanitization (real.rs): clears BlendEnable / LogicOpEnable on UINT / SINT render target slots across CreateGraphicsPipelineState, CreatePipelineState streams, translated GS/MS streams, and direct DXIL pipelines (sanitize_integer_rt_blend).
  2. Unsupported UAV flag stripping (device_x.rs, real.rs): checks is_typeless_uav_format first and queries D3D12_FEATURE_FORMAT_SUPPORT per device+format (uav_format_supported_by_caps, device_format_supports_uav) to strip ALLOW_UNORDERED_ACCESS on MSAA or host-unsupported formats across GetResourceAllocationInfo (pc_allocation_size), create_placed_resource_x, dev_create_committed_resource_x, and initial state mapping (pc_resource_desc_for_device, pc_initial_state_for_desc).
  3. SRV T# mip/MSAA metadata (real.rs): populates GFX10 BASE_LEVEL (t[3][15:12]), LAST_LEVEL (t[3][19:16], or log2(SampleDesc.Count) for MSAA), and MAX_MIP (t[5][7:4]) in srv_tsharp_from_desc / view_shape_desc.
  4. Pipelined PresentX (present.rs): integrates a Presenter-owned 2-slot PresentRing / PresentPipe over a 3-buffer swap chain (XCL_PRESENT_SYNC=1 forces 1 slot) with slot_dumps fence-safe readback tracking and Drop fence draining.

Part of #1833.

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs: is_typeless_uav_format-first ordering in uav_format_supported_by_caps / device_format_supports_uav, texture_format_allows_uav, strip_unsupported_uav_for_device, pc_resource_desc_for_device, pc_initial_state_for_desc, plus pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa.
  • crates/xcl/src/hle/d3d12x/present.rs: Presenter-owned PresentPipe / PresentRing (slot_dumps, prepare_pipelined_slot, mark_pipe_drained, Drop drain) and present_ring_overlaps_previous_frame_and_drains_cleanly.
  • crates/xcl/src/hle/d3d12x/real.rs: view_shape_desc, srv_tsharp_from_desc, sanitize_integer_rt_blend, pc_allocation_size / create_placed_resource_x / dev_create_committed_resource_x UAV sanitization, plus pso_blend_and_tsharp_tests.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto 0f293be (587d77b).
  • cargo check --workspace --tests: passed.
  • XCL_ADAPTER=warp cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=4: passed (pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa, present_ring_overlaps_previous_frame_and_drains_cleanly, and pso_blend_and_tsharp_tests included and passed).

Regression run

  • Standalone scripts/smoke.ps1 pair on 587d77b vs 0f293be has not been run locally. AMD and NVIDIA reviewers are invited to test on 587d77b vs 0f293be (including scripts/smoke.ps1 and graphics/MSAA/PresentX workloads) and post results in the comments.

Not tested

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

AI use

  • Antigravity assisted with implementation, rebase onto 0f293be, and unit tests; the author reviewed the diff and test output.

@gsucristo

Copy link
Copy Markdown
Contributor

Technical review findings:

Blocking

  1. uav_format_supported_by_caps falsely rejects typeless UAV textures on real D3D12 drivers (device_x.rs, uav_format_supported_by_caps): Checks (support1 & D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW) == 0 before is_typeless_uav_format(format). On real PC D3D12 drivers, CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT) for *_TYPELESS formats does not set TYPED_UNORDERED_ACCESS_VIEW (typed UAVs are created with concrete sibling formats), so this will wrongly strip ALLOW_UNORDERED_ACCESS from typeless textures.

Major

  1. Device-capability UAV stripping isn't wired into resource creation (device_x.rs create_placed_resource_x, real.rs dev_create_committed_resource_x): pc_resource_desc_for_device / strip_unsupported_uav_for_device are only called in allocation-size queries (get_resource_allocation_info_x, place_console_texture, pc_allocation_size), while create_placed_resource_x and dev_create_committed_resource_x still call static pc_resource_desc, so allocation size and resource creation can disagree.
  2. GPU UAF on p.dumps if a frame-dump fence wait times out (present.rs, present_now): If frame N-1 had XCL_FRAME_DUMP active and fence::wait timed out (non-fatal), frame N's prepare_pipelined_slot only waits for frame N-2, and present_now unconditionally runs p.dumps.clear(), freeing readback buffers while frame N-1's copy is still in flight.
  3. PRESENT_PIPE global side-table leaks/aliases across Presenter lifetime (present.rs, PresentPipe/PRESENT_PIPE): Drop for Presenter and p.disabled = true don't clear PRESENT_PIPE, leaking spare_alloc/slot_sources past teardown and risking pointer-reuse aliasing. Moving these fields directly onto the private Presenter struct avoids the extra mutex and fixes lifetime cleanly.

(The integer RTV blend sanitization and SRV T# mip/MSAA metadata parts look clean and would be easy to land if split out.)

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 505e974 (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: 989 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: pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa, present_ring_overlaps_previous_frame_and_drains_cleanly, integer_rtv_blend_sanitization_clears_uint_sint_and_preserves_float, rt_format_array_layout_matches_stream_parsing, srv_tsharp_populates_base_level_and_msaa_last_level.
  • 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: 999 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.

@raylitebull
raylitebull force-pushed the feat/world-d3d-gameplay-fixes branch from 505e974 to 587d77b Compare November 25, 2026 01:15
@raylitebull

Copy link
Copy Markdown
Member Author

Thanks for the thorough review and catch, @gsucristo!

Updated #1988 cleanly onto 0f293be (587d77b):

  • is_typeless_uav_format check order (device_x.rs): checked is_typeless_uav_format(format) before D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW inside uav_format_supported_by_caps and device_format_supports_uav, so *_TYPELESS textures keep ALLOW_UNORDERED_ACCESS on real D3D12 drivers (verified with Support1 = 0 typeless unit assertions).
  • Placed & committed resource wiring (real.rs): routed create_placed_resource_x and dev_create_committed_resource_x through pc_resource_desc_for_device.
  • Presenter-owned ring state & fence-safe dump cleanup (present.rs): moved PresentPipe fields directly onto Presenter (eliminating the global PRESENT_PIPE side-table + draining fences on Drop), and tracked readback dumps per slot (slot_dumps[prev]) so fence timeouts never UAF active readback buffers.

Verified locally (cargo check --workspace --tests + XCL_ADAPTER=warp cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=4).

@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run for this PR: head 505e974, 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: 505e9745f9c693f18922815fcc11fd69a248af28
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1619 (PresentX 1619)
presents per 2 s (last 3): 60 45 50
device removals: 0
crashes: 0
peak commit: 25355 MB

No device removals or crashes; 101 % of main's frames, 100 % 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.

@JJAutoCompare

Copy link
Copy Markdown

Empirical verification of xcl-dev/xcl PR #1988

  • PR head 587d77be2a7208c7e7972453b7f9074f19e10a04, fetched from live origin ref refs/pull/1988/head and tested in a clean detached checkout.
  • origin/main was aaa093657bd96a146c05c0c1a9b61149fe761453. git merge-tree --write-tree origin/main HEAD exited 0 with tree cb845f485f9a34bc2fa96360f702815bfba46100.

Tested

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175, wave range 8–32 and DoublePrecisionFloatShaderOps=0. DXC/DXIL 1.9.2609.5. rustc 1.100.0 (0ef1bc386 2026-11-09). Unoptimized dev/test profiles with debug info and incremental compilation disabled.
  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the GPU lock.
  • cargo test -p xcl --lib <filter> -- --show-output ran once per filter outside the GPU lock. 5 passed, 0 failed, 0 ignored, 0 skipped.
    • pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa
    • present_ring_overlaps_previous_frame_and_drains_cleanly
    • integer_rtv_blend_sanitization_clears_uint_sint_and_preserves_float
    • rt_format_array_layout_matches_stream_parsing
    • srv_tsharp_populates_base_level_and_msaa_last_level
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output completed in one pass through L:\XclTooling\Invoke-ArcTest.ps1 under the shared Arc lock. Cargo exited 101. Across 20 targets, libtest reported 1,044 passed, 26 failed, 45 ignored, 0 filtered. The log has 26 SKIPPED lines across 16 test identifiers, including skipped subcases. Libtest's passed count includes early returns, and skipped cases provide no coverage. All five targeted tests also passed in the workspace run.
  • xcl library tests reported 996 passed, 25 failed, 25 ignored. Of the 25 failures, 21 returned 0x80070057 from CreateComputePipelineState. The other four were assertions on fused multiply-add overflow, implicit-LOD sampling between mips, preservation of the high half during v_add_f16, and pixel-shader wave reductions.
  • e2e reported 2 passed and 1 failed. test_title_runs_and_game_folder_is_untouched observed a blue top-right pixel ([0, 0, 255, 255]) where the RSSetDepthBiasX(-1000.5) check expected green. The same title run logged a pass for the frame clock and PresentX back-buffer check.
  • Full output is in L:\XclTooling\sol-slot-8\tmp\pr1988-suite.log.

Not tested

  • No main baseline suite, merged-tree suite, or retail-title smoke runs on main and the PR head. The run establishes the outcomes at the PR head. Whether the PR introduced any of the failures remains unverified.
  • No AMD or NVIDIA GPU coverage. Optional sample data was unavailable (XCL_SAMPLE_* unset). The log also records early returns for host-specific audio and system-runtime checks.

AI use

  • T3 Code / Codex (gpt-6.2-sol) ran the build and tests and drafted this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against pr1988-suite.log and published this report.

Workspace SKIPPED lines

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::coalesced_guarded_runs_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_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: 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 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::f32_programs_on_the_gpu: f32 arithmetic, 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 compares, 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 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::integer_programs_on_the_gpu: integer carries, 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))

Failed workspace tests

gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3
gpu::dxil::ops_tests::doubles_match_cpu
gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run
gpu::dxil::round_tests::gpu_direct_f32_round_modes_dynamic_and_denormals
gpu::dxil::round_tests::gpu_direct_f32_round_modes_static
gpu::dxil::round_tests::gpu_direct_f32_round_preserved_denormal_times_inf_is_inf
gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu
gpu::recomp::tests::gpu_clamp_and_omod_per_instruction
gpu::recomp::tests::gpu_f64_literal_high_word
gpu::recomp::tests::gpu_f64_compares_with_nan
gpu::recomp::tests::gpu_f64_class_compare
gpu::recomp::tests::gpu_f64_rounding_and_conversions
gpu::recomp::tests::gpu_f64_roots
gpu::recomp::tests::gpu_f64_math_random
gpu::recomp::tests::gpu_frexp_f64_exp_and_mant
gpu::recomp::tests::gpu_float_compares_random
gpu::recomp::tests::gpu_ldexp_f64
gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction
gpu::recomp::tests::gpu_ps_image_sample_offset_implicit_lod_between_mips
gpu::recomp::tests::gpu_rndne_f64
gpu::recomp::tests::gpu_valu_16_and_64_bit
gpu::recomp::tests::gpu_wave64_ps_whole_wave_reductions
test_title_runs_and_game_folder_is_untouched


@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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.

6 participants