Add allocation COM API definitions

このコミットが含まれているのは:
Sergio Pedri committed 2023-07-01 20:57:24 +02:00
1 親 aa4236a07d
コミット 5c60e773b0
3ファイル変更
+197

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

+61
ファイルの表示
@@ -0,0 +1,61 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#pragma warning disable CS0649
namespace ComputeSharp.Interop.Allocation;
/// <summary>
/// An allocation wrapper for a native <see cref="ID3D12Resource"/> object.
/// </summary>
[Guid("D42D5782-2DE7-4539-A817-482E3AA01E2E")]
internal unsafe struct ID3D12Allocation
{
/// <summary>
/// Gets the <see cref="System.Guid"/> for <see cref="ID3D12Allocation"/> (<c>D42D5782-2DE7-4539-A817-482E3AA01E2E</c>).
/// </summary>
public static ref readonly Guid Guid
{
get
{
ReadOnlySpan<byte> data = new byte[] {
0x82, 0x57, 0x2D, 0xD4,
0xE7, 0x2D,
0x39, 0x45,
0xA8, 0x17,
0x48,
0x2E,
0x3A,
0xA0,
0x1E,
0x2E
};
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
/// <summary>
/// The vtable for the current instance.
/// </summary>
private readonly void** lpVtbl;
/// <summary>
/// Gets the underlying <see cref="ID3D12Resource"/> for the current instance.
/// </summary>
/// <param name="resource">The resulting <see cref="ID3D12Resource"/> object.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
/// <remarks>
/// The returned resource should not be used after the current allocation instance has been released.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT GetD3D12Resource(ID3D12Resource** resource)
{
return ((delegate* unmanaged[Stdcall]<ID3D12Allocation*, ID3D12Resource**, int>)this.lpVtbl[3])(
(ID3D12Allocation*)Unsafe.AsPointer(ref this),
resource);
}
}
+71
ファイルの表示
@@ -0,0 +1,71 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#pragma warning disable CS0649
namespace ComputeSharp.Interop.Allocation;
/// <summary>
/// An object that can allocate resources for a given <see cref="ID3D12Device"/> instance.
/// </summary>
[Guid("2D5E55D2-9244-431F-868E-0D90AAB6E575")]
internal unsafe struct ID3D12MemoryAllocator
{
/// <summary>
/// Gets the <see cref="System.Guid"/> for <see cref="ID3D12MemoryAllocator"/> (<c>2D5E55D2-9244-431F-868E-0D90AAB6E575</c>).
/// </summary>
public static ref readonly Guid Guid
{
get
{
ReadOnlySpan<byte> data = new byte[] {
0xD2, 0x55, 0x5E, 0x2D,
0x44, 0x92,
0x1F, 0x43,
0x86, 0x8E,
0x0D,
0x90,
0xAA,
0xB6,
0xE5,
0x75
};
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
/// <summary>
/// The vtable for the current instance.
/// </summary>
private readonly void** lpVtbl;
/// <summary>
/// Creates a new resource allocation from the current allocator.
/// </summary>
/// <param name="resourceDescription">The description of the resource to allocate.</param>
/// <param name="heapType">The type of heap to use for the allocation.</param>
/// <param name="resourceState">The resource state to use initially for the resource.</param>
/// <param name="clearAllocation">Whether to clear the allocation after creating it.</param>
/// <param name="allocation">The resulting allocation.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT AllocateResource(
D3D12_RESOURCE_DESC* resourceDescription,
D3D12_HEAP_TYPE heapType,
D3D12_RESOURCE_STATES resourceState,
BOOL clearAllocation,
ID3D12Allocation** allocation)
{
return ((delegate* unmanaged[Stdcall]<ID3D12MemoryAllocator*, D3D12_RESOURCE_DESC*, D3D12_HEAP_TYPE, D3D12_RESOURCE_STATES, BOOL, ID3D12Allocation**, int>)this.lpVtbl[3])(
(ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this),
resourceDescription,
heapType,
resourceState,
clearAllocation,
allocation);
}
}
+65
ファイルの表示
@@ -0,0 +1,65 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#pragma warning disable CS0649
namespace ComputeSharp.Interop.Allocation;
/// <summary>
/// A factory type for <see cref="ID3D12MemoryAllocator"/> objects.
/// </summary>
[Guid("CC1E74A7-786D-40F4-8AE2-F8B7A255587E")]
internal unsafe struct ID3D12MemoryAllocatorFactory
{
/// <summary>
/// Gets the <see cref="System.Guid"/> for <see cref="ID3D12MemoryAllocatorFactory"/> (<c>CC1E74A7-786D-40F4-8AE2-F8B7A255587E</c>).
/// </summary>
public static ref readonly Guid Guid
{
get
{
ReadOnlySpan<byte> data = new byte[] {
0xA7, 0x74, 0x1E, 0xCC,
0x6D, 0x78,
0xF4, 0x40,
0x8A, 0xE2,
0xF8,
0xB7,
0xA2,
0x55,
0x58,
0x7E
};
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
/// <summary>
/// The vtable for the current instance.
/// </summary>
private readonly void** lpVtbl;
/// <summary>
/// Creates a new <see cref="ID3D12MemoryAllocator"/> for a given device.
/// </summary>
/// <param name="device">The device to create the allocator for.</param>
/// <param name="adapter">The <see cref="IDXGIAdapter"/> for <paramref name="device"/>.</param>
/// <param name="allocator">The resulting <see cref="ID3D12MemoryAllocator"/> instance.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT CreateAllocator(
ID3D12Device* device,
IDXGIAdapter* adapter,
ID3D12MemoryAllocator** allocator)
{
return ((delegate* unmanaged[Stdcall]<ID3D12MemoryAllocatorFactory*, ID3D12Device*, IDXGIAdapter*, ID3D12MemoryAllocator**, int>)this.lpVtbl[3])(
(ID3D12MemoryAllocatorFactory*)Unsafe.AsPointer(ref this),
device,
adapter,
allocator);
}
}