Add base skeleton for D2D1DrawInfoUpdateContextImpl

このコミットが含まれているのは:
Sergio Pedri committed 2022-11-29 22:34:05 +01:00
1 親 8291775267
コミット 6fbf37c3cf
6ファイル変更
+374 -10

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

@@ -118,7 +118,7 @@ unsafe partial struct D2D1ResourceTextureManagerImpl
}
/// <summary>
/// The implementation for <c>ID2D1ResourceTextureManager</c>.
/// The implementation for <see cref="ID2D1ResourceTextureManager"/>.
/// </summary>
private static class ID2D1ResourceTextureManagerMethods
{
@@ -13,7 +13,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
partial struct D2D1ResourceTextureManagerImpl
{
/// <summary>
/// The implementation for <c>ID2D1ResourceTextureManagerInternal</c>.
/// The implementation for <see cref="ID2D1ResourceTextureManagerInternal"/>.
/// </summary>
private static unsafe class ID2D1ResourceTextureManagerInternalMethods
{
@@ -13,10 +13,11 @@ using RuntimeHelpers = ComputeSharp.D2D1.NetStandard.System.Runtime.CompilerServ
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
/// <summary>
/// An implementation of the <c>ID2D1ResourceTextureManager</c> and <c>ID2D1ResourceTextureManagerInternal</c> interfaces.
/// An implementation of the <see cref="ID2D1ResourceTextureManager"/> and <see cref="ID2D1ResourceTextureManagerInternal"/> interfaces.
/// </summary>
internal unsafe partial struct D2D1ResourceTextureManagerImpl
{
#if !NET6_0_OR_GREATER
/// <inheritdoc cref="QueryInterface"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int QueryInterfaceDelegate(D2D1ResourceTextureManagerImpl* @this, Guid* riid, void** ppvObject);
@@ -28,21 +29,22 @@ internal unsafe partial struct D2D1ResourceTextureManagerImpl
/// <inheritdoc cref="Release"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate uint ReleaseDelegate(D2D1ResourceTextureManagerImpl* @this);
#endif
/// <summary>
/// The shared vtable pointer for <see cref="D2D1ResourceTextureManagerImpl"/> instance, for <c>ID2D1ResourceTextureManager</c>.
/// The shared vtable pointer for <see cref="D2D1ResourceTextureManagerImpl"/> instance, for <see cref="ID2D1ResourceTextureManager"/>.
/// </summary>
private static readonly void** VtblForID2D1ResourceTextureManager = InitVtblForID2D1ResourceTextureManagerAndID2D1ResourceTextureManagerInternal();
/// <summary>
/// The shared vtable pointer for <see cref="D2D1ResourceTextureManagerImpl"/> instance, for <c>ID2D1ResourceTextureManagerInternal</c>.
/// The shared vtable pointer for <see cref="D2D1ResourceTextureManagerImpl"/> instance, for <see cref="ID2D1ResourceTextureManagerInternal"/>.
/// </summary>
private static readonly void** VtblForID2D1ResourceTextureManagerInternal = &VtblForID2D1ResourceTextureManager[5];
/// <summary>
/// Initializes the combined vtable for <c>ID2D1ResourceTextureManager</c> and <c>ID2D1ResourceTextureManagerInternal</c>.
/// Initializes the combined vtable for <see cref="ID2D1ResourceTextureManager"/> and <see cref="ID2D1ResourceTextureManagerInternal"/>.
/// </summary>
/// <returns>The combined vtable for <c>ID2D1ResourceTextureManager</c> and <c>ID2D1ResourceTextureManagerInternal</c>.</returns>
/// <returns>The combined vtable for <see cref="ID2D1ResourceTextureManager"/> and <see cref="ID2D1ResourceTextureManagerInternal"/>.</returns>
private static void** InitVtblForID2D1ResourceTextureManagerAndID2D1ResourceTextureManagerInternal()
{
void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(D2D1ResourceTextureManagerImpl), sizeof(void*) * 10);
@@ -81,17 +83,17 @@ internal unsafe partial struct D2D1ResourceTextureManagerImpl
}
/// <summary>
/// The vtable pointer for the current instance, for <c>ID2D1ResourceTextureManager</c>.
/// The vtable pointer for the current instance, for <see cref="ID2D1ResourceTextureManager"/>.
/// </summary>
private void** lpVtblForID2D1ResourceTextureManager;
/// <summary>
/// The vtable pointer for the current instance, for <c>ID2D1ResourceTextureManagerInternal</c>.
/// The vtable pointer for the current instance, for <see cref="ID2D1ResourceTextureManagerInternal"/>.
/// </summary>
private void** lpVtblForID2D1ResourceTextureManagerInternal;
/// <summary>
/// The current reference count for the object (from <c>IUnknown</c>).
/// The current reference count for the object (from <see cref="IUnknown"/>).
/// </summary>
private volatile int referenceCount;
@@ -0,0 +1,110 @@
using System;
using System.Runtime.InteropServices;
using TerraFX.Interop.Windows;
#if !NET6_0_OR_GREATER
using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
#endif
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMapperManagers;
/// <inheritdoc/>
partial struct D2D1DrawInfoUpdateContextImpl
{
/// <summary>
/// The implementation for <see cref="ID2D1DrawInfoUpdateContex"/>.
/// </summary>
private static unsafe class ID2D1DrawInfoUpdateContexMethods
{
#if !NET6_0_OR_GREATER
/// <inheritdoc cref="GetConstantBufferSize"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GetConstantBufferSizeDelegate(D2D1DrawInfoUpdateContextImpl* @this, uint* size);
/// <inheritdoc cref="GetConstantBuffer"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int GetConstantBufferDelegate(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount);
/// <inheritdoc cref="SetConstantBuffer"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int SetConstantBufferDelegate(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount);
/// <summary>
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
/// </summary>
public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
/// <summary>
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef"/>.
/// </summary>
public static readonly AddRefDelegate AddRefWrapper = AddRef;
/// <summary>
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
/// </summary>
public static readonly ReleaseDelegate ReleaseWrapper = Release;
/// <summary>
/// A cached <see cref="GetConstantBufferSizeDelegate"/> instance wrapping <see cref="GetConstantBufferSize"/>.
/// </summary>
public static readonly GetConstantBufferSizeDelegate GetConstantBufferSizeWrapper = GetConstantBufferSize;
/// <summary>
/// A cached <see cref="GetConstantBufferDelegate"/> instance wrapping <see cref="GetConstantBuffer"/>.
/// </summary>
public static readonly GetConstantBufferDelegate GetConstantBufferWrapper = GetConstantBuffer;
/// <summary>
/// A cached <see cref="SetConstantBufferDelegate"/> instance wrapping <see cref="SetConstantBuffer"/>.
/// </summary>
public static readonly SetConstantBufferDelegate SetConstantBufferWrapper = SetConstantBuffer;
#endif
/// <inheritdoc cref="D2D1DrawInfoUpdateContextImpl.QueryInterface"/>
[UnmanagedCallersOnly]
public static int QueryInterface(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject)
{
return @this->QueryInterface(riid, ppvObject);
}
/// <inheritdoc cref="D2D1DrawInfoUpdateContextImpl.AddRef"/>
[UnmanagedCallersOnly]
public static uint AddRef(D2D1DrawInfoUpdateContextImpl* @this)
{
return @this->AddRef();
}
/// <inheritdoc cref="D2D1DrawInfoUpdateContextImpl.Release"/>
[UnmanagedCallersOnly]
public static uint Release(D2D1DrawInfoUpdateContextImpl* @this)
{
return @this->Release();
}
/// <inheritdoc cref="ID2D1DrawInfoUpdateContex.GetConstantBufferSize"/>
[UnmanagedCallersOnly]
public static int GetConstantBufferSize(D2D1DrawInfoUpdateContextImpl* @this, uint* size)
{
// TODO
return S.S_OK;
}
/// <inheritdoc cref="ID2D1DrawInfoUpdateContex.GetConstantBuffer"/>
[UnmanagedCallersOnly]
public static int GetConstantBuffer(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount)
{
// TODO
return S.S_OK;
}
/// <inheritdoc cref="ID2D1DrawInfoUpdateContex.SetConstantBuffer"/>
[UnmanagedCallersOnly]
public static int SetConstantBuffer(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount)
{
// TODO
return S.S_OK;
}
}
}
@@ -0,0 +1,82 @@
using System;
using System.Runtime.InteropServices;
using TerraFX.Interop.Windows;
#if !NET6_0_OR_GREATER
using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
#endif
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMapperManagers;
/// <inheritdoc/>
partial struct D2D1DrawInfoUpdateContextImpl
{
/// <summary>
/// The implementation for <see cref="ID2D1DrawInfoUpdateContexInternal"/>.
/// </summary>
private static unsafe class ID2D1DrawInfoUpdateContexInternalMethods
{
#if !NET6_0_OR_GREATER
/// <inheritdoc cref="Close"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int CloseDelegate(D2D1DrawInfoUpdateContextImpl* @this);
/// <summary>
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
/// </summary>
public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
/// <summary>
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef"/>.
/// </summary>
public static readonly AddRefDelegate AddRefWrapper = AddRef;
/// <summary>
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
/// </summary>
public static readonly ReleaseDelegate ReleaseWrapper = Release;
/// <summary>
/// A cached <see cref="CloseDelegate"/> instance wrapping <see cref="Close"/>.
/// </summary>
public static readonly CloseDelegate CloseWrapper = Close;
#endif
/// <inheritdoc cref="D2D1DrawInfoUpdateContextImpl.QueryInterface"/>
[UnmanagedCallersOnly]
public static int QueryInterface(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject)
{
@this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1];
return @this->QueryInterface(riid, ppvObject);
}
/// <inheritdoc cref="D2D1DrawInfoUpdateContextImpl.AddRef"/>
[UnmanagedCallersOnly]
public static uint AddRef(D2D1DrawInfoUpdateContextImpl* @this)
{
@this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1];
return @this->AddRef();
}
/// <inheritdoc cref="D2D1DrawInfoUpdateContextImpl.Release"/>
[UnmanagedCallersOnly]
public static uint Release(D2D1DrawInfoUpdateContextImpl* @this)
{
@this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1];
return @this->Release();
}
/// <inheritdoc cref="ID2D1DrawInfoUpdateContexInternal.Close"/>
[UnmanagedCallersOnly]
public static int Close(D2D1DrawInfoUpdateContextImpl* @this)
{
@this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1];
// TODO
return S.S_OK;
}
}
}
@@ -0,0 +1,170 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using TerraFX.Interop.Windows;
#if NET6_0_OR_GREATER
using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
#else
using RuntimeHelpers = ComputeSharp.D2D1.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
#endif
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMapperManagers;
/// <summary>
/// An implementation of the <see cref="ID2D1DrawInfoUpdateContex"/> and <see cref="ID2D1DrawInfoUpdateContexInternal"/> interfaces.
/// </summary>
internal unsafe partial struct D2D1DrawInfoUpdateContextImpl
{
#if !NET6_0_OR_GREATER
/// <inheritdoc cref="QueryInterface"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int QueryInterfaceDelegate(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject);
/// <inheritdoc cref="AddRef"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate uint AddRefDelegate(D2D1DrawInfoUpdateContextImpl* @this);
/// <inheritdoc cref="Release"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate uint ReleaseDelegate(D2D1DrawInfoUpdateContextImpl* @this);
#endif
/// <summary>
/// The shared vtable pointer for <see cref="D2D1DrawInfoUpdateContextImpl"/> instance, for <see cref="ID2D1DrawInfoUpdateContex"/>.
/// </summary>
private static readonly void** VtblForID2D1DrawInfoUpdateContex = InitVtblForID2D1DrawInfoUpdateContexAndID2D1DrawInfoUpdateContexInternal();
/// <summary>
/// The shared vtable pointer for <see cref="D2D1DrawInfoUpdateContextImpl"/> instance, for <see cref="ID2D1DrawInfoUpdateContexInternal"/>.
/// </summary>
private static readonly void** VtblForID2D1DrawInfoUpdateContexInternal = &VtblForID2D1DrawInfoUpdateContex[5];
/// <summary>
/// Initializes the combined vtable for <see cref="ID2D1DrawInfoUpdateContex"/> and <see cref="ID2D1DrawInfoUpdateContexInternal"/>.
/// </summary>
/// <returns>The combined vtable for <see cref="ID2D1DrawInfoUpdateContex"/> and <see cref="ID2D1DrawInfoUpdateContexInternal"/>.</returns>
private static void** InitVtblForID2D1DrawInfoUpdateContexAndID2D1DrawInfoUpdateContexInternal()
{
void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(D2D1DrawInfoUpdateContextImpl), sizeof(void*) * 10);
// ID2D1ResourceTextureManager
#if NET6_0_OR_GREATER
lpVtbl[0] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, Guid*, void**, int>)&ID2D1DrawInfoUpdateContexMethods.QueryInterface;
lpVtbl[1] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, uint>)&ID2D1DrawInfoUpdateContexMethods.AddRef;
lpVtbl[2] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, uint>)&ID2D1DrawInfoUpdateContexMethods.Release;
lpVtbl[3] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, uint*, int>)&ID2D1DrawInfoUpdateContexMethods.GetConstantBufferSize;
lpVtbl[4] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, byte*, uint, int>)&ID2D1DrawInfoUpdateContexMethods.GetConstantBuffer;
lpVtbl[5] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, byte*, uint, int>)&ID2D1DrawInfoUpdateContexMethods.SetConstantBuffer;
#else
lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexMethods.QueryInterfaceWrapper);
lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexMethods.AddRefWrapper);
lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexMethods.ReleaseWrapper);
lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexMethods.GetConstantBufferSizeWrapper);
lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexMethods.GetConstantBufferWrapper);
lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexMethods.SetConstantBufferWrapper);
#endif
// ID2D1ResourceTextureManagerInternal
#if NET6_0_OR_GREATER
lpVtbl[6 + 0] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, Guid*, void**, int>)&ID2D1DrawInfoUpdateContexInternalMethods.QueryInterface;
lpVtbl[6 + 1] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, uint>)&ID2D1DrawInfoUpdateContexInternalMethods.AddRef;
lpVtbl[6 + 2] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, uint>)&ID2D1DrawInfoUpdateContexInternalMethods.Release;
lpVtbl[6 + 3] = (delegate* unmanaged<D2D1DrawInfoUpdateContextImpl*, int>)&ID2D1DrawInfoUpdateContexInternalMethods.Close;
#else
lpVtbl[6 + 0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexInternalMethods.QueryInterfaceWrapper);
lpVtbl[6 + 1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexInternalMethods.AddRefWrapper);
lpVtbl[6 + 2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexInternalMethods.ReleaseWrapper);
lpVtbl[6 + 3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContexInternalMethods.CloseWrapper);
#endif
return lpVtbl;
}
/// <summary>
/// The vtable pointer for the current instance, for <see cref="ID2D1DrawInfoUpdateContex"/>.
/// </summary>
private void** lpVtblForID2D1DrawInfoUpdateContex;
/// <summary>
/// The vtable pointer for the current instance, for <see cref="ID2D1DrawInfoUpdateContexInternal"/>.
/// </summary>
private void** lpVtblForID2D1DrawInfoUpdateContexInternal;
/// <summary>
/// The current reference count for the object (from <see cref="IUnknown"/>).
/// </summary>
private volatile int referenceCount;
/// <summary>
/// The factory method for <see cref="D2D1DrawInfoUpdateContextImpl"/> instances.
/// </summary>
/// <param name="drawInfoUpdateContext">The resulting draw info update context instance.</param>
public static void Factory(D2D1DrawInfoUpdateContextImpl** drawInfoUpdateContext)
{
D2D1DrawInfoUpdateContextImpl* @this = (D2D1DrawInfoUpdateContextImpl*)NativeMemory.Alloc((nuint)sizeof(D2D1DrawInfoUpdateContextImpl));
*@this = default;
@this->lpVtblForID2D1DrawInfoUpdateContex = VtblForID2D1DrawInfoUpdateContex;
@this->lpVtblForID2D1DrawInfoUpdateContexInternal = VtblForID2D1DrawInfoUpdateContexInternal;
@this->referenceCount = 1;
*drawInfoUpdateContext = @this;
}
/// <inheritdoc cref="IUnknown.QueryInterface"/>
public int QueryInterface(Guid* riid, void** ppvObject)
{
if (ppvObject is null)
{
return E.E_POINTER;
}
// ID2D1DrawInfoUpdateContex
if (riid->Equals(Windows.__uuidof<IUnknown>()) ||
riid->Equals(ID2D1DrawInfoUpdateContex.Guid))
{
_ = Interlocked.Increment(ref this.referenceCount);
*ppvObject = Unsafe.AsPointer(ref this);
return S.S_OK;
}
// ID2D1DrawInfoUpdateContexInternal
if (riid->Equals(ID2D1DrawInfoUpdateContexInternal.Guid))
{
_ = Interlocked.Increment(ref this.referenceCount);
*ppvObject = (void**)Unsafe.AsPointer(ref this) + 1;
return S.S_OK;
}
*ppvObject = null;
return E.E_NOINTERFACE;
}
/// <inheritdoc cref="IUnknown.AddRef"/>
public uint AddRef()
{
return (uint)Interlocked.Increment(ref this.referenceCount);
}
/// <inheritdoc cref="IUnknown.Release"/>
public uint Release()
{
uint referenceCount = (uint)Interlocked.Decrement(ref this.referenceCount);
if (referenceCount == 0)
{
// TODO
NativeMemory.Free(Unsafe.AsPointer(ref this));
}
return referenceCount;
}
}