Repository navigation
Conversation
Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s |
bmjask
left a comment
There was a problem hiding this comment.
Review of 37fc811b: 5 finding(s). 4 are inline. These are on lines outside the diff:
crates/xcl/src/hle/d3d12x/real.rs:4412: lut3d::created still gets state & PC_RESOURCE_STATES, but the fallback in placed_in_heap_x / own_memory_if_larger_on_the_pc now creates the resource in the sanitized st (0x8 dropped, DS|UAV becomes DEPTH_WRITE) or in COMMON. A placed 3D sRGB+UAV texture requested in UNORDERED_ACCESS is created in COMMON while lut3d tracks UNORDERED_ACCESS, which gives barrier before-state mismatches and wrong dumps with XCL_DUMP_TARGETS/capture.
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| let mut used_state = state; | ||
| if hr < 0 && desc != 0 && crate::gpu::shader::readable(desc, 0x38) { | ||
| let x: [u8; 0x38] = (desc as *const [u8; 0x38]).read_unaligned(); | ||
| let d = pc_reserved_desc_for_device(this, &x); |
There was a problem hiding this comment.
The reserved fallback applies pc_resource_desc's format promotions (85/86/115 -> 28, 116/117 -> 10, 118-120 -> 44), which change bytes per texel and therefore the 64 KB tile count and shape. Nothing in the UpdateTileMappings / GetResourceTiling hooks accounts for that. A reserved B5G6R5 RT|UAV texture (test case 2 here) becomes R8G8B8A8, with twice the tiles, but the title maps tiles computed for the console layout. Only part of the resource is backed, so unmapped regions read as zero and drop writes. Before, creation failed loudly; now it succeeds and the data is silently wrong.
| let clear_changed = clear != 0 | ||
| && clear_d != clear | ||
| && (clear as *const [u8; 24]).read_unaligned() != clear_buf; | ||
| if d != x || st as usize != state || clear_changed { |
There was a problem hiding this comment.
This hook is on every adopted PC device's vtable, so the fallback also rewrites PC-native descriptions that should be rejected. It strips DS|UAV and sRGB+UAV, masks flags to 0xFF and drops state bits. A PC or XCL-internal CreateReservedResource with DS|UAV, or R8G8B8A8_UNORM_SRGB+UAV in UNORDERED_ACCESS, now gets S_OK and a resource without the UAV flag instead of E_INVALIDARG. A later CreateUnorderedAccessView on it is invalid, so the caller's bug is hidden. Only ROW_MAJOR is checked for parity.
| mut create: impl FnMut(usize, usize, usize) -> HRESULT, | ||
| ) -> HRESULT { | ||
| let mut hr = create(desc, state, clear); | ||
| let mut used_state = state; |
There was a problem hiding this comment.
When the first call succeeds, used_state is the raw console state, console-only bits included (e.g. 0x100004). The fallback branch uses the sanitized st, and the placed path masks with & PC_RESOURCE_STATES. reserved_3d then hands lut3d::created a value that isn't a PC state, and it's tracked and logged as one.
| let dim = u32::from_le_bytes(d[0..4].try_into().unwrap()); | ||
| if dim != D3D12_RESOURCE_DIMENSION_BUFFER.0 as u32 { | ||
| let orig_layout = u32::from_le_bytes(x[0x2C..0x30].try_into().unwrap()); | ||
| let layout = if orig_layout > 3 { |
There was a problem hiding this comment.
pc_reserved_desc_for_device keeps texture layout 0 (UNKNOWN) as it is, but PC CreateReservedResource only accepts 64KB_UNDEFINED_SWIZZLE / 64KB_STANDARD_SWIZZLE for textures. A console reserved Texture2D with Layout=0 plus console flag bits fails, the retry still has layout 0, and it fails again, which is the case the fallback was meant to cover.
Unifies console resource description, resource flag, initial state, optimized clear value, and heap property/flag sanitization across CreateCommittedResource(X), display target creation, CreatePlacedResource(X) and its fallbacks, and CreateReservedResource(1). Consolidates and resolves all review findings from xcl-dev#3291, xcl-dev#3414, xcl-dev#3418, and xcl-dev#3376: - pc_resource_desc enforces PC buffer/texture flag invariants (buffer strips DS/DENY_SRV/SIMULTANEOUS_ACCESS while keeping RT/UAV; texture RT|DS resolves by format family; depth strips UAV/SIMULTANEOUS_ACCESS; DENY_SHADER_RESOURCE requires DS or video reference flags; MSAA strips SIMULTANEOUS_ACCESS; textures strip ALLOW_CROSS_ADAPTER). - pc_initial_state_for_desc derives initial state from sanitized PC flags and drops RENDER_TARGET, DEPTH_WRITE/READ, and UNORDERED_ACCESS when the matching PC flag is absent; placed console buffers created in UNORDERED_ACCESS or RAYTRACING_ACCELERATION_STRUCTURE promote ALLOW_UNORDERED_ACCESS before pc_initial_state_for_desc so place_at_title_address / sparse::place_buffer_in keep the UAV flag and state. - pc_clear_for_resource_desc handles buffers/non-targets before reading the pointer, maps depth families (including typeless/partially-typeless formats) to their typed DSV clear format, resolves typeless/UNKNOWN clears on concrete RTs, and is used across every creation and fallback path. - dev_create_committed_resource_x routes non-buffer ALLOW_DISPLAY resources through create_display_target (falling through to the existing path if it fails), retries sanitized heap properties (preserving CPU-visible console buffers as CUSTOM+L0) and heap flags only on failure, and logs both raw and tried values on failure. - dev_create_reserved_resource(1) adds a console-only fallback (skipping own_work and PC-native invalid calls) that maps console layouts (0 or >3) to 64KB_UNDEFINED_SWIZZLE, refuses bytes-per-texel-changing format promotions, and propagates the actual PC state to lut3d/reserved_3d. Assisted-by: Antigravity (Gemini 4 Neon) Assisted-by: Claude Code (Claude Opus 5.5)
Console
CreatePlacedResource(placed_in_heap_x/own_memory_if_larger_on_the_pc) andCreateReservedResource(1)incrates/xcl/src/hle/d3d12x/real.rsmissed parts of the PC description/state/clear sanitization already used byCreateCommittedResourceandCreatePlacedResourceX:placed_in_heap_xandown_memory_if_larger_on_the_pccalledpc_resource_desc(&x)instead ofpc_resource_desc_for_device(this, &x)andpc_initial_state(orig_flags, state)instead ofpc_initial_state_for_desc(orig_flags, pc_flags, state). Whenpc_resource_desc_for_devicestrippedD3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESSfrom a non-depth texture (for example an sRGB or unsupported-UAV format),D3D12_RESOURCE_STATE_UNORDERED_ACCESS(0x8) remained in the initial state, causing both the placed retry and the committed fallback to fail withE_INVALIDARG.dev_create_reserved_resourceanddev_create_reserved_resource1had no sanitization fallback when PC D3D12 refused a console format, console tile layout (> 3), console resource flag bits, console initial-state bits,ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS, unsupported texture UAV flags, or promoted clear-value format.What is in it
crates/xcl/src/hle/d3d12x/real.rs:placed_in_heap_xandown_memory_if_larger_on_the_pcto usepc_resource_desc_for_device(this, &x)andpc_initial_state_for_desc(orig_flags, pc_flags, state as u32)so stripped UAV flags also dropUNORDERED_ACCESSfrom the initial state and per-device UAV format checks are honored.pc_reserved_desc_for_device(preserving PC layouts<= 3so invalid PC layouts likeROW_MAJORare still rejected like the host driver, while mapping console tile layouts> 3toD3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE) andcreate_reserved_with_fallbackfordev_create_reserved_resourceanddev_create_reserved_resource1, retrying only when sanitization changed the description, initial state, or clear value, and callingdepth_uav::note_createdon texture fallback success.reserved_placed_sanitize_testscovering consoleCreateReservedResource(D32+UAV depth target with console flags/layout/state,B5G6R5RT+UAV with promoted clear format),CreateReservedResource1(sRGB+UAV inUNORDERED_ACCESSstate), andCreatePlacedResource(dev_create_placed_resource_x) with sRGB+UAV inUNORDERED_ACCESSstate.Tested
32.0.16.1074),rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (1.9.2609).reserved_placed_sanitize_testsfailed on WARP with0x80070057(E_INVALIDARG).cargo test -p xcl --lib -- hle::d3d12x::real::reserved_placed_sanitize_tests::): 2 passed, 0 failed (0.09s, D3D12 debug layer enabled).cargo test -p xcl --test d3d12_create_reserved_resource): 3 passed, 0 failed (0.30s), includingpc_reserved_resources_match_host_driver(invalid_tex2d_row_majorstill rejected with0x80070057).cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::withXCL_DXC_DIRset to DXC 1.9): 2601 passed, 0 failed, 49 ignored, 9 filtered (532.3s).SKIPPEDlines in workspace run (26 total): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426(V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), 2no heap windows(defaultXCL_HEAP_WINDOWSoff).cargo build --release -p xcl -j 4) succeeded and passed the paired 150 s title smoke below.Regression run
main (
f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):PR (
37fc811b087ae6067493e8865613017c24add47e):Not tested
uma_driver::tests::andtest_title_runs_and_game_folder_is_untouched(filtered out of the workspace test run).CreateReservedResource1with a non-nullID3D12ProtectedResourceSession.AI use