Add IUnknown.Interface type to memory allocator types
このコミットが含まれているのは:
1 親
5c60e773b0
コミット
5f02ddaffe
3ファイル変更
+74
-2
検索条件に一致するファイルはありません
@@ -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 <see cref="ID3D12Resource"/> object.
|
||||
/// </summary>
|
||||
[Guid("D42D5782-2DE7-4539-A817-482E3AA01E2E")]
|
||||
internal unsafe struct ID3D12Allocation
|
||||
internal unsafe struct ID3D12Allocation : IUnknown.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="System.Guid"/> for <see cref="ID3D12Allocation"/> (<c>D42D5782-2DE7-4539-A817-482E3AA01E2E</c>).
|
||||
@@ -38,11 +41,37 @@ internal unsafe struct ID3D12Allocation
|
||||
}
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The vtable for the current instance.
|
||||
/// </summary>
|
||||
private readonly void** lpVtbl;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public HRESULT QueryInterface(Guid* riid, void** ppvObject)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3D12Allocation*, Guid*, void**, int>)this.lpVtbl[0])((ID3D12Allocation*)Unsafe.AsPointer(ref this), riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint AddRef()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3D12Allocation*, uint>)this.lpVtbl[1])((ID3D12Allocation*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint Release()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3D12Allocation*, uint>)this.lpVtbl[2])((ID3D12Allocation*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the underlying <see cref="ID3D12Resource"/> for the current instance.
|
||||
/// </summary>
|
||||
|
||||
@@ -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 <see cref="ID3D12Device"/> instance.
|
||||
/// </summary>
|
||||
[Guid("2D5E55D2-9244-431F-868E-0D90AAB6E575")]
|
||||
internal unsafe struct ID3D12MemoryAllocator
|
||||
internal unsafe struct ID3D12MemoryAllocator : IUnknown.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="System.Guid"/> for <see cref="ID3D12MemoryAllocator"/> (<c>2D5E55D2-9244-431F-868E-0D90AAB6E575</c>).
|
||||
@@ -38,11 +41,37 @@ internal unsafe struct ID3D12MemoryAllocator
|
||||
}
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The vtable for the current instance.
|
||||
/// </summary>
|
||||
private readonly void** lpVtbl;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public HRESULT QueryInterface(Guid* riid, void** ppvObject)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3D12MemoryAllocator*, Guid*, void**, int>)this.lpVtbl[0])((ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this), riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint AddRef()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3D12MemoryAllocator*, uint>)this.lpVtbl[1])((ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint Release()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3D12MemoryAllocator*, uint>)this.lpVtbl[2])((ID3D12MemoryAllocator*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new resource allocation from the current allocator.
|
||||
/// </summary>
|
||||
|
||||
@@ -38,4 +38,18 @@ internal unsafe partial struct IUnknown
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IUnknown*, uint>)(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();
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする