Refactored extensions to return ComPtr<T>
このコミットが含まれているのは:
1 親
bb962fee80
コミット
3818fef1d0
3ファイル変更
+49
-43
検索条件に一致するファイルはありません
@@ -24,24 +24,25 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
/// <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 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 = 0;
|
||||
d3d12CommandQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
d3d12CommandQueueDesc.NodeMask = 0;
|
||||
Guid d3d12CommandQueueDescGuid = FX.IID_ID3D12CommandQueue;
|
||||
ID3D12CommandQueue* commandQueue;
|
||||
|
||||
int result = d3d12device.CreateCommandQueue(
|
||||
&d3d12CommandQueueDesc,
|
||||
&d3d12CommandQueueDescGuid,
|
||||
(void**)&commandQueue);
|
||||
d3D12CommandQueue.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
|
||||
return commandQueue;
|
||||
return d3D12CommandQueue.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -50,20 +51,21 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
/// <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 ID3D12Fence* CreateFence(this ref ID3D12Device d3d12device)
|
||||
public static ComPtr<ID3D12Fence> CreateFence(this ref ID3D12Device d3d12device)
|
||||
{
|
||||
using ComPtr<ID3D12Fence> d3d12Fence = default;
|
||||
|
||||
Guid d3D12FenceGuid = FX.IID_ID3D12Fence;
|
||||
ID3D12Fence* d3d12Fence;
|
||||
|
||||
int result = d3d12device.CreateFence(
|
||||
0,
|
||||
D3D12_FENCE_FLAG_NONE,
|
||||
&d3D12FenceGuid,
|
||||
(void**)&d3d12Fence);
|
||||
d3d12Fence.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
|
||||
return d3d12Fence;
|
||||
return d3d12Fence.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,24 +75,25 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
/// <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 ID3D12DescriptorHeap* CreateDescriptorHeap(this ref ID3D12Device d3d12device, uint descriptorsCount)
|
||||
public static ComPtr<ID3D12DescriptorHeap> CreateDescriptorHeap(this ref ID3D12Device d3d12device, uint descriptorsCount)
|
||||
{
|
||||
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;
|
||||
Guid d3d12DescriptorHeapDescGuid = FX.IID_ID3D12DescriptorHeap;
|
||||
ID3D12DescriptorHeap* d3d12DescriptorHeap;
|
||||
|
||||
int result = d3d12device.CreateDescriptorHeap(
|
||||
&d3d12DescriptorHeapDesc,
|
||||
&d3d12DescriptorHeapDescGuid,
|
||||
(void**)&d3d12DescriptorHeap);
|
||||
d3d12DescriptorHeap.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
|
||||
return d3d12DescriptorHeap;
|
||||
return d3d12DescriptorHeap.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,13 +103,15 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
/// <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 ID3D12Resource* CreateCommittedResource(
|
||||
public static ComPtr<ID3D12Resource> CreateCommittedResource(
|
||||
this ref ID3D12Device d3d12device,
|
||||
D3D12_HEAP_TYPE d3D12HeapType,
|
||||
ulong width,
|
||||
D3D12_RESOURCE_FLAGS d3D12ResourceFlags,
|
||||
D3D12_RESOURCE_STATES d3D12ResourceStates)
|
||||
{
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
D3D12_HEAP_PROPERTIES d3D12HeapProperties;
|
||||
d3D12HeapProperties.Type = d3D12HeapType;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
@@ -115,7 +120,6 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
d3D12HeapProperties.VisibleNodeMask = 1;
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Buffer(width, d3D12ResourceFlags);
|
||||
Guid d3D12ResourceGuid = FX.IID_ID3D12Resource;
|
||||
ID3D12Resource* d3D12Resource;
|
||||
|
||||
int result = d3d12device.CreateCommittedResource(
|
||||
&d3D12HeapProperties,
|
||||
@@ -124,11 +128,11 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
d3D12ResourceStates,
|
||||
null,
|
||||
&d3D12ResourceGuid,
|
||||
(void**)&d3D12Resource);
|
||||
d3D12Resource.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
|
||||
return d3D12Resource;
|
||||
return d3D12Resource.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -138,21 +142,22 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
/// <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 ID3D12CommandAllocator* CreateCommandAllocator(
|
||||
public static ComPtr<ID3D12CommandAllocator> CreateCommandAllocator(
|
||||
this ref ID3D12Device d3d12device,
|
||||
D3D12_COMMAND_LIST_TYPE d3d12CommandListType)
|
||||
{
|
||||
ID3D12CommandAllocator* d3D12CommandAllocator;
|
||||
using ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator = default;
|
||||
|
||||
Guid d3D12CommandAllocatorGuid = FX.IID_ID3D12CommandAllocator;
|
||||
|
||||
int result = d3d12device.CreateCommandAllocator(
|
||||
d3d12CommandListType,
|
||||
&d3D12CommandAllocatorGuid,
|
||||
(void**)&d3D12CommandAllocator);
|
||||
d3D12CommandAllocator.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
|
||||
return d3D12CommandAllocator;
|
||||
return d3D12CommandAllocator.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -162,12 +167,13 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
/// <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 ID3D12GraphicsCommandList* CreateCommandList(
|
||||
public static ComPtr<ID3D12GraphicsCommandList> CreateCommandList(
|
||||
this ref ID3D12Device d3d12device,
|
||||
D3D12_COMMAND_LIST_TYPE d3d12CommandListType,
|
||||
ID3D12CommandAllocator* d3D12CommandAllocator)
|
||||
{
|
||||
ID3D12GraphicsCommandList* d3d12GraphicsCommandList;
|
||||
using ComPtr<ID3D12GraphicsCommandList> d3d12GraphicsCommandList = default;
|
||||
|
||||
Guid d3D12GraphicsCommandListGuid = FX.IID_ID3D12GraphicsCommandList;
|
||||
|
||||
int result = d3d12device.CreateCommandList(
|
||||
@@ -176,11 +182,11 @@ namespace ComputeSharp.Graphics.Extensions
|
||||
d3D12CommandAllocator,
|
||||
null,
|
||||
&d3D12GraphicsCommandListGuid,
|
||||
(void**)&d3d12GraphicsCommandList);
|
||||
d3d12GraphicsCommandList.GetVoidAddressOf());
|
||||
|
||||
ThrowHelper.ThrowIfFailed(result);
|
||||
|
||||
return d3d12GraphicsCommandList;
|
||||
return d3d12GraphicsCommandList.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする