From 41384e347c3411fa0d23387dee6dd9c6cee91eb8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 4 Dec 2020 01:59:44 +0100 Subject: [PATCH] More code style tweaks --- .../Buffers/Interop/ID3D12ResourceMap.cs | 6 +- .../Commands/CommandList.cs | 34 ++--- .../Interop/ID3D12CommandAllocatorPool.cs | 28 ++-- .../ID3D12DescriptorHandleAllocator.cs | 28 ++-- .../GraphicsDeviceMismatchException.cs | 2 +- .../Extensions/ID3D12DeviceExtensions.cs | 144 +++++++++--------- .../ID3D12GraphicsCommandListExtensions.cs | 12 +- .../Extensions/ID3D12ResourceExtensions.cs | 16 +- src/ComputeSharp.Graphics/GraphicsDevice.cs | 30 ++-- .../Helpers/DeviceHelper.Enumerator.cs | 6 +- .../Helpers/DeviceHelper.cs | 12 +- .../Extensions/ID3D12DeviceExtensions.cs | 34 ++--- 12 files changed, 176 insertions(+), 176 deletions(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Interop/ID3D12ResourceMap.cs b/src/ComputeSharp.Graphics/Buffers/Interop/ID3D12ResourceMap.cs index 5577e253..bd9d70f9 100644 --- a/src/ComputeSharp.Graphics/Buffers/Interop/ID3D12ResourceMap.cs +++ b/src/ComputeSharp.Graphics/Buffers/Interop/ID3D12ResourceMap.cs @@ -23,12 +23,12 @@ namespace ComputeSharp.Graphics.Buffers.Interop /// /// Creates a new instance for a given value. /// - /// The input instance to map. + /// The input instance to map. /// The pointer to the mapped resource. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ID3D12ResourceMap(ID3D12Resource* d3d12resource, void* pointer) + public ID3D12ResourceMap(ID3D12Resource* d3D12Resource, void* pointer) { - this.d3D12Resource = d3d12resource; + this.d3D12Resource = d3D12Resource; Pointer = pointer; } diff --git a/src/ComputeSharp.Graphics/Commands/CommandList.cs b/src/ComputeSharp.Graphics/Commands/CommandList.cs index 18cecdf0..2eb12aaa 100644 --- a/src/ComputeSharp.Graphics/Commands/CommandList.cs +++ b/src/ComputeSharp.Graphics/Commands/CommandList.cs @@ -21,7 +21,7 @@ namespace ComputeSharp.Graphics.Commands /// /// The command list type being used by the current instance. /// - private readonly D3D12_COMMAND_LIST_TYPE d3d12CommandListType; + private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType; /// /// The object in use by the current instance. @@ -37,16 +37,16 @@ namespace ComputeSharp.Graphics.Commands /// Creates a new instance with the specified parameters. /// /// The target instance to use. - /// The type of command list to create. - public CommandList(GraphicsDevice device, D3D12_COMMAND_LIST_TYPE d3d12CommandListType) + /// The type of command list to create. + public CommandList(GraphicsDevice device, D3D12_COMMAND_LIST_TYPE d3D12CommandListType) { this.device = device; - this.d3d12CommandListType = d3d12CommandListType; - this.d3D12CommandAllocator = device.GetCommandAllocator(d3d12CommandListType); - this.d3D12GraphicsCommandList = device.D3D12Device->CreateCommandList(d3d12CommandListType, this.d3D12CommandAllocator); + this.d3D12CommandListType = d3D12CommandListType; + this.d3D12CommandAllocator = device.GetCommandAllocator(d3D12CommandListType); + this.d3D12GraphicsCommandList = device.D3D12Device->CreateCommandList(d3D12CommandListType, this.d3D12CommandAllocator); // Set the heap descriptor if the command list is not for copy operations - if (d3d12CommandListType is not D3D12_COMMAND_LIST_TYPE_COPY) + if (d3D12CommandListType is not D3D12_COMMAND_LIST_TYPE_COPY) { device.SetDescriptorHeapForCommandList(this.d3D12GraphicsCommandList); } @@ -55,7 +55,7 @@ namespace ComputeSharp.Graphics.Commands /// /// Gets the command list type being used by the current instance. /// - public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3d12CommandListType; + public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3D12CommandListType; /// /// Detaches the object in use by the current instance. @@ -81,20 +81,20 @@ namespace ComputeSharp.Graphics.Commands /// /// Copies a memory region from one resource to another. /// - /// The destination to write to. + /// The destination to write to. /// The starting offset to write the destination resource from. /// The source to read from. /// The starting offset to read the source resource from. /// The total number of bytes to copy from one resource to another. - public readonly void CopyBufferRegion(ID3D12Resource* d3d12ResourceDestination, ulong destinationOffset, ID3D12Resource* d3D12ResourceSource, ulong sourceOffset, ulong numBytes) + public readonly void CopyBufferRegion(ID3D12Resource* d3D12ResourceDestination, ulong destinationOffset, ID3D12Resource* d3D12ResourceSource, ulong sourceOffset, ulong numBytes) { - this.d3D12GraphicsCommandList.Get()->CopyBufferRegion(d3d12ResourceDestination, destinationOffset, d3D12ResourceSource, sourceOffset, numBytes); + this.d3D12GraphicsCommandList.Get()->CopyBufferRegion(d3D12ResourceDestination, destinationOffset, d3D12ResourceSource, sourceOffset, numBytes); } /// /// Copies a texture memory region from one resource (a buffer) to another (a texture). /// - /// The destination (a texture) to write to. + /// The destination (a texture) to write to. /// The parameter curreently in use by the texture. /// The horizontal offset in the destination texture. /// The vertical offset in the destination texture. @@ -104,7 +104,7 @@ namespace ComputeSharp.Graphics.Commands /// The size of each element to copy. public readonly void CopyTextureRegion( - ID3D12Resource* d3d12ResourceDestination, + ID3D12Resource* d3D12ResourceDestination, DXGI_FORMAT dxgiFormat, uint x, uint y, @@ -113,13 +113,13 @@ namespace ComputeSharp.Graphics.Commands uint height, uint elementSizeInBytes) { - this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3d12ResourceDestination, dxgiFormat, x, y, d3D12ResourceSource, width, height, elementSizeInBytes); + this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3D12ResourceDestination, dxgiFormat, x, y, d3D12ResourceSource, width, height, elementSizeInBytes); } /// /// Copies a texture memory region from one resource (a texture) to another (a buffer). /// - /// The destination (a buffer) to write to. + /// The destination (a buffer) to write to. /// The size of each element to copy. /// The source (a texture) to read from. /// The parameter curreently in use by the texture. @@ -128,7 +128,7 @@ namespace ComputeSharp.Graphics.Commands /// The width of the memory area to write to. /// The height of the memory area to write to. public readonly void CopyTextureRegion( - ID3D12Resource* d3d12ResourceDestination, + ID3D12Resource* d3D12ResourceDestination, uint elementSizeInBytes, ID3D12Resource* d3D12ResourceSource, DXGI_FORMAT dxgiFormat, @@ -137,7 +137,7 @@ namespace ComputeSharp.Graphics.Commands uint width, uint height) { - this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3d12ResourceDestination, elementSizeInBytes, d3D12ResourceSource, dxgiFormat, x, y, width, height); + this.d3D12GraphicsCommandList.Get()->CopyTextureRegion(d3D12ResourceDestination, elementSizeInBytes, d3D12ResourceSource, dxgiFormat, x, y, width, height); } /// diff --git a/src/ComputeSharp.Graphics/Commands/Interop/ID3D12CommandAllocatorPool.cs b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12CommandAllocatorPool.cs index 849bbe04..d4d29e6d 100644 --- a/src/ComputeSharp.Graphics/Commands/Interop/ID3D12CommandAllocatorPool.cs +++ b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12CommandAllocatorPool.cs @@ -14,21 +14,21 @@ namespace ComputeSharp.Graphics.Commands /// /// The command list type being used by the current instance. /// - private readonly D3D12_COMMAND_LIST_TYPE d3d12CommandListType; + private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType; /// /// The queue of currently pooled instances. /// - private readonly Queue> d3d12CommandAllocatorQueue; + private readonly Queue> d3D12CommandAllocatorQueue; /// /// Creates a new instance with the specified values. /// - /// The command list type to use. - public ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE d3d12CommandListType) + /// The command list type to use. + public ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE d3D12CommandListType) { - this.d3d12CommandListType = d3d12CommandListType; - this.d3d12CommandAllocatorQueue = new(); + this.d3D12CommandListType = d3D12CommandListType; + this.d3D12CommandAllocatorQueue = new(); } /// @@ -37,9 +37,9 @@ namespace ComputeSharp.Graphics.Commands /// The input to enqueue. public void Enqueue(ComPtr d3D12CommandAllocator) { - lock (this.d3d12CommandAllocatorQueue) + lock (this.d3D12CommandAllocatorQueue) { - this.d3d12CommandAllocatorQueue.Enqueue(d3D12CommandAllocator); + this.d3D12CommandAllocatorQueue.Enqueue(d3D12CommandAllocator); } } @@ -51,30 +51,30 @@ namespace ComputeSharp.Graphics.Commands { using ComPtr d3D12CommandAllocator = default; - lock (this.d3d12CommandAllocatorQueue) + lock (this.d3D12CommandAllocatorQueue) { - if (this.d3d12CommandAllocatorQueue.TryDequeue(out *&d3D12CommandAllocator)) + if (this.d3D12CommandAllocatorQueue.TryDequeue(out *&d3D12CommandAllocator)) { d3D12CommandAllocator.Get()->Reset().Assert(); return d3D12CommandAllocator.Move(); } - return d3D12Device->CreateCommandAllocator(this.d3d12CommandListType); + return d3D12Device->CreateCommandAllocator(this.d3D12CommandListType); } } /// public void Dispose() { - lock (this.d3d12CommandAllocatorQueue) + lock (this.d3D12CommandAllocatorQueue) { - foreach (ComPtr d3D12CommandAllocator in this.d3d12CommandAllocatorQueue) + foreach (ComPtr d3D12CommandAllocator in this.d3D12CommandAllocatorQueue) { d3D12CommandAllocator.Dispose(); } - this.d3d12CommandAllocatorQueue.Clear(); + this.d3D12CommandAllocatorQueue.Clear(); } } } diff --git a/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs index 70d96daa..0d96f337 100644 --- a/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs +++ b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs @@ -33,12 +33,12 @@ namespace ComputeSharp.Graphics /// /// The current for the instance in use. /// - private D3D12_CPU_DESCRIPTOR_HANDLE d3d12CpuDescriptorHandle; + private D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle; /// /// The current for the instance in use. /// - private D3D12_GPU_DESCRIPTOR_HANDLE d3d12GpuDescriptorHandle; + private D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle; /// /// The number of remaining handles to allocate on the current heap. @@ -54,8 +54,8 @@ namespace ComputeSharp.Graphics this.d3D12DescriptorHeap = device->CreateDescriptorHeap(DescriptorsPerHeap); this.allocationLock = new object(); this.descriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - this.d3d12CpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetCPUDescriptorHandleForHeapStart(); - this.d3d12GpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetGPUDescriptorHandleForHeapStart(); + this.d3D12CpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetCPUDescriptorHandleForHeapStart(); + this.d3D12GpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetGPUDescriptorHandleForHeapStart(); this.remainingHandles = this.d3D12DescriptorHeap.Get()->GetDesc().NumDescriptors; } @@ -67,26 +67,26 @@ namespace ComputeSharp.Graphics /// /// Allocates a new CPU and GPU handle pair to use in a memory buffer. /// - /// The resulting value. - /// The resulting value. + /// The resulting value. + /// The resulting value. public void Allocate( - out D3D12_CPU_DESCRIPTOR_HANDLE d3d12CpuDescriptorHandle, - out D3D12_GPU_DESCRIPTOR_HANDLE d3d12GpuDescriptorHandle) + out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, + out D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle) { lock (this.allocationLock) { if (this.remainingHandles == 0) { - this.d3d12CpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetCPUDescriptorHandleForHeapStart(); - this.d3d12GpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetGPUDescriptorHandleForHeapStart(); + this.d3D12CpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetCPUDescriptorHandleForHeapStart(); + this.d3D12GpuDescriptorHandle = this.d3D12DescriptorHeap.Get()->GetGPUDescriptorHandleForHeapStart(); this.remainingHandles = this.d3D12DescriptorHeap.Get()->GetDesc().NumDescriptors; } - d3d12CpuDescriptorHandle = this.d3d12CpuDescriptorHandle; - d3d12GpuDescriptorHandle = this.d3d12GpuDescriptorHandle; + d3D12CpuDescriptorHandle = this.d3D12CpuDescriptorHandle; + d3D12GpuDescriptorHandle = this.d3D12GpuDescriptorHandle; - this.d3d12CpuDescriptorHandle.ptr += this.descriptorSize; - this.d3d12GpuDescriptorHandle.ptr += this.descriptorSize; + this.d3D12CpuDescriptorHandle.ptr += this.descriptorSize; + this.d3D12GpuDescriptorHandle.ptr += this.descriptorSize; this.remainingHandles--; } } diff --git a/src/ComputeSharp.Graphics/Exceptions/GraphicsDeviceMismatchException.cs b/src/ComputeSharp.Graphics/Exceptions/GraphicsDeviceMismatchException.cs index 8197b10f..8c7eb70c 100644 --- a/src/ComputeSharp.Graphics/Exceptions/GraphicsDeviceMismatchException.cs +++ b/src/ComputeSharp.Graphics/Exceptions/GraphicsDeviceMismatchException.cs @@ -63,7 +63,7 @@ namespace ComputeSharp.Exceptions /// Throws a new instance from the specified parameters. /// /// The type of values in the input buffer. - /// The input that was used. + /// The input that was used. /// The target instance that was used. [Pure] internal static void Throw(Texture2D texture, GraphicsDevice device) diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs index 3c95e4fc..16facd39 100644 --- a/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp.Graphics/Extensions/ID3D12DeviceExtensions.cs @@ -29,22 +29,22 @@ namespace ComputeSharp.Graphics.Extensions /// /// Creates a new of the specified type, for a given device. /// - /// The target to use to create the command queue. + /// The target to use to create the command queue. /// The type of command queue to create. /// A pointer to the newly allocated instance. /// Thrown when the creation of the command queue fails. - public static ComPtr CreateCommandQueue(this ref ID3D12Device d3d12device, D3D12_COMMAND_LIST_TYPE type) + public static ComPtr CreateCommandQueue(this ref ID3D12Device d3D12Device, D3D12_COMMAND_LIST_TYPE type) { using ComPtr d3D12CommandQueue = default; - D3D12_COMMAND_QUEUE_DESC d3d12CommandQueueDesc; - d3d12CommandQueueDesc.Type = type; - d3d12CommandQueueDesc.Priority = (int)D3D12_COMMAND_QUEUE_PRIORITY_NORMAL; - d3d12CommandQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; - d3d12CommandQueueDesc.NodeMask = 0; + D3D12_COMMAND_QUEUE_DESC d3D12CommandQueueDesc; + d3D12CommandQueueDesc.Type = type; + d3D12CommandQueueDesc.Priority = (int)D3D12_COMMAND_QUEUE_PRIORITY_NORMAL; + d3D12CommandQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; + d3D12CommandQueueDesc.NodeMask = 0; - d3d12device.CreateCommandQueue( - &d3d12CommandQueueDesc, + d3D12Device.CreateCommandQueue( + &d3D12CommandQueueDesc, FX.__uuidof(), d3D12CommandQueue.GetVoidAddressOf()).Assert(); @@ -54,45 +54,45 @@ namespace ComputeSharp.Graphics.Extensions /// /// Creates a new for a given device. /// - /// The target to use to create the fence. + /// The target to use to create the fence. /// A pointer to the newly allocated instance. /// Thrown when the creation of the command queue fails. - public static ComPtr CreateFence(this ref ID3D12Device d3d12device) + public static ComPtr CreateFence(this ref ID3D12Device d3D12Device) { - using ComPtr d3d12Fence = default; + using ComPtr d3D12Fence = default; - d3d12device.CreateFence( + d3D12Device.CreateFence( 0, D3D12_FENCE_FLAG_NONE, FX.__uuidof(), - d3d12Fence.GetVoidAddressOf()).Assert(); + d3D12Fence.GetVoidAddressOf()).Assert(); - return d3d12Fence.Move(); + return d3D12Fence.Move(); } /// /// Creates a new for a given device. /// - /// The target to use to create the descriptor heap. + /// The target to use to create the descriptor heap. /// The number of descriptors to allocate. /// A pointer to the newly allocated instance. /// Thrown when the creation of the command queue fails. - public static ComPtr CreateDescriptorHeap(this ref ID3D12Device d3d12device, uint descriptorsCount) + public static ComPtr CreateDescriptorHeap(this ref ID3D12Device d3D12Device, uint descriptorsCount) { - using ComPtr d3d12DescriptorHeap = default; + using ComPtr d3D12DescriptorHeap = default; - D3D12_DESCRIPTOR_HEAP_DESC d3d12DescriptorHeapDesc; - d3d12DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; - d3d12DescriptorHeapDesc.NumDescriptors = descriptorsCount; - d3d12DescriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - d3d12DescriptorHeapDesc.NodeMask = 0; + D3D12_DESCRIPTOR_HEAP_DESC d3D12DescriptorHeapDesc; + d3D12DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + d3D12DescriptorHeapDesc.NumDescriptors = descriptorsCount; + d3D12DescriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + d3D12DescriptorHeapDesc.NodeMask = 0; - d3d12device.CreateDescriptorHeap( - &d3d12DescriptorHeapDesc, + d3D12Device.CreateDescriptorHeap( + &d3D12DescriptorHeapDesc, FX.__uuidof(), - d3d12DescriptorHeap.GetVoidAddressOf()).Assert(); + d3D12DescriptorHeap.GetVoidAddressOf()).Assert(); - return d3d12DescriptorHeap.Move(); + return d3D12DescriptorHeap.Move(); } /// @@ -193,36 +193,36 @@ namespace ComputeSharp.Graphics.Extensions /// /// Creates a view for a constant buffer. /// - /// The target instance in use. - /// The to create a view for. + /// The target instance in use. + /// The to create a view for. /// The size of the target resource. /// The instance for the current resource. public static void CreateConstantBufferView( - this ref ID3D12Device d3d12Device, - ID3D12Resource* d3d12resource, + this ref ID3D12Device d3D12Device, + ID3D12Resource* d3D12Resource, nint bufferSize, D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle) { uint constantBufferSize = checked((uint)((bufferSize + 255) & ~255)); D3D12_CONSTANT_BUFFER_VIEW_DESC d3D12ConstantBufferViewDescription; - d3D12ConstantBufferViewDescription.BufferLocation = d3d12resource->GetGPUVirtualAddress(); + d3D12ConstantBufferViewDescription.BufferLocation = d3D12Resource->GetGPUVirtualAddress(); d3D12ConstantBufferViewDescription.SizeInBytes = constantBufferSize; - d3d12Device.CreateConstantBufferView(&d3D12ConstantBufferViewDescription, d3D12CpuDescriptorHandle); + d3D12Device.CreateConstantBufferView(&d3D12ConstantBufferViewDescription, d3D12CpuDescriptorHandle); } /// /// Creates a view for a readonly buffer. /// - /// The target instance in use. - /// The to create a view for. + /// The target instance in use. + /// The to create a view for. /// The size of the target resource. /// The size in byte of each item in the resource. /// The instance for the current resource. public static void CreateShaderResourceView( - this ref ID3D12Device d3d12Device, - ID3D12Resource* d3d12resource, + this ref ID3D12Device d3D12Device, + ID3D12Resource* d3D12Resource, uint bufferSize, uint elementSize, D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle) @@ -233,19 +233,19 @@ namespace ComputeSharp.Graphics.Extensions d3D12ShaderResourceViewDescription.Buffer.NumElements = bufferSize; d3D12ShaderResourceViewDescription.Buffer.StructureByteStride = elementSize; - d3d12Device.CreateShaderResourceView(d3d12resource, &d3D12ShaderResourceViewDescription, d3D12CpuDescriptorHandle); + d3D12Device.CreateShaderResourceView(d3D12Resource, &d3D12ShaderResourceViewDescription, d3D12CpuDescriptorHandle); } /// /// Creates a view for a readonly texture. /// - /// The target instance in use. - /// The to create a view for. + /// The target instance in use. + /// The to create a view for. /// The value to use. /// The instance for the current resource. public static void CreateShaderResourceView( - this ref ID3D12Device d3d12Device, - ID3D12Resource* d3d12resource, + this ref ID3D12Device d3D12Device, + ID3D12Resource* d3D12Resource, DXGI_FORMAT dxgiFormat, D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle) { @@ -254,20 +254,20 @@ namespace ComputeSharp.Graphics.Extensions d3D12ShaderResourceViewDescription.Format = dxgiFormat; d3D12ShaderResourceViewDescription.Shader4ComponentMapping = FX.D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - d3d12Device.CreateShaderResourceView(d3d12resource, &d3D12ShaderResourceViewDescription, d3D12CpuDescriptorHandle); + d3D12Device.CreateShaderResourceView(d3D12Resource, &d3D12ShaderResourceViewDescription, d3D12CpuDescriptorHandle); } /// /// Creates a view for a buffer that can be both read and written to. /// - /// The target instance in use. - /// The to create a view for. + /// The target instance in use. + /// The to create a view for. /// The size of the target resource. /// The size in byte of each item in the resource. /// The instance for the current resource. public static void CreateUnorderedAccessView( - this ref ID3D12Device d3d12Device, - ID3D12Resource* d3d12resource, + this ref ID3D12Device d3D12Device, + ID3D12Resource* d3D12Resource, uint bufferSize, uint elementSize, D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle) @@ -277,19 +277,19 @@ namespace ComputeSharp.Graphics.Extensions d3D12UnorderedAccessViewDescription.Buffer.NumElements = bufferSize; d3D12UnorderedAccessViewDescription.Buffer.StructureByteStride = elementSize; - d3d12Device.CreateUnorderedAccessView(d3d12resource, null, &d3D12UnorderedAccessViewDescription, d3D12CpuDescriptorHandle); + d3D12Device.CreateUnorderedAccessView(d3D12Resource, null, &d3D12UnorderedAccessViewDescription, d3D12CpuDescriptorHandle); } /// /// Creates a view for a texture that can be both read and written to. /// - /// The target instance in use. - /// The to create a view for. + /// The target instance in use. + /// The to create a view for. /// The value to use. /// The instance for the current resource. public static void CreateUnorderedAccessView( - this ref ID3D12Device d3d12Device, - ID3D12Resource* d3d12resource, + this ref ID3D12Device d3D12Device, + ID3D12Resource* d3D12Resource, DXGI_FORMAT dxgiFormat, D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle) { @@ -297,24 +297,24 @@ namespace ComputeSharp.Graphics.Extensions d3D12UnorderedAccessViewDescription.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; d3D12UnorderedAccessViewDescription.Format = dxgiFormat; - d3d12Device.CreateUnorderedAccessView(d3d12resource, null, &d3D12UnorderedAccessViewDescription, d3D12CpuDescriptorHandle); + d3D12Device.CreateUnorderedAccessView(d3D12Resource, null, &d3D12UnorderedAccessViewDescription, d3D12CpuDescriptorHandle); } /// /// Creates a new for a given device. /// - /// The target to use to create the command allocator. - /// The type of command list allocator to create. + /// The target to use to create the command allocator. + /// The type of command list allocator to create. /// A pointer to the newly allocated instance. /// Thrown when the creation of the command allocator fails. public static ComPtr CreateCommandAllocator( - this ref ID3D12Device d3d12device, - D3D12_COMMAND_LIST_TYPE d3d12CommandListType) + this ref ID3D12Device d3D12Device, + D3D12_COMMAND_LIST_TYPE d3D12CommandListType) { using ComPtr d3D12CommandAllocator = default; - d3d12device.CreateCommandAllocator( - d3d12CommandListType, + d3D12Device.CreateCommandAllocator( + d3D12CommandListType, FX.__uuidof(), d3D12CommandAllocator.GetVoidAddressOf()).Assert(); @@ -324,42 +324,42 @@ namespace ComputeSharp.Graphics.Extensions /// /// Creates a new for a given device. /// - /// The target to use to create the command list. - /// The type of command list to create. + /// The target to use to create the command list. + /// The type of command list to create. /// A pointer to the newly allocated instance. /// Thrown when the creation of the command list fails. public static ComPtr CreateCommandList( - this ref ID3D12Device d3d12device, - D3D12_COMMAND_LIST_TYPE d3d12CommandListType, + this ref ID3D12Device d3D12Device, + D3D12_COMMAND_LIST_TYPE d3D12CommandListType, ID3D12CommandAllocator* d3D12CommandAllocator) { - using ComPtr d3d12GraphicsCommandList = default; + using ComPtr d3D12GraphicsCommandList = default; - d3d12device.CreateCommandList( + d3D12Device.CreateCommandList( 0, - d3d12CommandListType, + d3D12CommandListType, d3D12CommandAllocator, null, FX.__uuidof(), - d3d12GraphicsCommandList.GetVoidAddressOf()).Assert(); + d3D12GraphicsCommandList.GetVoidAddressOf()).Assert(); - return d3d12GraphicsCommandList.Move(); + return d3D12GraphicsCommandList.Move(); } /// /// Checks the feature support of a given type for a given device. /// /// The type of feature support data to retrieve. - /// The target to use to check features for. - /// The type of features to check. + /// The target to use to check features for. + /// The type of features to check. /// A value with the features data. [Pure] - public static unsafe TFeature CheckFeatureSupport(this ref ID3D12Device d3d12device, D3D12_FEATURE d3d12feature) + public static unsafe TFeature CheckFeatureSupport(this ref ID3D12Device d3D12Device, D3D12_FEATURE d3D12Feature) where TFeature : unmanaged { TFeature feature; - d3d12device.CheckFeatureSupport(d3d12feature, &feature, (uint)sizeof(TFeature)).Assert(); + d3D12Device.CheckFeatureSupport(d3D12Feature, &feature, (uint)sizeof(TFeature)).Assert(); return feature; } diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12GraphicsCommandListExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12GraphicsCommandListExtensions.cs index 84e71da4..4f7effdd 100644 --- a/src/ComputeSharp.Graphics/Extensions/ID3D12GraphicsCommandListExtensions.cs +++ b/src/ComputeSharp.Graphics/Extensions/ID3D12GraphicsCommandListExtensions.cs @@ -12,7 +12,7 @@ namespace ComputeSharp.Graphics.Extensions /// Copies a texture memory region from one resource (a buffer) to another (a texture). /// /// The instance in use. - /// The destination (a texture) to write to. + /// The destination (a texture) to write to. /// The parameter curreently in use by the texture. /// The horizontal offset in the destination texture. /// The vertical offset in the destination texture. @@ -23,7 +23,7 @@ namespace ComputeSharp.Graphics.Extensions public static void CopyTextureRegion( this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, - ID3D12Resource* d3d12ResourceDestination, + ID3D12Resource* d3D12ResourceDestination, DXGI_FORMAT dxgiFormat, uint x, uint y, @@ -42,7 +42,7 @@ namespace ComputeSharp.Graphics.Extensions d3D12PlacedSubresourceFootprint.Offset = 0; d3D12PlacedSubresourceFootprint.Footprint = d3D12SubresourceFootprint; D3D12_TEXTURE_COPY_LOCATION - d3D12TextureCopyLocationDestination = new(d3d12ResourceDestination, 0), + d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, 0), d3D12TextureCopyLocationSource = new(d3D12ResourceSource, d3D12PlacedSubresourceFootprint); d3D12GraphicsCommandList.CopyTextureRegion(&d3D12TextureCopyLocationDestination, x, y, 0, &d3D12TextureCopyLocationSource, null); @@ -52,7 +52,7 @@ namespace ComputeSharp.Graphics.Extensions /// Copies a texture memory region from one resource (a texture) to another (a buffer). /// /// The instance in use. - /// The destination (a buffer) to write to. + /// The destination (a buffer) to write to. /// The size of each element to copy. /// The source (a texture) to read from. /// The parameter curreently in use by the texture. @@ -62,7 +62,7 @@ namespace ComputeSharp.Graphics.Extensions /// The height of the memory area to write to. public static void CopyTextureRegion( this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, - ID3D12Resource* d3d12ResourceDestination, + ID3D12Resource* d3D12ResourceDestination, uint elementSizeInBytes, ID3D12Resource* d3D12ResourceSource, DXGI_FORMAT dxgiFormat, @@ -81,7 +81,7 @@ namespace ComputeSharp.Graphics.Extensions d3D12PlacedSubresourceFootprint.Offset = 0; d3D12PlacedSubresourceFootprint.Footprint = d3D12SubresourceFootprint; D3D12_TEXTURE_COPY_LOCATION - d3D12TextureCopyLocationDestination = new(d3d12ResourceDestination, d3D12PlacedSubresourceFootprint), + d3D12TextureCopyLocationDestination = new(d3D12ResourceDestination, d3D12PlacedSubresourceFootprint), d3D12TextureCopyLocationSource = new(d3D12ResourceSource, 0); D3D12_BOX d3D12Box = new((int)x, (int)y, (int)(x + width), (int)(y + height)); diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs index 6263df62..5fc2c29e 100644 --- a/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs +++ b/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs @@ -14,29 +14,29 @@ namespace ComputeSharp.Graphics.Extensions /// /// Maps the current resource to a specified subresource. /// - /// The target to map. + /// The target to map. /// A instance representing the mapped resource. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ID3D12ResourceMap Map(this ref ID3D12Resource d3d12resource) + public static ID3D12ResourceMap Map(this ref ID3D12Resource d3D12Resource) { void* pointer; - d3d12resource.Map(0, null, &pointer).Assert(); + d3D12Resource.Map(0, null, &pointer).Assert(); - return new((ID3D12Resource*)Unsafe.AsPointer(ref d3d12resource), pointer); + return new((ID3D12Resource*)Unsafe.AsPointer(ref d3D12Resource), pointer); } /// /// Maps a given memory area. /// - /// The target to map. - /// A pointer to the mapped area for . + /// The target to map. + /// A pointer to the mapped area for . /// Thrown when the mapping operation fails. /// Only use this method to unmap resources that were mapped with . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Unmap(this ref ID3D12Resource d3d12resource) + public static void Unmap(this ref ID3D12Resource d3D12Resource) { - d3d12resource.Unmap(0, null); + d3D12Resource.Unmap(0, null); } } } diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index b474d7c2..e49cee8f 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -71,25 +71,25 @@ namespace ComputeSharp.Graphics /// /// Creates a new instance for the input . /// - /// The to use for the new instance. + /// The to use for the new instance. /// The available info for the new instance. - internal GraphicsDevice(ComPtr d3d12device, DXGI_ADAPTER_DESC1* dxgiDescription1) + internal GraphicsDevice(ComPtr d3D12Device, DXGI_ADAPTER_DESC1* dxgiDescription1) { - this.d3D12Device = d3d12device; - this.d3D12ComputeCommandQueue = d3d12device.Get()->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COMPUTE); - this.d3D12CopyCommandQueue = d3d12device.Get()->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COPY); - this.d3D12ComputeFence = d3d12device.Get()->CreateFence(); - this.d3D12CopyFence = d3d12device.Get()->CreateFence(); + this.d3D12Device = d3D12Device; + this.d3D12ComputeCommandQueue = d3D12Device.Get()->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COMPUTE); + this.d3D12CopyCommandQueue = d3D12Device.Get()->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COPY); + this.d3D12ComputeFence = d3D12Device.Get()->CreateFence(); + this.d3D12CopyFence = d3D12Device.Get()->CreateFence(); this.computeCommandAllocatorPool = new ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE_COMPUTE); this.copyCommandAllocatorPool = new ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE_COPY); - this.shaderResourceViewDescriptorAllocator = new ID3D12DescriptorHandleAllocator(d3d12device); + this.shaderResourceViewDescriptorAllocator = new ID3D12DescriptorHandleAllocator(d3D12Device); Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid); Name = new string((char*)dxgiDescription1->Description); MemorySize = dxgiDescription1->DedicatedVideoMemory; - var d3D12Options1Data = d3d12device.Get()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1); + var d3D12Options1Data = d3D12Device.Get()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1); ComputeUnits = d3D12Options1Data.TotalLaneCount; WavefrontSize = d3D12Options1Data.WaveLaneCountMin; @@ -127,17 +127,17 @@ namespace ComputeSharp.Graphics /// internal void AllocateShaderResourceViewDescriptorHandles( - out D3D12_CPU_DESCRIPTOR_HANDLE d3d12CpuDescriptorHandle, - out D3D12_GPU_DESCRIPTOR_HANDLE d3d12GpuDescriptorHandle) + out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle, + out D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle) { - this.shaderResourceViewDescriptorAllocator.Allocate(out d3d12CpuDescriptorHandle, out d3d12GpuDescriptorHandle); + this.shaderResourceViewDescriptorAllocator.Allocate(out d3D12CpuDescriptorHandle, out d3D12GpuDescriptorHandle); } /// - /// The type of command allocator to rent. - internal ComPtr GetCommandAllocator(D3D12_COMMAND_LIST_TYPE d3d12CommandListType) + /// The type of command allocator to rent. + internal ComPtr GetCommandAllocator(D3D12_COMMAND_LIST_TYPE d3D12CommandListType) { - return d3d12CommandListType switch + return d3D12CommandListType switch { D3D12_COMMAND_LIST_TYPE_COMPUTE => this.computeCommandAllocatorPool.GetCommandAllocator(this.d3D12Device, this.d3D12ComputeFence), D3D12_COMMAND_LIST_TYPE_COPY => this.copyCommandAllocatorPool.GetCommandAllocator(this.d3D12Device, this.d3D12CopyFence), diff --git a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.Enumerator.cs b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.Enumerator.cs index c093c64d..fa4bead4 100644 --- a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.Enumerator.cs +++ b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.Enumerator.cs @@ -133,15 +133,15 @@ namespace ComputeSharp.Graphics.Helpers if (FX.SUCCEEDED(createDeviceResult) && this.predicate(new GraphicsDeviceInfo(&dxgiDescription1))) { - using ComPtr d3d12device = default; + using ComPtr d3D12Device = default; FX.D3D12CreateDevice( dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_12_0, FX.__uuidof(), - d3d12device.GetVoidAddressOf()).Assert(); + d3D12Device.GetVoidAddressOf()).Assert(); - this.graphicsDevice = GetOrCreateDevice(d3d12device.Move(), &dxgiDescription1); + this.graphicsDevice = GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1); return true; } diff --git a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs index 61e90d91..86c880b7 100644 --- a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs @@ -48,13 +48,13 @@ namespace ComputeSharp.Graphics.Helpers /// Thrown when a default device is not available. public static unsafe GraphicsDevice GetDefaultDevice() { - using ComPtr d3d12device = default; + using ComPtr d3D12Device = default; DXGI_ADAPTER_DESC1 dxgiDescription1; - if (TryGetDefaultDevice(d3d12device.GetAddressOf(), &dxgiDescription1)) + if (TryGetDefaultDevice(d3D12Device.GetAddressOf(), &dxgiDescription1)) { - return GetOrCreateDevice(d3d12device.Move(), &dxgiDescription1); + return GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1); } return ThrowHelper.ThrowNotSupportedException("There isn't a supported GPU device on the current machine"); @@ -63,10 +63,10 @@ namespace ComputeSharp.Graphics.Helpers /// /// Tries to check or create a default object. /// - /// A pointer to the object to create, or . + /// A pointer to the object to create, or . /// A pointer to the value for the device found. /// Whether a default device was found with the requested feature level. - private static unsafe bool TryGetDefaultDevice(ID3D12Device** d3d12device, DXGI_ADAPTER_DESC1* dxgiDescription1) + private static unsafe bool TryGetDefaultDevice(ID3D12Device** d3D12Device, DXGI_ADAPTER_DESC1* dxgiDescription1) { using ComPtr dxgiFactory4 = default; @@ -97,7 +97,7 @@ namespace ComputeSharp.Graphics.Helpers dxgiAdapter1.AsIUnknown().Get(), D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_12_0, FX.__uuidof(), - (void**)d3d12device); + (void**)d3D12Device); if (FX.SUCCEEDED(createDeviceResult)) { diff --git a/src/ComputeSharp.Shaders/Extensions/ID3D12DeviceExtensions.cs b/src/ComputeSharp.Shaders/Extensions/ID3D12DeviceExtensions.cs index 7ac82bf7..88f88aac 100644 --- a/src/ComputeSharp.Shaders/Extensions/ID3D12DeviceExtensions.cs +++ b/src/ComputeSharp.Shaders/Extensions/ID3D12DeviceExtensions.cs @@ -14,12 +14,12 @@ namespace ComputeSharp.Shaders.Extensions /// /// Creates a new for a given device. /// - /// The target to use to create the root signature. + /// The target to use to create the root signature. /// The input descriptor ranges for the signature to create. /// A pointer to the newly allocated instance. /// Thrown when the creation of the root signature fails. public static ComPtr CreateRootSignature( - this ref ID3D12Device d3d12device, + this ref ID3D12Device d3D12Device, ReadOnlySpan d3D12DescriptorRanges1) { using ComPtr d3D3Blob = default; @@ -38,19 +38,19 @@ namespace ComputeSharp.Shaders.Extensions // Root signature description wrapping the packed collection of root parameters D3D12_VERSIONED_ROOT_SIGNATURE_DESC.Init_1_1( - out D3D12_VERSIONED_ROOT_SIGNATURE_DESC d3d12VersionedRootSignatureDescription, + out D3D12_VERSIONED_ROOT_SIGNATURE_DESC d3D12VersionedRootSignatureDescription, (uint)d3D12DescriptorRanges1.Length, d3D12RootParameters1); // Serialize the root signature from the data just computed. When this is done // we just work with the resulting blobs, so the input data can be unpinned. FX.D3D12SerializeVersionedRootSignature( - &d3d12VersionedRootSignatureDescription, + &d3D12VersionedRootSignatureDescription, d3D3Blob.GetAddressOf(), d3D3BlobError.GetAddressOf()).Assert(); } - d3d12device.CreateRootSignature( + d3D12Device.CreateRootSignature( 0, d3D3Blob.Get()->GetBufferPointer(), d3D3Blob.Get()->GetBufferSize(), @@ -63,27 +63,27 @@ namespace ComputeSharp.Shaders.Extensions /// /// Creates a new for a given device. /// - /// The target to use to create the pipeline state. + /// The target to use to create the pipeline state. /// The input root signature to use to create the pipeline state. - /// The shader bytecode to use for the pipeline state. + /// The shader bytecode to use for the pipeline state. /// A pointer to the newly allocated instance. /// Thrown when the creation of the pipeline state fails. public static ComPtr CreateComputePipelineState( - this ref ID3D12Device d3d12device, + this ref ID3D12Device d3D12Device, ID3D12RootSignature* d3D12RootSignature, - D3D12_SHADER_BYTECODE d3d12ShaderBytecode) + D3D12_SHADER_BYTECODE d3D12ShaderBytecode) { using ComPtr d3D12PipelineState = default; - D3D12_COMPUTE_PIPELINE_STATE_DESC d3d12ComputePipelineStateDescription; - d3d12ComputePipelineStateDescription.pRootSignature = d3D12RootSignature; - d3d12ComputePipelineStateDescription.CS = d3d12ShaderBytecode; - d3d12ComputePipelineStateDescription.NodeMask = 0; - d3d12ComputePipelineStateDescription.CachedPSO = default; - d3d12ComputePipelineStateDescription.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; + D3D12_COMPUTE_PIPELINE_STATE_DESC d3D12ComputePipelineStateDescription; + d3D12ComputePipelineStateDescription.pRootSignature = d3D12RootSignature; + d3D12ComputePipelineStateDescription.CS = d3D12ShaderBytecode; + d3D12ComputePipelineStateDescription.NodeMask = 0; + d3D12ComputePipelineStateDescription.CachedPSO = default; + d3D12ComputePipelineStateDescription.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; - d3d12device.CreateComputePipelineState( - &d3d12ComputePipelineStateDescription, + d3D12Device.CreateComputePipelineState( + &d3D12ComputePipelineStateDescription, FX.__uuidof(), d3D12PipelineState.GetVoidAddressOf()).Assert();