Repository navigation
Conversation
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 62de21cf: 4 finding(s). 4 are inline.
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.
| flags &= !4; | ||
| } | ||
| if (flags & 0x02) != 0 { | ||
| flags &= !(0x01 | 0x20); |
There was a problem hiding this comment.
ALLOW_RENDER_TARGET is now stripped from DS|RT textures, but the initial state still comes from the console flags, and pc_initial_state / pc_initial_state_for_desc only drop UNORDERED_ACCESS, so RENDER_TARGET (0x4) survives on a resource without the RT flag. A console texture with flags 0x03 created in RENDER_TARGET ends up with PC flags 0x02 and state 0x4, which CreatePlacedResource/CreateCommittedResource reject with E_INVALIDARG. In placed_in_heap_x (real.rs:4469) both the hr2 attempt and the hr3 committed fallback use the same st, so creation still fails. Deriving the state from the sanitized PC flags (drop RENDER_TARGET without 0x1, DEPTH_* without 0x2, UAV without 0x4) at every call site (real.rs 4469 / 4529, device_x.rs 1248) would cover this and the buffer case below.
| // with MSAA or ALLOW_DEPTH_STENCIL, and cannot set ALLOW_CROSS_ADAPTER (0x10) once layout | ||
| // is forced to TEXTURE_LAYOUT_UNKNOWN below. | ||
| if is_buffer { | ||
| flags &= !(0x01 | 0x02 | 0x08 | 0x20); |
There was a problem hiding this comment.
Buffers with ALLOW_DEPTH_STENCIL|ALLOW_UNORDERED_ACCESS now keep the UAV flag, but pc_initial_state still gets the original console flags (DS set) and turns an UNORDERED_ACCESS initial state into DEPTH_WRITE. A buffer with flags 0x06 and state 0x8 through create_placed_resource_x gets pc_initial_state(0x06, 0x8) = 0x10 (line 1248), and the buffer branch skips pc_initial_state_for_desc. The buffer is created in DEPTH_WRITE without the DS flag (rejected, or tracked in the wrong state), and the title's next UAV->X barrier has the wrong before-state. The new test checks flags only, not the state.
| if (flags & 4) != 0 && (samples > 1 || !texture_format_allows_uav(pc_format)) { | ||
| flags &= !4; | ||
| } | ||
| if (flags & 0x02) != 0 { |
There was a problem hiding this comment.
On DS|RT conflicts the code always keeps ALLOW_DEPTH_STENCIL and drops ALLOW_RENDER_TARGET, whatever the format. For a color format (e.g. R32_FLOAT 41 or R8G8B8A8 with flags 0x03), depth_typeless is None, so PC flags become 0x02 on a color format and the PC still refuses it. Where creation does succeed, the title's later CreateRenderTargetView / ClearRenderTargetView is invalid (dev_create_rtv has no flag guard) and the device is removed. The flag to keep should follow the format: DS for depth/typeless-depth families, RT otherwise.
| if (flags & 0x02) != 0 { | ||
| flags &= !(0x01 | 0x20); | ||
| } else { | ||
| flags &= !0x08; |
There was a problem hiding this comment.
DENY_SHADER_RESOURCE is stripped whenever ALLOW_DEPTH_STENCIL is absent, but flags & 0xFF still passes VIDEO_DECODE_REFERENCE_ONLY (0x40) and VIDEO_ENCODE_REFERENCE_ONLY (0x80), which require DENY_SHADER_RESOURCE on the PC. A resource with flags 0x48 or 0x88 becomes 0x40/0x80 and a previously valid desc is refused with E_INVALIDARG. The rule should be "strip 0x08 unless 0x02, 0x40 or 0x80 is set".
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
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)
What is in it
pc_resource_descincrates/xcl/src/hle/d3d12x/device_x.rsconverts consoleD3D12_RESOURCE_DESCstructures into PC descriptions, forcing buffer layouts toD3D12_TEXTURE_LAYOUT_ROW_MAJOR, texture layouts toD3D12_TEXTURE_LAYOUT_UNKNOWN, and masking flags to the lower byte (flags & 0xFF). Previously it only strippedALLOW_UNORDERED_ACCESSon depth/MSAA/unsupported-format textures, leaving other flag combinations that PC D3D12 rejects withE_INVALIDARG:D3D12_RESOURCE_DIMENSION_BUFFER) carryingALLOW_RENDER_TARGET(0x01),ALLOW_DEPTH_STENCIL(0x02),DENY_SHADER_RESOURCE(0x08), orALLOW_SIMULTANEOUS_ACCESS(0x20). These bits are stripped before depth-UAV stripping so a buffer withALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESSstill keepsALLOW_UNORDERED_ACCESS.ALLOW_DEPTH_STENCIL(0x02) withALLOW_RENDER_TARGET(0x01) orALLOW_SIMULTANEOUS_ACCESS(0x20), settingDENY_SHADER_RESOURCE(0x08) withoutALLOW_DEPTH_STENCIL, settingALLOW_SIMULTANEOUS_ACCESS(0x20) on multisampled (SampleDesc.Count > 1) textures, or settingALLOW_CROSS_ADAPTER(0x10) once texture layout is forced toD3D12_TEXTURE_LAYOUT_UNKNOWN.Valid PC combinations such as
ALLOW_DEPTH_STENCIL | DENY_SHADER_RESOURCEon textures andALLOW_SIMULTANEOUS_ACCESSon single-sample non-depth textures are preserved unchanged.This change also updates
console_types_and_descs_become_pc_onesto expect buffer-invalidALLOW_SIMULTANEOUS_ACCESS(0x20) to be stripped from its buffer test descriptor (0x14instead of0x34), and addspc_resource_desc_sanitizes_invalid_pc_flag_combinationscovering unit assertions and real D3D12CreateCommittedResourceverification (rejecting all 7 unsanitized descriptors and accepting all 9 sanitized descriptors).Tested
CreateCommittedResourceverification (cargo test -p xcl --lib -- hle::d3d12x::device_x::tests::):pc_resource_desc_sanitizes_invalid_pc_flag_combinationsfails becausepc_resource_descleavesDENY_SHADER_RESOURCEset on anALLOW_RENDER_TARGETtexture (0x09instead of0x01), andCreateCommittedResourcerejects all 7 unsanitized invalid flag combinations withE_INVALIDARG.21 passed, 0 failed, includingpc_resource_desc_sanitizes_invalid_pc_flag_combinationsandconsole_types_and_descs_become_pc_ones.cargo test --workspace --no-fail-fast -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::, RTX 5070 Ti + DXC 1.9):41 binaries, 2712 passed, 4 failed, 49 ignored, 9 filtered; 27 SKIPPED (22 no wave64, 3 refused #1426, 2 no heap windows). All 4 failures are pre-existing geometry test failures onmain(3b6a91ed, tracked in Tests: fix 4 geometry tests broken on main by split-ES safe-barrier and no-store epilogue merges #3411):gpu::dxil::geometry_tests::gpu_geometry_msg_gs_done_records,gpu::dxil::geometry_tests::msg_gs_done_emits_in_dxil,gpu::dxil::lower_geom::tests::gpu_epilogue_filters_oob_triangles_and_no_store_emits, andgpu::dxil::lower_mem::stage_guard_tests::geometry_export_rejected.Regression run
Not tested
22wave64 tests skipped on RTX 5070 Ti).ea3b5e4dor paths requiringuma_driver::tests::kernel driver tests.0x40/0x80(left untouched here to avoid overlap with D3D12.X: the console's acceleration-structure resource flag becomes UAV, not a video flag #3141).AI use
Used an AI coding assistant to audit
pc_resource_descflag handling, author the minimal invariant fix and synthetic unit/D3D12 tests, and run local verification.