From f4043cd1cc1c829dc38cb92f5edbeca74ea75471 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Fri, 4 Oct 2019 00:52:50 +0200 Subject: [PATCH] Add root descriptor commands and add trait derives --- src/command_list.rs | 69 +++++++++++++++++++++++++++++++++++++++------ src/descriptor.rs | 15 +++++++--- 2 files changed, 72 insertions(+), 12 deletions(-) diff --git a/src/command_list.rs b/src/command_list.rs index a9a787b487..7db8d120b7 100644 --- a/src/command_list.rs +++ b/src/command_list.rs @@ -103,14 +103,7 @@ impl GraphicsCommandList { ptr::null() }; unsafe { - self.ClearDepthStencilView( - dsv, - flags.bits(), - depth, - stencil, - num_rects, - rects, - ); + self.ClearDepthStencilView(dsv, flags.bits(), depth, stencil, num_rects, rects); } } @@ -229,6 +222,36 @@ impl GraphicsCommandList { } } + pub fn set_compute_root_constant_buffer_view( + &self, + root_index: u32, + buffer_location: GpuAddress, + ) { + unsafe { + self.SetComputeRootConstantBufferView(root_index, buffer_location); + } + } + + pub fn set_compute_root_shader_resource_view( + &self, + root_index: u32, + buffer_location: GpuAddress, + ) { + unsafe { + self.SetComputeRootShaderResourceView(root_index, buffer_location); + } + } + + pub fn set_compute_root_unordered_access_view( + &self, + root_index: u32, + buffer_location: GpuAddress, + ) { + unsafe { + self.SetComputeRootUnorderedAccessView(root_index, buffer_location); + } + } + pub fn set_graphics_root_descriptor_table( &self, root_index: u32, @@ -238,4 +261,34 @@ impl GraphicsCommandList { self.SetGraphicsRootDescriptorTable(root_index, base_descriptor); } } + + pub fn set_graphics_root_constant_buffer_view( + &self, + root_index: u32, + buffer_location: GpuAddress, + ) { + unsafe { + self.SetGraphicsRootConstantBufferView(root_index, buffer_location); + } + } + + pub fn set_graphics_root_shader_resource_view( + &self, + root_index: u32, + buffer_location: GpuAddress, + ) { + unsafe { + self.SetGraphicsRootShaderResourceView(root_index, buffer_location); + } + } + + pub fn set_graphics_root_unordered_access_view( + &self, + root_index: u32, + buffer_location: GpuAddress, + ) { + unsafe { + self.SetGraphicsRootUnorderedAccessView(root_index, buffer_location); + } + } } diff --git a/src/descriptor.rs b/src/descriptor.rs index 2b48b752d8..cfe24e2da5 100644 --- a/src/descriptor.rs +++ b/src/descriptor.rs @@ -8,13 +8,14 @@ use {Blob, D3DResult, Error, TextureAddressMode}; pub type CpuDescriptor = d3d12::D3D12_CPU_DESCRIPTOR_HANDLE; pub type GpuDescriptor = d3d12::D3D12_GPU_DESCRIPTOR_HANDLE; +#[derive(Clone, Copy, Debug)] pub struct Binding { pub register: u32, pub space: u32, } #[repr(u32)] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum HeapType { CbvSrvUav = d3d12::D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, Sampler = d3d12::D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, @@ -41,7 +42,7 @@ impl DescriptorHeap { } #[repr(u32)] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum ShaderVisibility { All = d3d12::D3D12_SHADER_VISIBILITY_ALL, VS = d3d12::D3D12_SHADER_VISIBILITY_VERTEX, @@ -52,7 +53,7 @@ pub enum ShaderVisibility { } #[repr(u32)] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum DescriptorRangeType { SRV = d3d12::D3D12_DESCRIPTOR_RANGE_TYPE_SRV, UAV = d3d12::D3D12_DESCRIPTOR_RANGE_TYPE_UAV, @@ -109,7 +110,11 @@ impl RootParameter { RootParameter(param) } - fn descriptor(ty: d3d12::D3D12_ROOT_PARAMETER_TYPE, visibility: ShaderVisibility, binding: Binding) -> Self { + fn descriptor( + ty: d3d12::D3D12_ROOT_PARAMETER_TYPE, + visibility: ShaderVisibility, + binding: Binding, + ) -> Self { let mut param = d3d12::D3D12_ROOT_PARAMETER { ParameterType: ty, ShaderVisibility: visibility as _, @@ -138,6 +143,7 @@ impl RootParameter { } #[repr(u32)] +#[derive(Copy, Clone, Debug)] pub enum StaticBorderColor { TransparentBlack = d3d12::D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK, OpaqueBlack = d3d12::D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK, @@ -178,6 +184,7 @@ impl StaticSampler { } #[repr(u32)] +#[derive(Copy, Clone, Debug)] pub enum RootSignatureVersion { V1_0 = d3d12::D3D_ROOT_SIGNATURE_VERSION_1_0, V1_1 = d3d12::D3D_ROOT_SIGNATURE_VERSION_1_1,