using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Win32;
#pragma warning disable CS0649
namespace ComputeSharp.Interop.Allocation;
///
/// A factory type for objects.
///
[Guid("CC1E74A7-786D-40F4-8AE2-F8B7A255587E")]
internal unsafe struct ID3D12MemoryAllocatorFactory
#if NET6_0_OR_GREATER
//: IUnknown.Interface
#endif
{
///
/// Gets the for (CC1E74A7-786D-40F4-8AE2-F8B7A255587E).
///
public static ref readonly Guid Guid
{
get
{
ReadOnlySpan data = new byte[] {
0xA7, 0x74, 0x1E, 0xCC,
0x6D, 0x78,
0xF4, 0x40,
0x8A, 0xE2,
0xF8,
0xB7,
0xA2,
0x55,
0x58,
0x7E
};
return ref Unsafe.As(ref MemoryMarshal.GetReference(data));
}
}
#if NET6_0_OR_GREATER
/////
//static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
#endif
///
/// The vtable for the current instance.
///
private readonly void** lpVtbl;
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT QueryInterface(Guid* riid, void** ppvObject)
{
return ((delegate* unmanaged[Stdcall])this.lpVtbl[0])((ID3D12MemoryAllocatorFactory*)Unsafe.AsPointer(ref this), riid, ppvObject);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public uint AddRef()
{
return ((delegate* unmanaged[Stdcall])this.lpVtbl[1])((ID3D12MemoryAllocatorFactory*)Unsafe.AsPointer(ref this));
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public uint Release()
{
return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID3D12MemoryAllocatorFactory*)Unsafe.AsPointer(ref this));
}
///
/// Creates a new for a given device.
///
/// The device to create the allocator for.
/// The for .
/// The resulting instance.
/// An for the operation.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT CreateAllocator(
ID3D12Device* device,
IDXGIAdapter* adapter,
ID3D12MemoryAllocator** allocator)
{
return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])(
(ID3D12MemoryAllocatorFactory*)Unsafe.AsPointer(ref this),
device,
adapter,
allocator);
}
}