diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.cs
index a525a984..404ef31b 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/ResourceTextureManager.cs
@@ -2,9 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
-#if NET6_0_OR_GREATER
using TerraFX.Interop.DirectX;
-#endif
using TerraFX.Interop.Windows;
#if NET6_0_OR_GREATER
using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
@@ -139,6 +137,52 @@ internal unsafe partial struct ResourceTextureManager
///
private void** lpVtblForID2D1ResourceTextureManagerInternal;
+ ///
+ /// The current reference count for the object (from IUnknown).
+ ///
+ private volatile int referenceCount;
+
+ ///
+ /// The object currently wrapped by the current instance.
+ ///
+ private ID2D1EffectContext* d2D1EffectContext;
+
+ ///
+ /// The object, if one was created already.
+ ///
+ private ID2D1ResourceTexture* d2D1ResourceTexture;
+
+ ///
+ /// The to identify the resource, if available.
+ ///
+ private Guid* resourceId;
+
+ ///
+ /// The for the resource texture.
+ ///
+ ///
+ /// If is , it has not been set.
+ ///
+ private D2D1_RESOURCE_TEXTURE_PROPERTIES resourceTextureProperties;
+
+ ///
+ /// The texture data, if available.
+ ///
+ ///
+ /// Once the texture has been created, this will no longer be necessary.
+ ///
+ private byte* data;
+
+ ///
+ /// An optional pointer to the stride to advance through the resource texture, according to dimension.
+ ///
+ private uint* strides;
+
+ ///
+ /// The size, in bytes, of the data.
+ ///
+ private uint dataSize;
+
///
/// The factory method for instances.
///
@@ -163,17 +207,20 @@ internal unsafe partial struct ResourceTextureManager
@this->lpVtblForID2D1ResourceTextureManager = VtblForID2D1ResourceTextureManager;
@this->lpVtblForID2D1ResourceTextureManagerInternal = VtblForID2D1ResourceTextureManagerInternal;
+ @this->referenceCount = 1;
+ @this->d2D1EffectContext = null;
+ @this->d2D1ResourceTexture = null;
+ @this->resourceId = null;
+ @this->resourceTextureProperties = default;
+ @this->data = null;
+ @this->strides = null;
+ @this->dataSize = 0;
*resourceTextureManager = @this;
return S.S_OK;
}
- ///
- /// The current reference count for the object (from IUnknown).
- ///
- private volatile int referenceCount;
-
///
private int QueryInterface(Guid* riid, void** ppvObject)
{
@@ -221,7 +268,40 @@ internal unsafe partial struct ResourceTextureManager
if (referenceCount == 0)
{
- // TODO: release resources
+ if (this.d2D1EffectContext is not null)
+ {
+ this.d2D1EffectContext->Release();
+ }
+
+ if (this.d2D1ResourceTexture is not null)
+ {
+ this.d2D1ResourceTexture->Release();
+ }
+
+ if (this.resourceId is not null)
+ {
+ NativeMemory.Free(this.resourceId);
+ }
+
+ if (this.resourceTextureProperties.extents is not null)
+ {
+ NativeMemory.Free(this.resourceTextureProperties.extents);
+ }
+
+ if (this.resourceTextureProperties.extendModes is not null)
+ {
+ NativeMemory.Free(this.resourceTextureProperties.extendModes);
+ }
+
+ if (this.data is not null)
+ {
+ NativeMemory.Free(this.data);
+ }
+
+ if (this.strides is not null)
+ {
+ NativeMemory.Free(this.strides);
+ }
}
return referenceCount;
diff --git a/src/TerraFX.Interop.Windows.D2D1/DirectX/um/d2d1effectauthor/ID2D1EffectContext.cs b/src/TerraFX.Interop.Windows.D2D1/DirectX/um/d2d1effectauthor/ID2D1EffectContext.cs
index dfe7b3be..e9d47721 100644
--- a/src/TerraFX.Interop.Windows.D2D1/DirectX/um/d2d1effectauthor/ID2D1EffectContext.cs
+++ b/src/TerraFX.Interop.Windows.D2D1/DirectX/um/d2d1effectauthor/ID2D1EffectContext.cs
@@ -19,6 +19,29 @@ namespace TerraFX.Interop.DirectX
{
public void** lpVtbl;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(0)]
+ public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[0]))((IUnknown*)Unsafe.AsPointer(ref this), riid, ppvObject);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(1)]
+ [return: NativeTypeName("ULONG")]
+ public uint AddRef()
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[1]))((IUnknown*)Unsafe.AsPointer(ref this));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(2)]
+ [return: NativeTypeName("ULONG")]
+ public uint Release()
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((IUnknown*)Unsafe.AsPointer(ref this));
+ }
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(4)]
public HRESULT CreateEffect([NativeTypeName("const IID &")] Guid* effectId, void** effect)