Implement wrapping types for D3D12MA
このコミットが含まれているのは:
1 親
56dcbe201f
コミット
2070246f90
6ファイル変更
+613
-249
検索条件に一致するファイルはありません
@@ -0,0 +1,35 @@
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_CPU_PAGE_PROPERTY;
|
||||
using static TerraFX.Interop.DirectX.D3D12_HEAP_TYPE;
|
||||
using static TerraFX.Interop.DirectX.D3D12_MEMORY_POOL;
|
||||
|
||||
namespace ComputeSharp.D3D12MemoryAllocator.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> with extensions for the <see cref="D3D12MA_Allocator"/> type.
|
||||
/// </summary>
|
||||
internal static unsafe class AllocatorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="D3D12MA_Pool"/> instance suited to be used for cache coherent UMA devices.
|
||||
/// </summary>
|
||||
/// <param name="allocator">The <see cref="D3D12MA_Allocator"/> instance in use.</param>
|
||||
/// <returns>A <see cref="D3D12MA_Pool"/> instance suited to be used for cache coherent UMA devices.</returns>
|
||||
public static ComPtr<D3D12MA_Pool> CreatePoolForCacheCoherentUMA(this ref D3D12MA_Allocator allocator)
|
||||
{
|
||||
using ComPtr<D3D12MA_Pool> pool = default;
|
||||
|
||||
D3D12MA_POOL_DESC poolDesc = default;
|
||||
poolDesc.HeapProperties.CreationNodeMask = 1;
|
||||
poolDesc.HeapProperties.VisibleNodeMask = 1;
|
||||
poolDesc.HeapProperties.Type = D3D12_HEAP_TYPE_CUSTOM;
|
||||
poolDesc.HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK;
|
||||
poolDesc.HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;
|
||||
|
||||
allocator.CreatePool(&poolDesc, pool.GetAddressOf()).Assert();
|
||||
|
||||
return pool.Move();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.Graphics.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> with extensions for the <see cref="ID3D12Device"/> type.
|
||||
/// </summary>
|
||||
internal static unsafe class ID3D12DeviceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="D3D12MA_Allocator"/> instance for a given device.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the allocator.</param>
|
||||
/// <param name="dxgiAdapter">The <see cref="IDXGIAdapter"/> that <paramref name="d3D12Device"/> was created from.</param>
|
||||
/// <returns>A <see cref="D3D12MA_Allocator"/> instance to create resources on the device in use.</returns>
|
||||
public static ComPtr<D3D12MA_Allocator> CreateAllocator(this ref ID3D12Device d3D12Device, IDXGIAdapter* dxgiAdapter)
|
||||
{
|
||||
using ComPtr<D3D12MA_Allocator> allocator = default;
|
||||
|
||||
D3D12MA_ALLOCATOR_DESC allocatorDesc = default;
|
||||
allocatorDesc.pDevice = (ID3D12Device*)Unsafe.AsPointer(ref d3D12Device);
|
||||
allocatorDesc.pAdapter = dxgiAdapter;
|
||||
|
||||
D3D12MemAlloc.D3D12MA_CreateAllocator(&allocatorDesc, allocator.GetAddressOf()).Assert();
|
||||
|
||||
return allocator.Move();
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする