diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs index 959f5ffe..58c2875b 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs @@ -118,7 +118,7 @@ unsafe partial struct D2D1ResourceTextureManagerImpl } /// - /// The implementation for ID2D1ResourceTextureManager. + /// The implementation for . /// private static class ID2D1ResourceTextureManagerMethods { diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs index 9f7cc023..c8e9ba9f 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs @@ -13,7 +13,7 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; partial struct D2D1ResourceTextureManagerImpl { /// - /// The implementation for ID2D1ResourceTextureManagerInternal. + /// The implementation for . /// private static unsafe class ID2D1ResourceTextureManagerInternalMethods { diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs index 31095856..100bc5b1 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs @@ -13,10 +13,11 @@ using RuntimeHelpers = ComputeSharp.D2D1.NetStandard.System.Runtime.CompilerServ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; /// -/// An implementation of the ID2D1ResourceTextureManager and ID2D1ResourceTextureManagerInternal interfaces. +/// An implementation of the and interfaces. /// internal unsafe partial struct D2D1ResourceTextureManagerImpl { +#if !NET6_0_OR_GREATER /// [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int QueryInterfaceDelegate(D2D1ResourceTextureManagerImpl* @this, Guid* riid, void** ppvObject); @@ -28,21 +29,22 @@ internal unsafe partial struct D2D1ResourceTextureManagerImpl /// [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate uint ReleaseDelegate(D2D1ResourceTextureManagerImpl* @this); +#endif /// - /// The shared vtable pointer for instance, for ID2D1ResourceTextureManager. + /// The shared vtable pointer for instance, for . /// private static readonly void** VtblForID2D1ResourceTextureManager = InitVtblForID2D1ResourceTextureManagerAndID2D1ResourceTextureManagerInternal(); /// - /// The shared vtable pointer for instance, for ID2D1ResourceTextureManagerInternal. + /// The shared vtable pointer for instance, for . /// private static readonly void** VtblForID2D1ResourceTextureManagerInternal = &VtblForID2D1ResourceTextureManager[5]; /// - /// Initializes the combined vtable for ID2D1ResourceTextureManager and ID2D1ResourceTextureManagerInternal. + /// Initializes the combined vtable for and . /// - /// The combined vtable for ID2D1ResourceTextureManager and ID2D1ResourceTextureManagerInternal. + /// The combined vtable for and . private static void** InitVtblForID2D1ResourceTextureManagerAndID2D1ResourceTextureManagerInternal() { void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(D2D1ResourceTextureManagerImpl), sizeof(void*) * 10); @@ -81,17 +83,17 @@ internal unsafe partial struct D2D1ResourceTextureManagerImpl } /// - /// The vtable pointer for the current instance, for ID2D1ResourceTextureManager. + /// The vtable pointer for the current instance, for . /// private void** lpVtblForID2D1ResourceTextureManager; /// - /// The vtable pointer for the current instance, for ID2D1ResourceTextureManagerInternal. + /// The vtable pointer for the current instance, for . /// private void** lpVtblForID2D1ResourceTextureManagerInternal; /// - /// The current reference count for the object (from IUnknown). + /// The current reference count for the object (from ). /// private volatile int referenceCount; diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs new file mode 100644 index 00000000..2ced1422 --- /dev/null +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs @@ -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; + +/// +partial struct D2D1DrawInfoUpdateContextImpl +{ + /// + /// The implementation for . + /// + private static unsafe class ID2D1DrawInfoUpdateContexMethods + { +#if !NET6_0_OR_GREATER + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int GetConstantBufferSizeDelegate(D2D1DrawInfoUpdateContextImpl* @this, uint* size); + + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int GetConstantBufferDelegate(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount); + + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int SetConstantBufferDelegate(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount); + + /// + /// A cached instance wrapping . + /// + public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; + + /// + /// A cached instance wrapping . + /// + public static readonly AddRefDelegate AddRefWrapper = AddRef; + + /// + /// A cached instance wrapping . + /// + public static readonly ReleaseDelegate ReleaseWrapper = Release; + + /// + /// A cached instance wrapping . + /// + public static readonly GetConstantBufferSizeDelegate GetConstantBufferSizeWrapper = GetConstantBufferSize; + + /// + /// A cached instance wrapping . + /// + public static readonly GetConstantBufferDelegate GetConstantBufferWrapper = GetConstantBuffer; + + /// + /// A cached instance wrapping . + /// + public static readonly SetConstantBufferDelegate SetConstantBufferWrapper = SetConstantBuffer; +#endif + + /// + [UnmanagedCallersOnly] + public static int QueryInterface(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject) + { + return @this->QueryInterface(riid, ppvObject); + } + + /// + [UnmanagedCallersOnly] + public static uint AddRef(D2D1DrawInfoUpdateContextImpl* @this) + { + return @this->AddRef(); + } + + /// + [UnmanagedCallersOnly] + public static uint Release(D2D1DrawInfoUpdateContextImpl* @this) + { + return @this->Release(); + } + + /// + [UnmanagedCallersOnly] + public static int GetConstantBufferSize(D2D1DrawInfoUpdateContextImpl* @this, uint* size) + { + // TODO + + return S.S_OK; + } + + /// + [UnmanagedCallersOnly] + public static int GetConstantBuffer(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount) + { + // TODO + + return S.S_OK; + } + + /// + [UnmanagedCallersOnly] + public static int SetConstantBuffer(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount) + { + // TODO + + return S.S_OK; + } + } +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs new file mode 100644 index 00000000..7bbce424 --- /dev/null +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs @@ -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; + +/// +partial struct D2D1DrawInfoUpdateContextImpl +{ + /// + /// The implementation for . + /// + private static unsafe class ID2D1DrawInfoUpdateContexInternalMethods + { +#if !NET6_0_OR_GREATER + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int CloseDelegate(D2D1DrawInfoUpdateContextImpl* @this); + + /// + /// A cached instance wrapping . + /// + public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; + + /// + /// A cached instance wrapping . + /// + public static readonly AddRefDelegate AddRefWrapper = AddRef; + + /// + /// A cached instance wrapping . + /// + public static readonly ReleaseDelegate ReleaseWrapper = Release; + + /// + /// A cached instance wrapping . + /// + public static readonly CloseDelegate CloseWrapper = Close; +#endif + + /// + [UnmanagedCallersOnly] + public static int QueryInterface(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject) + { + @this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1]; + + return @this->QueryInterface(riid, ppvObject); + } + + /// + [UnmanagedCallersOnly] + public static uint AddRef(D2D1DrawInfoUpdateContextImpl* @this) + { + @this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1]; + + return @this->AddRef(); + } + + /// + [UnmanagedCallersOnly] + public static uint Release(D2D1DrawInfoUpdateContextImpl* @this) + { + @this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1]; + + return @this->Release(); + } + + /// + [UnmanagedCallersOnly] + public static int Close(D2D1DrawInfoUpdateContextImpl* @this) + { + @this = (D2D1DrawInfoUpdateContextImpl*)&((void**)@this)[-1]; + + // TODO + + return S.S_OK; + } + } +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.cs new file mode 100644 index 00000000..84284fa1 --- /dev/null +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMapperManagers/D2D1DrawInfoUpdateContextImpl.cs @@ -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; + +/// +/// An implementation of the and interfaces. +/// +internal unsafe partial struct D2D1DrawInfoUpdateContextImpl +{ +#if !NET6_0_OR_GREATER + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int QueryInterfaceDelegate(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject); + + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate uint AddRefDelegate(D2D1DrawInfoUpdateContextImpl* @this); + + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate uint ReleaseDelegate(D2D1DrawInfoUpdateContextImpl* @this); +#endif + + /// + /// The shared vtable pointer for instance, for . + /// + private static readonly void** VtblForID2D1DrawInfoUpdateContex = InitVtblForID2D1DrawInfoUpdateContexAndID2D1DrawInfoUpdateContexInternal(); + + /// + /// The shared vtable pointer for instance, for . + /// + private static readonly void** VtblForID2D1DrawInfoUpdateContexInternal = &VtblForID2D1DrawInfoUpdateContex[5]; + + /// + /// Initializes the combined vtable for and . + /// + /// The combined vtable for and . + private static void** InitVtblForID2D1DrawInfoUpdateContexAndID2D1DrawInfoUpdateContexInternal() + { + void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(D2D1DrawInfoUpdateContextImpl), sizeof(void*) * 10); + + // ID2D1ResourceTextureManager +#if NET6_0_OR_GREATER + lpVtbl[0] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexMethods.QueryInterface; + lpVtbl[1] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexMethods.AddRef; + lpVtbl[2] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexMethods.Release; + lpVtbl[3] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexMethods.GetConstantBufferSize; + lpVtbl[4] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexMethods.GetConstantBuffer; + lpVtbl[5] = (delegate* unmanaged)&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)&ID2D1DrawInfoUpdateContexInternalMethods.QueryInterface; + lpVtbl[6 + 1] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexInternalMethods.AddRef; + lpVtbl[6 + 2] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContexInternalMethods.Release; + lpVtbl[6 + 3] = (delegate* unmanaged)&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; + } + + /// + /// The vtable pointer for the current instance, for . + /// + private void** lpVtblForID2D1DrawInfoUpdateContex; + + /// + /// The vtable pointer for the current instance, for . + /// + private void** lpVtblForID2D1DrawInfoUpdateContexInternal; + + /// + /// The current reference count for the object (from ). + /// + private volatile int referenceCount; + + /// + /// The factory method for instances. + /// + /// The resulting draw info update context instance. + 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; + } + + /// + public int QueryInterface(Guid* riid, void** ppvObject) + { + if (ppvObject is null) + { + return E.E_POINTER; + } + + // ID2D1DrawInfoUpdateContex + if (riid->Equals(Windows.__uuidof()) || + 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; + } + + /// + public uint AddRef() + { + return (uint)Interlocked.Increment(ref this.referenceCount); + } + + /// + public uint Release() + { + uint referenceCount = (uint)Interlocked.Decrement(ref this.referenceCount); + + if (referenceCount == 0) + { + // TODO + + NativeMemory.Free(Unsafe.AsPointer(ref this)); + } + + return referenceCount; + } +} \ No newline at end of file