Skip to content
Closed
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
29 changes: 13 additions & 16 deletions crates/xcl/src/hle/d3d12x/device_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,24 +945,21 @@ pub(super) unsafe extern "system" fn create_placed_resource_x(this: *mut c_void,
/// 0xFFFFFFFF = undefined for a buffer) in the initial state's place.
pub(super) unsafe extern "system" fn create_placed_resource_layout_x(this: *mut c_void, va: u64, desc: *const u8, layout: u32, clear: *const c_void, riid: *const GUID, ppv: *mut *mut c_void) -> HRESULT {
real::note_newer_device_method(133);
create_placed_resource_x(this, va, desc, layout_state(layout), clear, riid, ppv)
let state = layout_state_for_desc(layout, desc as usize);
let hr = create_placed_resource_x(this, va, desc, state, clear, riid, ppv);
// the state an enhanced barrier's UNDEFINED layout before starts from
if hr >= 0 && !ppv.is_null() && !(*ppv).is_null() {
super::enhanced_barrier::note_state(*ppv as usize, state);
}
hr
}

/// The resource state (D3D12_RESOURCE_STATES) of a D3D12_BARRIER_LAYOUT (undefined: COMMON).
pub(super) fn layout_state(layout: u32) -> u32 {
match layout {
1 => 0xAC3, // generic read
2 => 0x4, // render target
3 => 0x8, // unordered access
4 => 0x10, // depth write
5 => 0x20, // depth read
6 => 0xC0, // shader resource (all stages)
7 => 0x800, // copy source
8 => 0x400, // copy dest
9 => 0x2000, // resolve source
10 => 0x1000, // resolve dest
_ => 0,
}
/// The resource state (D3D12_RESOURCE_STATES) of a D3D12_BARRIER_LAYOUT (undefined: COMMON),
/// stripping buffer-only bits (`VERTEX_AND_CONSTANT_BUFFER | INDEX_BUFFER | INDIRECT_ARGUMENT`)
/// when `desc` is a texture so creation matches `enhanced_barrier::Barrier`.
pub(super) unsafe fn layout_state_for_desc(layout: u32, desc: usize) -> u32 {
let texture = desc != 0 && crate::gpu::shader::readable(desc, 4) && (desc as *const u32).read_unaligned() != D3D12_RESOURCE_DIMENSION_BUFFER.0 as u32;
super::enhanced_barrier::layout_state(layout, texture).unwrap_or(0)
}

/// device #38 GetCopyableFootprints: a console resource desc the PC rejects (total stays
Expand Down
Loading
Loading