Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions crates/xcl/src/hle/d3d12x/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,41 @@ fn table_resources_of(this: *mut c_void, gfx: bool, slots: usize) -> Vec<usize>
out
}

/// Check the first 64 slots of each bound table. A texture descriptor copied as bytes still
/// samples the resource named by its heap index in word 0.
unsafe fn uncover_bound_tables(layout: Option<&Layout>, args: &[u8], u: &crate::gpu::uma::Uma) {
let Some(layout) = layout.filter(|_| super::title_textures::has_shadowed()) else { return };
const TABLE_SLOTS: usize = 64;

@gut0to gut0to Dec 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scan stops at 64 entries, but a D3D12 root descriptor range can be larger or unbounded (NumDescriptors = UINT_MAX). The current Layout traversal records the table start but no descriptor count, so a shadowed T# SRV after slot 63 is omitted and uncover_drawn never reactivates it. Could the scan follow the actual reachable range, or document a console-specific limit and add a slot-64 regression test? AI-assisted static review: I used an AI assistant to inspect this path; I checked the range limit against https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_descriptor_range1.

let mut resources = Vec::new();
for p in &layout.params {
let Param::Table { at } = *p else { continue };
let at = at as usize;
let Some(word) = args.get(at..at + 4) else { continue };
let offset = u32::from_le_bytes(word.try_into().unwrap()) as usize;
if offset == 0 {
continue;
}
let addr = u.base() + offset;
let mut table = [0u8; TABLE_SLOTS * 32];
if u.in_committed_window(addr, table.len()) {
std::ptr::copy_nonoverlapping(addr as *const u8, table.as_mut_ptr(), table.len());
} else {
super::title_textures::copy_readable(addr, &mut table);
}
for slot in table.chunks_exact(32) {
let index = u32::from_le_bytes(slot[..4].try_into().unwrap());
if slot[15] >> 4 < 8 || index == 0 {
continue;
}
let res = super::console_heap::named_by_index(index);
if res != 0 && res != super::console_heap::GONE && !resources.contains(&res) {
resources.push(res);
}
}
}
super::title_textures::uncover_drawn(&resources);
}

/// `XCL_CAPTURE_FRAME`: a draw or dispatch of the title's on `this` (`gfx`: with the graphics
/// root arguments), with the root arguments, heaps and pipeline it has, until the call returns.
pub(super) unsafe fn capture_work(this: *mut c_void, kind: impl FnOnce() -> super::capture::WorkKind, gfx: bool) -> super::capture::Guard {
Expand Down Expand Up @@ -1794,6 +1829,10 @@ unsafe fn prepare_two_pass_stage(this: *mut c_void, real_mesh_pso: usize, tp: &s
if pso == 0 {
return Err(if compute_pass { "two-pass compute pipeline" } else { "two-pass mesh pipeline" }.into());
}
if !compute_pass {
// Both passes use the same graphics root tables.
uncover_bound_tables(layout.as_deref(), &args, u);
}
let w = |k: usize| super::real::uma_window_va(k).unwrap_or(first);
Ok(StageBind { rs, pso, views: [va(io_at), res_va, w(0), w(1), w(2), w(3)] })
}
Expand Down Expand Up @@ -3473,6 +3512,7 @@ unsafe fn bind_abi(this: *mut c_void, list: &ID3D12GraphicsCommandList, pso: usi
}
let real = real as *mut c_void;
let pc = ID3D12PipelineState::from_raw_borrowed(&real).ok_or("pipeline")?.clone();
uncover_bound_tables(layout.as_deref(), &args, u);
let b = Bound { rs, views, pso: pc, io: views[0] };
rebind(this, list, &b, gfx);
Ok(b)
Expand Down
Loading
Loading