librashader/librashader-runtime-d3d12/src/descriptor_heap.rs

85 lines
2.8 KiB
Rust
Raw Normal View History

2023-02-06 17:05:19 +11:00
use windows::Win32::Graphics::Direct3D12::{
D3D12_DESCRIPTOR_HEAP_DESC, D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
2023-02-06 17:05:19 +11:00
D3D12_DESCRIPTOR_HEAP_TYPE_RTV, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER,
};
2023-01-24 18:02:27 +11:00
use d3d12_descriptor_heap::{D3D12DescriptorHeapType, D3D12ShaderVisibleDescriptorHeapType};
2023-01-24 18:02:27 +11:00
2023-02-01 09:50:47 +11:00
#[derive(Clone)]
2023-01-25 15:15:43 +11:00
pub struct SamplerPaletteHeap;
2023-02-01 09:50:47 +11:00
#[derive(Clone)]
pub struct CpuStagingHeap;
2023-02-01 16:16:06 +11:00
#[derive(Clone)]
pub struct RenderTargetHeap;
2023-02-01 09:50:47 +11:00
#[derive(Clone)]
2023-01-27 09:57:54 +11:00
pub struct ResourceWorkHeap;
2023-01-25 15:15:43 +11:00
#[derive(Clone)]
pub struct SamplerWorkHeap;
impl D3D12DescriptorHeapType for SamplerPaletteHeap {
2023-01-25 15:15:43 +11:00
// sampler palettes just get set directly
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
2023-01-24 18:02:27 +11:00
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
2023-01-24 18:02:27 +11:00
NodeMask: 0,
}
}
}
impl D3D12DescriptorHeapType for CpuStagingHeap {
2023-01-25 15:15:43 +11:00
// Lut texture heaps are CPU only and get bound to the descriptor heap of the shader.
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
2023-01-25 15:15:43 +11:00
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
NodeMask: 0,
}
}
}
impl D3D12DescriptorHeapType for RenderTargetHeap {
2023-02-01 16:16:06 +11:00
// Lut texture heaps are CPU only and get bound to the descriptor heap of the shader.
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
2023-02-01 16:16:06 +11:00
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
NodeMask: 0,
}
}
}
unsafe impl D3D12ShaderVisibleDescriptorHeapType for ResourceWorkHeap {}
impl D3D12DescriptorHeapType for ResourceWorkHeap {
2023-01-27 09:57:54 +11:00
// Lut texture heaps are CPU only and get bound to the descriptor heap of the shader.
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
2023-01-27 09:57:54 +11:00
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE,
NodeMask: 0,
}
}
}
unsafe impl D3D12ShaderVisibleDescriptorHeapType for SamplerWorkHeap {}
impl D3D12DescriptorHeapType for SamplerWorkHeap {
// Lut texture heaps are CPU only and get bound to the descriptor heap of the shader.
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE,
NodeMask: 0,
}
}
}