From f41dd507c80677db9b7147f263021ef5e5d3c260 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 12 Aug 2022 16:40:43 +0200 Subject: [PATCH] Minor code tweaks --- .../Interop/D2D1ResourceTextureManager.cs | 8 ++--- .../ID2D1ResourceTextureManager.cs | 36 +++++++++---------- .../ID2D1ResourceTextureManagerInternal.cs | 14 ++++---- ...tureManager.ID2D1ResourceTextureManager.cs | 33 +++++++++++++---- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs index e749dd6b..47a167a8 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ResourceTextureManager.cs @@ -135,14 +135,14 @@ public static unsafe class D2D1ResourceTextureManager /// /// A pointer to the ID2D1ResourceTextureManager instance to use. /// The "left" extent of the updates if specified (if empty, the entire texture is updated). - /// The "right" extent of the updates if specified (if empty, the entire texture is updated). + /// The "right" extent of the updates if specified (if empty, 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. public static void Update( void* resourceTextureManager, ReadOnlySpan minimumExtents, - ReadOnlySpan maximumExtents, + ReadOnlySpan maximimumExtents, ReadOnlySpan strides, uint dimensions, ReadOnlySpan data) @@ -150,13 +150,13 @@ public static unsafe class D2D1ResourceTextureManager // TODO: validate argument and return fixed (uint* pMinimumExtents = minimumExtents) - fixed (uint* pMaximumExtents = maximumExtents) + fixed (uint* pMaximumExtents = maximimumExtents) fixed (uint* pStrides = strides) fixed (byte* pData = data) { int hresult = ((ID2D1ResourceTextureManager*)resourceTextureManager)->Update( minimumExtents: pMinimumExtents, - maximumExtents: pMaximumExtents, + maximimumExtents: pMaximumExtents, strides: pStrides, dimensions: dimensions, data: pData, diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs index 641d4d7d..690f7db6 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManager.cs @@ -61,21 +61,20 @@ internal unsafe struct ID2D1ResourceTextureManager uint* strides, uint dataSize) { - return - ((delegate* unmanaged[Stdcall])this.lpVtbl[3])( - (ID2D1ResourceTextureManager*)Unsafe.AsPointer(ref this), - resourceId, - resourceTextureProperties, - data, - strides, - dataSize); + return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])( + (ID2D1ResourceTextureManager*)Unsafe.AsPointer(ref this), + resourceId, + resourceTextureProperties, + data, + strides, + dataSize); } /// /// Updates the specific resource texture inside the specific range or box using the supplied data. /// /// 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 "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. @@ -84,20 +83,19 @@ internal unsafe struct ID2D1ResourceTextureManager [MethodImpl(MethodImplOptions.AggressiveInlining)] public int Update( uint* minimumExtents, - uint* maximumExtents, + uint* maximimumExtents, uint* strides, uint dimensions, byte* data, uint dataCount) { - return - ((delegate* unmanaged[Stdcall])this.lpVtbl[4])( - (ID2D1ResourceTextureManager*)Unsafe.AsPointer(ref this), - minimumExtents, - maximumExtents, - strides, - dimensions, - data, - dataCount); + return ((delegate* unmanaged[Stdcall])this.lpVtbl[4])( + (ID2D1ResourceTextureManager*)Unsafe.AsPointer(ref this), + minimumExtents, + maximimumExtents, + strides, + dimensions, + data, + dataCount); } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs index f090788c..d89d79fb 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ID2D1ResourceTextureManagerInternal.cs @@ -51,10 +51,9 @@ internal unsafe struct ID2D1ResourceTextureManagerInternal [MethodImpl(MethodImplOptions.AggressiveInlining)] public int SetEffectContext(ID2D1EffectContext* effectContext) { - return - ((delegate* unmanaged[Stdcall])this.lpVtbl[3])( - (ID2D1ResourceTextureManagerInternal*)Unsafe.AsPointer(ref this), - effectContext); + return ((delegate* unmanaged[Stdcall])this.lpVtbl[3])( + (ID2D1ResourceTextureManagerInternal*)Unsafe.AsPointer(ref this), + effectContext); } /// @@ -65,9 +64,8 @@ internal unsafe struct ID2D1ResourceTextureManagerInternal [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetResourceTexture(ID2D1ResourceTexture** resourceTexture) { - return - ((delegate* unmanaged[Stdcall])this.lpVtbl[4])( - (ID2D1ResourceTextureManagerInternal*)Unsafe.AsPointer(ref this), - resourceTexture); + return ((delegate* unmanaged[Stdcall])this.lpVtbl[4])( + (ID2D1ResourceTextureManagerInternal*)Unsafe.AsPointer(ref this), + resourceTexture); } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.ID2D1ResourceTextureManager.cs index f48dd4ed..b8849221 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.ID2D1ResourceTextureManager.cs @@ -32,7 +32,7 @@ partial struct ResourceTextureManager public delegate int UpdateDelegate( ResourceTextureManager* @this, uint* minimumExtents, - uint* maximumExtents, + uint* maximimumExtents, uint* strides, uint dimensions, byte* data, @@ -141,14 +141,14 @@ partial struct ResourceTextureManager public static int Update( ResourceTextureManager* @this, uint* minimumExtents, - uint* maximumExtents, + uint* maximimumExtents, uint* strides, uint dimensions, byte* data, uint dataCount) { if (minimumExtents is null || - maximumExtents is null || + maximimumExtents is null || data is null) { return E.E_POINTER; @@ -167,16 +167,22 @@ partial struct ResourceTextureManager { return @this->d2D1ResourceTexture->Update( minimumExtents: minimumExtents, - maximimumExtents: maximumExtents, + maximimumExtents: maximimumExtents, strides: strides, dimensions: dimensions, data: data, dataCount: dataCount); } - // TODO: implement Update over buffered data - - return 0; + // Otherwise update the staging buffer + return UpdateWithStagingBuffer( + @this: @this, + minimumExtents: minimumExtents, + maximimumExtents: maximimumExtents, + strides: strides, + dimensions: dimensions, + data: data, + dataCount: dataCount); } } @@ -286,5 +292,18 @@ partial struct ResourceTextureManager return S.S_OK; } + + /// + private static int UpdateWithStagingBuffer( + ResourceTextureManager* @this, + uint* minimumExtents, + uint* maximimumExtents, + uint* strides, + uint dimensions, + byte* data, + uint dataCount) + { + return E.E_NOTIMPL; + } } }