From 0c3f8f92c3825358ed0c797e00bde5bd27739d7d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 20 Nov 2020 02:31:12 +0100 Subject: [PATCH] Minor code refactoring --- src/ComputeSharp.Graphics/Commands/CommandList.cs | 1 - .../Interop/ID3D12DescriptorHandleAllocator.cs} | 14 +++++++------- src/ComputeSharp.Graphics/GraphicsDevice.cs | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) rename src/ComputeSharp.Graphics/{DescriptorAllocator.cs => Commands/Interop/ID3D12DescriptorHandleAllocator.cs} (88%) diff --git a/src/ComputeSharp.Graphics/Commands/CommandList.cs b/src/ComputeSharp.Graphics/Commands/CommandList.cs index 73b5b8c4..5a78a3af 100644 --- a/src/ComputeSharp.Graphics/Commands/CommandList.cs +++ b/src/ComputeSharp.Graphics/Commands/CommandList.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -using ComputeSharp.Graphics.Buffers.Abstract; using ComputeSharp.Graphics.Extensions; using TerraFX.Interop; using static TerraFX.Interop.D3D12_COMMAND_LIST_TYPE; diff --git a/src/ComputeSharp.Graphics/DescriptorAllocator.cs b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs similarity index 88% rename from src/ComputeSharp.Graphics/DescriptorAllocator.cs rename to src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs index 5c5c0a47..0e17912a 100644 --- a/src/ComputeSharp.Graphics/DescriptorAllocator.cs +++ b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs @@ -8,7 +8,7 @@ namespace ComputeSharp.Graphics /// /// A type that provides logic to create resource descriptors for a instance. /// - internal unsafe struct DescriptorAllocator : IDisposable + internal unsafe struct ID3D12DescriptorHandleAllocator : IDisposable { /// /// The default number of available descriptors per heap. @@ -16,7 +16,7 @@ namespace ComputeSharp.Graphics private const uint DescriptorsPerHeap = 4096; /// - /// The in use for the current instance. + /// The in use for the current instance. /// private ComPtr d3D12DescriptorHeap; @@ -31,12 +31,12 @@ namespace ComputeSharp.Graphics private readonly uint descriptorSize; /// - /// The current for the instance in use. + /// The current for the instance in use. /// private D3D12_CPU_DESCRIPTOR_HANDLE d3d12CpuDescriptorHandle; /// - /// The current for the instance in use. + /// The current for the instance in use. /// private D3D12_GPU_DESCRIPTOR_HANDLE d3d12GpuDescriptorHandle; @@ -46,10 +46,10 @@ namespace ComputeSharp.Graphics private uint remainingHandles; /// - /// Creates a new instance with the specified parameters. + /// Creates a new instance with the specified parameters. /// /// The instance to use - public DescriptorAllocator(ID3D12Device* device) + public ID3D12DescriptorHandleAllocator(ID3D12Device* device) { this.d3D12DescriptorHeap = device->CreateDescriptorHeap(DescriptorsPerHeap); this.allocationLock = new object(); @@ -60,7 +60,7 @@ namespace ComputeSharp.Graphics } /// - /// Gets the in use for the current instance. + /// Gets the in use for the current instance. /// public ID3D12DescriptorHeap* D3D12DescriptorHeap => this.d3D12DescriptorHeap; diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index 677eb695..c9535d94 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -50,9 +50,9 @@ namespace ComputeSharp.Graphics private readonly ID3D12CommandAllocatorPool copyCommandAllocatorPool; /// - /// The instance to use when allocating new buffers. + /// The instance to use when allocating new buffers. /// - private DescriptorAllocator shaderResourceViewDescriptorAllocator; + private ID3D12DescriptorHandleAllocator shaderResourceViewDescriptorAllocator; /// /// The next fence value for compute operations using . @@ -79,7 +79,7 @@ namespace ComputeSharp.Graphics this.computeCommandAllocatorPool = new ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE_COMPUTE); this.copyCommandAllocatorPool = new ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE_COPY); - this.shaderResourceViewDescriptorAllocator = new DescriptorAllocator(d3d12device); + this.shaderResourceViewDescriptorAllocator = new ID3D12DescriptorHandleAllocator(d3d12device); Luid = *(Luid*)&dxgiDescription1->AdapterLuid; Name = new string((char*)dxgiDescription1->Description); @@ -121,7 +121,7 @@ namespace ComputeSharp.Graphics /// internal ID3D12Device* D3D12Device => this.d3D12Device; - /// + /// internal void AllocateShaderResourceViewDescriptorHandles( out D3D12_CPU_DESCRIPTOR_HANDLE d3d12CpuDescriptorHandle, out D3D12_GPU_DESCRIPTOR_HANDLE d3d12GpuDescriptorHandle)