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
21 changes: 19 additions & 2 deletions crates/xcl/src/hle/d3d12x/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct State {
/// the title's graphics root signature (a PC object), bound before a draw with an
/// untranslated pipeline – created with it – since SetGraphicsRootSignature binds nothing
rs_gfx: usize,
/// the title's compute root signature (a PC object), preserved for internal-pass restoration
rs_cs: usize,
pso: usize,
allocator: usize,
/// unified memory of this recording (io, argument tables)
Expand Down Expand Up @@ -82,6 +84,7 @@ pub(super) fn reset(list: *mut c_void, allocator: usize, initial_pso: usize) {
s.layout_gfx = None;
s.args_gfx.clear();
s.rs_gfx = 0;
s.rs_cs = 0;
(old, std::mem::take(&mut s.uma))
});
console_list::hold_until_reset(old, blocks);
Expand All @@ -97,15 +100,16 @@ pub(super) fn clear_state(list: *mut c_void, pso: usize) {
s.layout_gfx = None;
s.args_gfx.clear();
s.rs_gfx = 0;
s.rs_cs = 0;
});
}

/// Carry bound pipeline and root-signature / root-argument state from `from` to `to` across a
/// deferred mid-list split (`to` records into `allocator` with its own fresh UMA arena while
/// `from` retains its previously allocated blocks until `allocator` resets).
pub(super) fn inherit_for_split(from: *mut c_void, to: *mut c_void, allocator: usize) {
let (layout, args, layout_gfx, args_gfx, rs_gfx, pso) = with(from, |s| {
(s.layout.clone(), s.args.clone(), s.layout_gfx.clone(), s.args_gfx.clone(), s.rs_gfx, s.pso)
let (layout, args, layout_gfx, args_gfx, rs_gfx, rs_cs, pso) = with(from, |s| {
(s.layout.clone(), s.args.clone(), s.layout_gfx.clone(), s.args_gfx.clone(), s.rs_gfx, s.rs_cs, s.pso)
});
let (old, blocks) = with(to, |s| {
let old = std::mem::replace(&mut s.allocator, allocator);
Expand All @@ -115,6 +119,7 @@ pub(super) fn inherit_for_split(from: *mut c_void, to: *mut c_void, allocator: u
s.layout_gfx = layout_gfx;
s.args_gfx = args_gfx;
s.rs_gfx = rs_gfx;
s.rs_cs = rs_cs;
s.pso = pso;
(old, std::mem::take(&mut s.uma))
});
Expand Down Expand Up @@ -811,6 +816,7 @@ pub(super) unsafe extern "system" fn set_compute_root_signature(this: *mut c_voi
with(this, |s| {
s.args = vec![0u8; layout.as_ref().map_or(0, |l| l.size as usize)];
s.layout = layout;
s.rs_cs = rs as usize;
});
}

Expand Down Expand Up @@ -1056,6 +1062,17 @@ pub(super) fn tracked_pso(list: *mut c_void) -> usize {
.map_or(0, |s| s.pso)
}

/// Tracked console `(graphics_root_signature, compute_root_signature)` on `list` for restoring
/// PC root signatures after an internal graphics/compute sync pass.
pub(super) fn tracked_root_sigs(list: *mut c_void) -> (usize, usize) {
STATES
.lock()
.unwrap()
.as_ref()
.and_then(|m| m.get(&(list as usize)))
.map_or((0, 0), |s| (s.rs_gfx, s.rs_cs))
}

#[cfg(test)]
mod tests {
use super::super::{device_x, list_x, pso_async, real, title_list};
Expand Down
Loading
Loading