From bb77049d102f7e7e509a2c77ea57ed5344c088f4 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 11 Aug 2022 02:08:09 +0200 Subject: [PATCH] Add APIs for D2D1 resource manager interfaces --- .../D2D1ResourceTextureManager.cs | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManager.cs index d247eaad..b62d707a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManager.cs @@ -2,6 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; +using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; #if NET6_0_OR_GREATER using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers; @@ -193,6 +194,27 @@ internal unsafe struct D2D1ResourceTextureManager private static class ID2D1ResourceTextureManagerMethods { #if !NET6_0_OR_GREATER + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int CreateResourceTextureDelegate( + D2D1ResourceTextureManager* @this, + Guid* resourceId, + D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties, + byte* data, + uint* strides, + uint dataSize); + + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int UpdateDelegate( + D2D1ResourceTextureManager* @this, + uint* minimumExtents, + uint* maximumExtents, + uint* strides, + uint dimensions, + byte* data, + uint dataCount); + /// /// A cached instance wrapping . /// @@ -207,6 +229,16 @@ internal unsafe struct D2D1ResourceTextureManager /// A cached instance wrapping . /// public static readonly ReleaseDelegate ReleaseWrapper = Release; + + /// + /// A cached instance wrapping . + /// + public static readonly CreateResourceTextureDelegate CreateResourceTextureWrapper = CreateResourceTexture; + + /// + /// A cached instance wrapping . + /// + public static readonly UpdateDelegate UpdateWrapper = Update; #endif /// @@ -229,6 +261,56 @@ internal unsafe struct D2D1ResourceTextureManager { return @this->Release(); } + + /// + /// Creates or finds the given resource texture, depending on whether a resource id is specified. + /// It also optionally initializes the texture with the specified data. + /// + /// The current ID2D1ResourceTextureManager instance. + /// An optional pointer to the unique id that identifies the resource texture. + /// The properties used to create the resource texture. + /// The optional data to be loaded into the resource texture. + /// An optional pointer to the stride to advance through the resource texture, according to dimension. + /// The size, in bytes, of the data. + /// An for the operation. + private static int CreateResourceTexture( + D2D1ResourceTextureManager* @this, + Guid* resourceId, + D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties, + byte* data, + uint* strides, + uint dataSize) + { + @this = (D2D1ResourceTextureManager*)&((void**)@this)[-1]; + + return 0; + } + + /// + /// Updates the specific resource texture inside the specific range or box using the supplied data. + /// + /// The current ID2D1ResourceTextureManager instance. + /// The "left" extent of the updates if specified. If , the entire texture is updated. + /// The "right" extent of the updates if specified. If , the entire texture is updated. + /// The stride to advance through the input data, according to dimension. + /// The number of dimensions in the resource texture. This must match the number used to load the texture. + /// The data to be placed into the resource texture. + /// The size of the data buffer to be used to update the resource texture. + /// An for the operation. + [UnmanagedCallersOnly] + private static int Update( + D2D1ResourceTextureManager* @this, + uint* minimumExtents, + uint* maximumExtents, + uint* strides, + uint dimensions, + byte* data, + uint dataCount) + { + @this = (D2D1ResourceTextureManager*)&((void**)@this)[-1]; + + return 0; + } } /// @@ -237,6 +319,14 @@ internal unsafe struct D2D1ResourceTextureManager private unsafe static class ID2D1ResourceTextureManagerInternalMethods { #if !NET6_0_OR_GREATER + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int InitializeDelegate(D2D1ResourceTextureManager* @this, ID2D1EffectContext* effectContext); + + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate int GetResourceTextureDelegate(D2D1ResourceTextureManager* @this, ID2D1ResourceTexture** resourceTexture); + /// /// A cached instance wrapping . /// @@ -251,6 +341,16 @@ internal unsafe struct D2D1ResourceTextureManager /// A cached instance wrapping . /// public static readonly ReleaseDelegate ReleaseWrapper = Release; + + /// + /// A cached instance wrapping . + /// + public static readonly InitializeDelegate InitializeWrapper = Initialize; + + /// + /// A cached instance wrapping . + /// + public static readonly GetResourceTextureDelegate GetResourceTextureWrapper = GetResourceTexture; #endif /// @@ -279,5 +379,29 @@ internal unsafe struct D2D1ResourceTextureManager return @this->Release(); } + + /// + /// Initializes the current ID2D1ResourceTextureManagerInternal instance. + /// + /// The current ID2D1ResourceTextureManagerInternal instance. + /// The input for the manager. + /// An for the operation. + [UnmanagedCallersOnly] + private static int Initialize(D2D1ResourceTextureManager* @this, ID2D1EffectContext* effectContext) + { + return 0; + } + + /// + /// Gets the instance held by the manager. + /// + /// The current ID2D1ResourceTextureManagerInternal instance. + /// The resulting instance. + /// An for the operation. + [UnmanagedCallersOnly] + private static int GetResourceTexture(D2D1ResourceTextureManager* @this, ID2D1ResourceTexture** resourceTexture) + { + return 0; + } } }