diff --git a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs
index 20081667..74d0b775 100644
--- a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs
+++ b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs
@@ -1,6 +1,9 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET6_0_OR_GREATER
+using TerraFX.Interop;
+#endif
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -12,7 +15,7 @@ namespace ComputeSharp.Interop.Allocation;
/// An allocation wrapper for a native object.
///
[Guid("D42D5782-2DE7-4539-A817-482E3AA01E2E")]
-internal unsafe struct ID3D12Allocation
+internal unsafe struct ID3D12Allocation : IUnknown.Interface
{
///
/// Gets the for (D42D5782-2DE7-4539-A817-482E3AA01E2E).
@@ -38,11 +41,37 @@ internal unsafe struct ID3D12Allocation
}
}
+#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])((ID3D12Allocation*)Unsafe.AsPointer(ref this), riid, ppvObject);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public uint AddRef()
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[1])((ID3D12Allocation*)Unsafe.AsPointer(ref this));
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public uint Release()
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID3D12Allocation*)Unsafe.AsPointer(ref this));
+ }
+
///
/// Gets the underlying for the current instance.
///
diff --git a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs
index 3841fbaa..2b1e54f9 100644
--- a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs
+++ b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs
@@ -1,6 +1,9 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#if NET6_0_OR_GREATER
+using TerraFX.Interop;
+#endif
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -12,7 +15,7 @@ namespace ComputeSharp.Interop.Allocation;
/// An object that can allocate resources for a given instance.
///
[Guid("2D5E55D2-9244-431F-868E-0D90AAB6E575")]
-internal unsafe struct ID3D12MemoryAllocator
+internal unsafe struct ID3D12MemoryAllocator : IUnknown.Interface
{
///
/// Gets the for (2D5E55D2-9244-431F-868E-0D90AAB6E575).
@@ -38,11 +41,37 @@ internal unsafe struct ID3D12MemoryAllocator
}
}
+#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])((ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this), riid, ppvObject);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public uint AddRef()
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[1])((ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this));
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public uint Release()
+ {
+ return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this));
+ }
+
///
/// Creates a new resource allocation from the current allocator.
///
diff --git a/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs b/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs
index 9a75021e..07e77b06 100644
--- a/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs
+++ b/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs
@@ -38,4 +38,18 @@ internal unsafe partial struct IUnknown
{
return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((IUnknown*)Unsafe.AsPointer(ref this));
}
+
+ public interface Interface
+ {
+ [VtblIndex(0)]
+ HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject);
+
+ [VtblIndex(1)]
+ [return: NativeTypeName("ULONG")]
+ uint AddRef();
+
+ [VtblIndex(2)]
+ [return: NativeTypeName("ULONG")]
+ uint Release();
+ }
}
\ No newline at end of file