More code style tweaks

このコミットが含まれているのは:
Sergio Pedri committed 2020-12-04 01:59:44 +01:00
1 親 aa2614d011
コミット 41384e347c
12ファイル変更
+176 -176

検索条件に一致するファイルはありません

+3 -3
ファイルの表示
@@ -23,12 +23,12 @@ namespace ComputeSharp.Graphics.Buffers.Interop
/// <summary>
/// Creates a new <see cref="ID3D12ResourceMap"/> instance for a given <see cref="ID3D12Resource"/> value.
/// </summary>
/// <param name="d3d12resource">The input <see cref="ID3D12Resource"/> instance to map.</param>
/// <param name="d3D12Resource">The input <see cref="ID3D12Resource"/> instance to map.</param>
/// <param name="pointer">The pointer to the mapped resource.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ID3D12ResourceMap(ID3D12Resource* d3d12resource, void* pointer)
public ID3D12ResourceMap(ID3D12Resource* d3D12Resource, void* pointer)
{
this.d3D12Resource = d3d12resource;
this.d3D12Resource = d3D12Resource;
Pointer = pointer;
}
+17 -17
ファイルの表示
@@ -21,7 +21,7 @@ namespace ComputeSharp.Graphics.Commands
/// <summary>
/// The command list type being used by the current instance.
/// </summary>
private readonly D3D12_COMMAND_LIST_TYPE d3d12CommandListType;
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
/// <summary>
/// The <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
@@ -37,16 +37,16 @@ namespace ComputeSharp.Graphics.Commands
/// Creates a new <see cref="CommandList"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to use.</param>
/// <param name="d3d12CommandListType">The type of command list to create.</param>
public CommandList(GraphicsDevice device, D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
/// <param name="d3D12CommandListType">The type of command list to create.</param>
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
/// <summary>
/// Gets the command list type being used by the current instance.
/// </summary>
public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3d12CommandListType;
public readonly D3D12_COMMAND_LIST_TYPE D3d12CommandListType => this.d3D12CommandListType;
/// <summary>
/// Detaches the <see cref="ID3D12CommandAllocator"/> object in use by the current instance.
@@ -81,20 +81,20 @@ namespace ComputeSharp.Graphics.Commands
/// <summary>
/// Copies a memory region from one resource to another.
/// </summary>
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> to write to.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> to write to.</param>
/// <param name="destinationOffset">The starting offset to write the destination resource from.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> to read from.</param>
/// <param name="sourceOffset">The starting offset to read the source resource from.</param>
/// <param name="numBytes">The total number of bytes to copy from one resource to another.</param>
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);
}
/// <summary>
/// Copies a texture memory region from one resource (a buffer) to another (a texture).
/// </summary>
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a texture) to write to.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a texture) to write to.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
@@ -104,7 +104,7 @@ namespace ComputeSharp.Graphics.Commands
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
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);
}
/// <summary>
/// Copies a texture memory region from one resource (a texture) to another (a buffer).
/// </summary>
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a buffer) to write to.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a buffer) to write to.</param>
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a texture) to read from.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
@@ -128,7 +128,7 @@ namespace ComputeSharp.Graphics.Commands
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
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);
}
/// <summary>
+14 -14
ファイルの表示
@@ -14,21 +14,21 @@ namespace ComputeSharp.Graphics.Commands
/// <summary>
/// The command list type being used by the current instance.
/// </summary>
private readonly D3D12_COMMAND_LIST_TYPE d3d12CommandListType;
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
/// <summary>
/// The queue of currently pooled <see cref="ID3D12CommandAllocator"/> instances.
/// </summary>
private readonly Queue<ComPtr<ID3D12CommandAllocator>> d3d12CommandAllocatorQueue;
private readonly Queue<ComPtr<ID3D12CommandAllocator>> d3D12CommandAllocatorQueue;
/// <summary>
/// Creates a new <see cref="ID3D12CommandAllocatorPool"/> instance with the specified values.
/// </summary>
/// <param name="d3d12CommandListType">The command list type to use.</param>
public ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
/// <param name="d3D12CommandListType">The command list type to use.</param>
public ID3D12CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE d3D12CommandListType)
{
this.d3d12CommandListType = d3d12CommandListType;
this.d3d12CommandAllocatorQueue = new();
this.d3D12CommandListType = d3D12CommandListType;
this.d3D12CommandAllocatorQueue = new();
}
/// <summary>
@@ -37,9 +37,9 @@ namespace ComputeSharp.Graphics.Commands
/// <param name="d3D12CommandAllocator">The input <see cref="ID3D12CommandAllocator"/> to enqueue.</param>
public void Enqueue(ComPtr<ID3D12CommandAllocator> 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<ID3D12CommandAllocator> 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);
}
}
/// <inheritdoc cref="IDisposable.Dispose"/>
public void Dispose()
{
lock (this.d3d12CommandAllocatorQueue)
lock (this.d3D12CommandAllocatorQueue)
{
foreach (ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator in this.d3d12CommandAllocatorQueue)
foreach (ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator in this.d3D12CommandAllocatorQueue)
{
d3D12CommandAllocator.Dispose();
}
this.d3d12CommandAllocatorQueue.Clear();
this.d3D12CommandAllocatorQueue.Clear();
}
}
}
+14 -14
ファイルの表示
@@ -33,12 +33,12 @@ namespace ComputeSharp.Graphics
/// <summary>
/// The current <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> for the <see cref="ID3D12DescriptorHandleAllocator"/> instance in use.
/// </summary>
private D3D12_CPU_DESCRIPTOR_HANDLE d3d12CpuDescriptorHandle;
private D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle;
/// <summary>
/// The current <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> for the <see cref="ID3D12DescriptorHandleAllocator"/> instance in use.
/// </summary>
private D3D12_GPU_DESCRIPTOR_HANDLE d3d12GpuDescriptorHandle;
private D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle;
/// <summary>
/// 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
/// <summary>
/// Allocates a new CPU and GPU handle pair to use in a memory buffer.
/// </summary>
/// <param name="d3d12CpuDescriptorHandle">The resulting <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3d12CpuDescriptorHandle">The resulting <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3D12CpuDescriptorHandle">The resulting <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3D12CpuDescriptorHandle">The resulting <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
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--;
}
}
+1 -1
ファイルの表示
@@ -63,7 +63,7 @@ namespace ComputeSharp.Exceptions
/// Throws a new <see cref="GraphicsDeviceMismatchException"/> instance from the specified parameters.
/// </summary>
/// <typeparam name="T">The type of values in the input buffer.</typeparam>
/// <param name="buffer">The input <see cref="Texture2D{T}"/> that was used.</param>
/// <param name="texture">The input <see cref="Texture2D{T}"/> that was used.</param>
/// <param name="device">The target <see cref="GraphicsDevice"/> instance that was used.</param>
[Pure]
internal static void Throw<T>(Texture2D<T> texture, GraphicsDevice device)
+72 -72
ファイルの表示
@@ -29,22 +29,22 @@ namespace ComputeSharp.Graphics.Extensions
/// <summary>
/// Creates a new <see cref="ID3D12CommandQueue"/> of the specified type, for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the command queue.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the command queue.</param>
/// <param name="type">The type of command queue to create.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12CommandQueue"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the command queue fails.</exception>
public static ComPtr<ID3D12CommandQueue> CreateCommandQueue(this ref ID3D12Device d3d12device, D3D12_COMMAND_LIST_TYPE type)
public static ComPtr<ID3D12CommandQueue> CreateCommandQueue(this ref ID3D12Device d3D12Device, D3D12_COMMAND_LIST_TYPE type)
{
using ComPtr<ID3D12CommandQueue> 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<ID3D12CommandQueue>(),
d3D12CommandQueue.GetVoidAddressOf()).Assert();
@@ -54,45 +54,45 @@ namespace ComputeSharp.Graphics.Extensions
/// <summary>
/// Creates a new <see cref="ID3D12Fence"/> for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the fence.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the fence.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12Fence"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the command queue fails.</exception>
public static ComPtr<ID3D12Fence> CreateFence(this ref ID3D12Device d3d12device)
public static ComPtr<ID3D12Fence> CreateFence(this ref ID3D12Device d3D12Device)
{
using ComPtr<ID3D12Fence> d3d12Fence = default;
using ComPtr<ID3D12Fence> d3D12Fence = default;
d3d12device.CreateFence(
d3D12Device.CreateFence(
0,
D3D12_FENCE_FLAG_NONE,
FX.__uuidof<ID3D12Fence>(),
d3d12Fence.GetVoidAddressOf()).Assert();
d3D12Fence.GetVoidAddressOf()).Assert();
return d3d12Fence.Move();
return d3D12Fence.Move();
}
/// <summary>
/// Creates a new <see cref="ID3D12DescriptorHeap"/> for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the descriptor heap.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the descriptor heap.</param>
/// <param name="descriptorsCount">The number of descriptors to allocate.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12DescriptorHeap"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the command queue fails.</exception>
public static ComPtr<ID3D12DescriptorHeap> CreateDescriptorHeap(this ref ID3D12Device d3d12device, uint descriptorsCount)
public static ComPtr<ID3D12DescriptorHeap> CreateDescriptorHeap(this ref ID3D12Device d3D12Device, uint descriptorsCount)
{
using ComPtr<ID3D12DescriptorHeap> d3d12DescriptorHeap = default;
using ComPtr<ID3D12DescriptorHeap> 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<ID3D12DescriptorHeap>(),
d3d12DescriptorHeap.GetVoidAddressOf()).Assert();
d3D12DescriptorHeap.GetVoidAddressOf()).Assert();
return d3d12DescriptorHeap.Move();
return d3D12DescriptorHeap.Move();
}
/// <summary>
@@ -193,36 +193,36 @@ namespace ComputeSharp.Graphics.Extensions
/// <summary>
/// Creates a view for a constant buffer.
/// </summary>
/// <param name="d3d12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3d12resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="bufferSize">The size of the target resource.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
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);
}
/// <summary>
/// Creates a view for a readonly buffer.
/// </summary>
/// <param name="d3d12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3d12resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="bufferSize">The size of the target resource.</param>
/// <param name="elementSize">The size in byte of each item in the resource.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
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);
}
/// <summary>
/// Creates a view for a readonly texture.
/// </summary>
/// <param name="d3d12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3d12resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
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);
}
/// <summary>
/// Creates a view for a buffer that can be both read and written to.
/// </summary>
/// <param name="d3d12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3d12resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="bufferSize">The size of the target resource.</param>
/// <param name="elementSize">The size in byte of each item in the resource.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
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);
}
/// <summary>
/// Creates a view for a texture that can be both read and written to.
/// </summary>
/// <param name="d3d12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3d12resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to create a view for.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> instance for the current resource.</param>
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);
}
/// <summary>
/// Creates a new <see cref="ID3D12CommandAllocator"/> for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the command allocator.</param>
/// <param name="d3d12CommandListType">The type of command list allocator to create.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the command allocator.</param>
/// <param name="d3D12CommandListType">The type of command list allocator to create.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12CommandAllocator"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the command allocator fails.</exception>
public static ComPtr<ID3D12CommandAllocator> CreateCommandAllocator(
this ref ID3D12Device d3d12device,
D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
this ref ID3D12Device d3D12Device,
D3D12_COMMAND_LIST_TYPE d3D12CommandListType)
{
using ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator = default;
d3d12device.CreateCommandAllocator(
d3d12CommandListType,
d3D12Device.CreateCommandAllocator(
d3D12CommandListType,
FX.__uuidof<ID3D12CommandAllocator>(),
d3D12CommandAllocator.GetVoidAddressOf()).Assert();
@@ -324,42 +324,42 @@ namespace ComputeSharp.Graphics.Extensions
/// <summary>
/// Creates a new <see cref="ID3D12GraphicsCommandList"/> for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the command list.</param>
/// <param name="d3d12CommandListType">The type of command list to create.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the command list.</param>
/// <param name="d3D12CommandListType">The type of command list to create.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12GraphicsCommandList"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the command list fails.</exception>
public static ComPtr<ID3D12GraphicsCommandList> CreateCommandList(
this ref ID3D12Device d3d12device,
D3D12_COMMAND_LIST_TYPE d3d12CommandListType,
this ref ID3D12Device d3D12Device,
D3D12_COMMAND_LIST_TYPE d3D12CommandListType,
ID3D12CommandAllocator* d3D12CommandAllocator)
{
using ComPtr<ID3D12GraphicsCommandList> d3d12GraphicsCommandList = default;
using ComPtr<ID3D12GraphicsCommandList> d3D12GraphicsCommandList = default;
d3d12device.CreateCommandList(
d3D12Device.CreateCommandList(
0,
d3d12CommandListType,
d3D12CommandListType,
d3D12CommandAllocator,
null,
FX.__uuidof<ID3D12GraphicsCommandList>(),
d3d12GraphicsCommandList.GetVoidAddressOf()).Assert();
d3D12GraphicsCommandList.GetVoidAddressOf()).Assert();
return d3d12GraphicsCommandList.Move();
return d3D12GraphicsCommandList.Move();
}
/// <summary>
/// Checks the feature support of a given type for a given device.
/// </summary>
/// <typeparam name="TFeature">The type of feature support data to retrieve.</typeparam>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to check features for.</param>
/// <param name="d3d12feature">The type of features to check.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to check features for.</param>
/// <param name="d3D12Feature">The type of features to check.</param>
/// <returns>A <see typeparamref="TFeature"/> value with the features data.</returns>
[Pure]
public static unsafe TFeature CheckFeatureSupport<TFeature>(this ref ID3D12Device d3d12device, D3D12_FEATURE d3d12feature)
public static unsafe TFeature CheckFeatureSupport<TFeature>(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;
}
+6 -6
ファイルの表示
@@ -12,7 +12,7 @@ namespace ComputeSharp.Graphics.Extensions
/// Copies a texture memory region from one resource (a buffer) to another (a texture).
/// </summary>
/// <param name="d3D12GraphicsCommandList">The <see cref="ID3D12GraphicsCommandList"/> instance in use.</param>
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a texture) to write to.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a texture) to write to.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
@@ -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).
/// </summary>
/// <param name="d3D12GraphicsCommandList">The <see cref="ID3D12GraphicsCommandList"/> instance in use.</param>
/// <param name="d3d12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a buffer) to write to.</param>
/// <param name="d3D12ResourceDestination">The destination <see cref="ID3D12Resource"/> (a buffer) to write to.</param>
/// <param name="elementSizeInBytes">The size of each element to copy.</param>
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a texture) to read from.</param>
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> parameter curreently in use by the texture.</param>
@@ -62,7 +62,7 @@ namespace ComputeSharp.Graphics.Extensions
/// <param name="height">The height of the memory area to write to.</param>
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));
+8 -8
ファイルの表示
@@ -14,29 +14,29 @@ namespace ComputeSharp.Graphics.Extensions
/// <summary>
/// Maps the current resource to a specified subresource.
/// </summary>
/// <param name="d3d12resource">The target <see cref="ID3D12Resource"/> to map.</param>
/// <param name="d3D12Resource">The target <see cref="ID3D12Resource"/> to map.</param>
/// <returns>A <see cref="ID3D12ResourceMap"/> instance representing the mapped resource.</returns>
[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);
}
/// <summary>
/// Maps a given <see cref="ID3D12Resource"/> memory area.
/// </summary>
/// <param name="d3d12resource">The target <see cref="ID3D12Resource"/> to map.</param>
/// <returns>A pointer to the mapped area for <paramref name="d3d12resource"/>.</returns>
/// <param name="d3D12Resource">The target <see cref="ID3D12Resource"/> to map.</param>
/// <returns>A pointer to the mapped area for <paramref name="d3D12Resource"/>.</returns>
/// <exception cref="Exception">Thrown when the mapping operation fails.</exception>
/// <remarks>Only use this method to unmap resources that were mapped with <see cref="Map(ref ID3D12Resource)"/>.</remarks>
[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);
}
}
}
+15 -15
ファイルの表示
@@ -71,25 +71,25 @@ namespace ComputeSharp.Graphics
/// <summary>
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="ID3D12Device"/>.
/// </summary>
/// <param name="d3d12device">The <see cref="ID3D12Device"/> to use for the new <see cref="GraphicsDevice"/> instance.</param>
/// <param name="d3D12Device">The <see cref="ID3D12Device"/> to use for the new <see cref="GraphicsDevice"/> instance.</param>
/// <param name="dxgiDescription1">The available info for the new <see cref="GraphicsDevice"/> instance.</param>
internal GraphicsDevice(ComPtr<ID3D12Device> d3d12device, DXGI_ADAPTER_DESC1* dxgiDescription1)
internal GraphicsDevice(ComPtr<ID3D12Device> 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_DATA_D3D12_OPTIONS1>(D3D12_FEATURE_D3D12_OPTIONS1);
var d3D12Options1Data = d3D12Device.Get()->CheckFeatureSupport<D3D12_FEATURE_DATA_D3D12_OPTIONS1>(D3D12_FEATURE_D3D12_OPTIONS1);
ComputeUnits = d3D12Options1Data.TotalLaneCount;
WavefrontSize = d3D12Options1Data.WaveLaneCountMin;
@@ -127,17 +127,17 @@ namespace ComputeSharp.Graphics
/// <inheritdoc cref="ID3D12DescriptorHandleAllocator.Allocate"/>
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);
}
/// <inheritdoc cref="ID3D12CommandAllocatorPool.GetCommandAllocator"/>
/// <param name="d3d12CommandListType">The type of command allocator to rent.</param>
internal ComPtr<ID3D12CommandAllocator> GetCommandAllocator(D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
/// <param name="d3D12CommandListType">The type of command allocator to rent.</param>
internal ComPtr<ID3D12CommandAllocator> 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),
+3 -3
ファイルの表示
@@ -133,15 +133,15 @@ namespace ComputeSharp.Graphics.Helpers
if (FX.SUCCEEDED(createDeviceResult) &&
this.predicate(new GraphicsDeviceInfo(&dxgiDescription1)))
{
using ComPtr<ID3D12Device> d3d12device = default;
using ComPtr<ID3D12Device> d3D12Device = default;
FX.D3D12CreateDevice(
dxgiAdapter1.AsIUnknown().Get(),
D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_12_0,
FX.__uuidof<ID3D12Device>(),
d3d12device.GetVoidAddressOf()).Assert();
d3D12Device.GetVoidAddressOf()).Assert();
this.graphicsDevice = GetOrCreateDevice(d3d12device.Move(), &dxgiDescription1);
this.graphicsDevice = GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1);
return true;
}
+6 -6
ファイルの表示
@@ -48,13 +48,13 @@ namespace ComputeSharp.Graphics.Helpers
/// <exception cref="NotSupportedException">Thrown when a default device is not available.</exception>
public static unsafe GraphicsDevice GetDefaultDevice()
{
using ComPtr<ID3D12Device> d3d12device = default;
using ComPtr<ID3D12Device> 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<GraphicsDevice>("There isn't a supported GPU device on the current machine");
@@ -63,10 +63,10 @@ namespace ComputeSharp.Graphics.Helpers
/// <summary>
/// Tries to check or create a default <see cref="ID3D12Device"/> object.
/// </summary>
/// <param name="d3d12device">A pointer to the <see cref="ID3D12Device"/> object to create, or <see langword="null"/>.</param>
/// <param name="d3D12Device">A pointer to the <see cref="ID3D12Device"/> object to create, or <see langword="null"/>.</param>
/// <param name="dxgiDescription1">A pointer to the <see cref="DXGI_ADAPTER_DESC1"/> value for the device found.</param>
/// <returns>Whether a default device was found with the requested feature level.</returns>
private static unsafe bool TryGetDefaultDevice(ID3D12Device** d3d12device, DXGI_ADAPTER_DESC1* dxgiDescription1)
private static unsafe bool TryGetDefaultDevice(ID3D12Device** d3D12Device, DXGI_ADAPTER_DESC1* dxgiDescription1)
{
using ComPtr<IDXGIFactory4> dxgiFactory4 = default;
@@ -97,7 +97,7 @@ namespace ComputeSharp.Graphics.Helpers
dxgiAdapter1.AsIUnknown().Get(),
D3D_FEATURE_LEVEL.D3D_FEATURE_LEVEL_12_0,
FX.__uuidof<ID3D12Device>(),
(void**)d3d12device);
(void**)d3D12Device);
if (FX.SUCCEEDED(createDeviceResult))
{
+17 -17
ファイルの表示
@@ -14,12 +14,12 @@ namespace ComputeSharp.Shaders.Extensions
/// <summary>
/// Creates a new <see cref="ID3D12RootSignature"/> for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the root signature.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the root signature.</param>
/// <param name="d3D12DescriptorRanges1">The input descriptor ranges for the signature to create.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12RootSignature"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the root signature fails.</exception>
public static ComPtr<ID3D12RootSignature> CreateRootSignature(
this ref ID3D12Device d3d12device,
this ref ID3D12Device d3D12Device,
ReadOnlySpan<D3D12_DESCRIPTOR_RANGE1> d3D12DescriptorRanges1)
{
using ComPtr<ID3DBlob> 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
/// <summary>
/// Creates a new <see cref="ID3D12PipelineState"/> for a given device.
/// </summary>
/// <param name="d3d12device">The target <see cref="ID3D12Device"/> to use to create the pipeline state.</param>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the pipeline state.</param>
/// <param name="d3D12RootSignature">The input root signature to use to create the pipeline state.</param>
/// <param name="d3d12ShaderBytecode">The shader bytecode to use for the pipeline state.</param>
/// <param name="d3D12ShaderBytecode">The shader bytecode to use for the pipeline state.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12PipelineState"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the pipeline state fails.</exception>
public static ComPtr<ID3D12PipelineState> CreateComputePipelineState(
this ref ID3D12Device d3d12device,
this ref ID3D12Device d3D12Device,
ID3D12RootSignature* d3D12RootSignature,
D3D12_SHADER_BYTECODE d3d12ShaderBytecode)
D3D12_SHADER_BYTECODE d3D12ShaderBytecode)
{
using ComPtr<ID3D12PipelineState> 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<ID3D12PipelineState>(),
d3D12PipelineState.GetVoidAddressOf()).Assert();