Merge branch 'night/crash' into local/next
This commit is contained in:
commit
a0ec11232e
2 files changed
+42
-5
No files matched your search
@@ -2848,8 +2848,10 @@ pub(crate) static TWINS: [std::sync::atomic::AtomicU64; 3] = [const { std::sync:
|
||||
/// no raw view. An AMD descriptor of a raw buffer is its address (48 bits),
|
||||
/// its bytes and flags; only one that says just that is changed, and only
|
||||
/// where what the handle points at is the descriptor. False: not moved.
|
||||
fn move_raw(at: D3D12_CPU_DESCRIPTOR_HANDLE, start: u64, bytes: u32, by: u32) -> bool {
|
||||
if !by.is_multiple_of(4) || by >= bytes {
|
||||
pub(crate) fn move_raw(at: D3D12_CPU_DESCRIPTOR_HANDLE, start: u64, bytes: u32, by: u32) -> bool {
|
||||
// (Off dwords too, as the typed view it stands for begins there: a view
|
||||
// of 16 bit values at an odd one.)
|
||||
if by >= bytes {
|
||||
return false;
|
||||
}
|
||||
let mut words = [0u8; 16];
|
||||
@@ -4003,7 +4005,7 @@ mod tests {
|
||||
let before = words();
|
||||
assert!(!move_raw(at, start + 16, 400, 8), "another address");
|
||||
assert!(!move_raw(at, start, 404, 8), "another size");
|
||||
assert!(!move_raw(at, start, 400, 2), "not a dword");
|
||||
assert!(!move_raw(at, start, 400, 400), "nothing left");
|
||||
assert_eq!(words(), before);
|
||||
if move_raw(at, start, 400, 8) {
|
||||
let moved = words();
|
||||
|
||||
@@ -1045,7 +1045,7 @@ void main(uint3 id : SV_DispatchThreadID, uint g : SV_GroupIndex) {
|
||||
gpu.device.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV) as usize,
|
||||
)
|
||||
};
|
||||
let names = ["raw", "structured 24 at 24", "structured 16", "typed u32", "typed u16", "typed 4 x u32", "constant buffer", "null raw"];
|
||||
let names = ["raw", "structured 24 at 24", "structured 16", "typed u32", "typed u16", "typed 4 x u32", "constant buffer", "raw, moved to 8"];
|
||||
let view = |i: usize, format: i32, first: u64, count: u32, stride: u32, raw: bool, null: bool| {
|
||||
let desc = D3D12_SHADER_RESOURCE_VIEW_DESC {
|
||||
Format: DXGI_FORMAT(format),
|
||||
@@ -1071,7 +1071,42 @@ void main(uint3 id : SV_DispatchThreadID, uint g : SV_GroupIndex) {
|
||||
view(base + 3, 42, 0, 1024, 0, false, false);
|
||||
view(base + 4, 57, 0, 2048, 0, false, false);
|
||||
view(base + 5, 3, 0, 256, 0, false, false);
|
||||
view(base + 7, 39, 0, 1, 0, true, true);
|
||||
// 1,024 dwords from 0 made in a heap the card does not see, moved
|
||||
// on by 8 bytes (`descriptor::host::move_raw`), copied in.
|
||||
// SAFETY: plain heap creation, slots of live heaps.
|
||||
unsafe {
|
||||
let beside: ID3D12DescriptorHeap = gpu
|
||||
.device
|
||||
.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
|
||||
Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||
NumDescriptors: 1,
|
||||
..Default::default()
|
||||
})
|
||||
.unwrap();
|
||||
let at = beside.GetCPUDescriptorHandleForHeapStart();
|
||||
let desc = D3D12_SHADER_RESOURCE_VIEW_DESC {
|
||||
Format: DXGI_FORMAT(39),
|
||||
ViewDimension: D3D12_SRV_DIMENSION_BUFFER,
|
||||
Shader4ComponentMapping: D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING,
|
||||
Anonymous: D3D12_SHADER_RESOURCE_VIEW_DESC_0 {
|
||||
Buffer: D3D12_BUFFER_SRV {
|
||||
FirstElement: 0,
|
||||
NumElements: 1024,
|
||||
StructureByteStride: 0,
|
||||
Flags: D3D12_BUFFER_SRV_FLAG_RAW,
|
||||
},
|
||||
},
|
||||
};
|
||||
gpu.device.CreateShaderResourceView(&buffer, Some(&desc), at);
|
||||
let moved = crate::descriptor::host::move_raw(at, buffer.GetGPUVirtualAddress(), 4096, 8);
|
||||
println!("the raw view was moved: {moved}");
|
||||
gpu.device.CopyDescriptorsSimple(
|
||||
1,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE { ptr: cpu + (base + 7) * step },
|
||||
at,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||
);
|
||||
}
|
||||
let desc = D3D12_CONSTANT_BUFFER_VIEW_DESC {
|
||||
// SAFETY: a live buffer.
|
||||
BufferLocation: unsafe { buffer.GetGPUVirtualAddress() },
|
||||
|
||||
Reference in new issue
Block a user