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 5dc64ea7: 2 finding(s). 2 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.
| @@ -511,6 +510,9 @@ pub unsafe fn shared_heap(dev: &ID3D12Device) -> bool { | |||
| fill_nulls(dev, cpu, inc, crate::gpu::recomp::MEM_HEAP_BASE, cap, at); | |||
There was a problem hiding this comment.
The fix for slots 20/21 looks right, but fill_nulls still starts at MEM_HEAP_BASE, so it writes Texture2D null SRV/UAVs over the window slots 4..19, which are reserved for raw buffer UAVs too. set_window_views only rewrites windows.len().max(MAX_WINDOWS) slots (4 for a normal layout), so slots 8..19 keep Texture2D nulls. A heap-windows shader that reaches window k >= count (a cached PSO translated for a wider layout, or the #3096 expansion) hits the same type mismatch this PR fixes for 20/21 (GBV 939/941, undefined on hardware). Starting fill_nulls at MEM_NULL_STORE + 1 (where Global.next starts), and having null_window_views write raw null UAVs for all of MEM_HEAP_BASE..=MEM_NULL_STORE once, would fix the whole region.
| }); | ||
| // Written after `fill_nulls` so the two out-of-layout raw buffer null UAVs at | ||
| // `MEM_NULL_LOAD` and `MEM_NULL_STORE` are not overwritten with Texture2D null SRV/UAVs. | ||
| null_window_views(dev, cpu, inc); |
There was a problem hiding this comment.
Not certain about this one: with slots 20/21 holding raw buffer UAVs again, a stale or garbage T# index that lands on them reaches a raw UAV through a Texture2D access. The image guard only checks tw0 < VIEW_HEAP_MAX_SRV, with no lower bound past the window region. A T# with word 0 = 20 indexes ResourceDescriptorHeap[20] as Texture2D and [21] as RWTexture2D and finds a 4-byte raw buffer UAV. The MEM_HEAP_BASE doc already records that a raw buffer UAV read as a texture hangs NVIDIA GPUs, and the shared_heap comment's promise that garbage T# indexes read zeros no longer holds for 4..21.
XCL_HEAP_FLAT=1 reads a compute program's heap memory windows without a branch (2f52333): the access runs for every lane, and a lane outside the windows or under a false guard (a buffer index past num_records, an EXEC- masked lane) had its value set to zero afterwards. But its access went to window 0's descriptor, at the address it was given, so it read window 0's memory at an address the program never reaches: the guarded form branches around it, and the HLSL accessors (409cf07) send it to the null view MEM_NULL_LOAD. The direct form now selects MEM_NULL_LOAD for it as well, so it touches no window's memory. The scalar flat read (s_buffer_load in the flat form, `scalar_flat_read`) picked window 0 the same way for an address outside the windows; it takes the null view too (its dwords were and are masked as well). On the RTX 5090, the retail title with XCL_HEAP_FLAT=1 hung on its first world frame (DRED: a page fault in a compute dispatch); with it off it ran past 200 s. Test: raw_loads_in_root_windows_are_branchless checks that the flat form selects the null-load view, and, for a program of one s_buffer_load alone, that the scalar flat read does (it fails without the scalar change). MEM_NULL_LOAD is only the null view once xcl-dev#3349 writes it after fill_nulls in shared_heap; before that, descriptor 20 holds a Texture2D null SRV. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
merge-check
main (base): this PR merged into base: verdict: safe to merge (the AI use section should still name the tool and model) |
XCL_HEAP_FLAT=1 reads a compute program's heap memory windows without a branch (2f52333): the access runs for every lane, and a lane outside the windows or under a false guard (a buffer index past num_records, an EXEC- masked lane) had its value set to zero afterwards. But its access went to window 0's descriptor, at the address it was given, so it read window 0's memory at an address the program never reaches: the guarded form branches around it, and the HLSL accessors (409cf07) send it to the null view MEM_NULL_LOAD. The direct form now selects MEM_NULL_LOAD for it as well, so it touches no window's memory. The scalar flat read (s_buffer_load in the flat form, `scalar_flat_read`) picked window 0 the same way for an address outside the windows; it takes the null view too (its dwords were and are masked as well), and so does the carry case's slot for a high dword of one (`high_one_slot`). On the RTX 5090, the retail title with XCL_HEAP_FLAT=1 hung on its first world frame (DRED: a page fault in a compute dispatch); with it off it ran past 200 s. Test: raw_loads_in_root_windows_are_branchless checks that the flat form selects the null-load view, and, for a program of one s_buffer_load alone, that the scalar flat read does (it fails without the scalar change). the_flat_read_carry_rewrite_keeps_the_null_select (module/opt.rs) checks that the optimizer's FlatRead carry rewrite turns the read's bounds test and slot into carry selects and leaves its null select in place. Stacked on xcl-dev#3349: MEM_NULL_LOAD is only the null view once xcl-dev#3349 writes it after fill_nulls in shared_heap; before that, descriptor 20 holds a Texture2D null SRV. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write the shared view heap's out-of-layout null raw buffer UAVs (
MEM_NULL_LOADandMEM_NULL_STORE) afterfill_nullsinconsole_heap::shared_heap(crates/xcl/src/hle/d3d12x/console_heap.rs), sofill_nullsno longer overwrites those twoRWByteAddressBuffernull UAV slots withTexture2Dnull SRV/UAV descriptors.What is in it
crates/xcl/src/hle/d3d12x/console_heap.rs:null_window_views(dev, cpu, inc)after thefill_nulls(dev, cpu, inc, MEM_HEAP_BASE, cap, at)pass inshared_heap. Previouslynull_window_viewsran first andfill_nullsimmediately overwroteMEM_NULL_LOAD(even index20) with aTexture2Dnull SRV andMEM_NULL_STORE(odd index21) with aTexture2Dnull UAV, causing descriptor-type mismatches wheneverXCL_HEAP_WINDOWS=1shaders redirected out-of-layout memory loads/stores to those slots (set_window_viewsonly writesMEM_HEAP_BASE..MEM_NULL_LOAD).ID3D12Debug1::SetEnableGPUBasedValidation(true)) testhle::d3d12x::console_heap::tests::shared_heap_preserves_null_window_raw_uavsthat initializesshared_heap, dispatches a Direct DXIL SM 6.6 compute shader accessingResourceDescriptorHeap[MEM_NULL_LOAD]andResourceDescriptorHeap[MEM_NULL_STORE]asRWByteAddressBuffer, verifies readback (0 ^ 0xA5A5_5A5A), and asserts0D3D12 debug/GBV errors.Tested
console_heaptests (cargo test -p xcl --lib -j 4 -- hle::d3d12x::console_heap::andcargo test -p xcl --test console_heap_contract -j 4):shared_heap_preserves_null_window_raw_uavsfailed on WARP+GBV with two D3D12 GPU-based validation errors ([id=939]Descriptor Heap Index: [20], Descriptor Type in Heap: D3D12_DESCRIPTOR_RANGE_TYPE_SRV, Register Type: D3D12_DESCRIPTOR_RANGE_TYPE_UAVand[id=941]UAV Dimension Expected: D3D12_UAV_DIMENSION_BUFFER, UAV Dimension In Descriptor: D3D12_UAV_DIMENSION_TEXTURE2D, Descriptor Heap Index: [21]).26 passed; 0 failed(0.27s) inhle::d3d12x::console_heap::(includingshared_heap_preserves_null_window_raw_uavswith0GBV errors and0xA5A5_5A5Areadback) and9 passed; 0 failed(0.01s) inconsole_heap_contract.rustc 1.99.0, RTX 5070 Ti driver32.0.16.1074, DXC1.9.2609.5):cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::2610 passed; 0 failed; 49 ignored(128.2s).SKIPPED:26runtimeSKIPPEDlines (21wave64-only checks on this wave32 RTX 5070 Ti,3wave32 per-lane#1426op refusals,2heap-windows opt-in checks).Regression run
Baseline (
mainancestorf0e8fdd5c3942ddd399d5ee11384c8595c5aacff) and this PR (5dc64ea70b240d48ee0da31b1deff64ae1260710), 150 s on RTX 5070 Ti:Not tested
set_window_viewsslot expansion pastwindows.len().max(MAX_WINDOWS)(left untouched for#3096).AI use
Claude Opus 5.5for initial patch/GBV test;Gemini 4 Neonfor verification and PR maintenance); all code, tests, and regression runs were validated locally.