From 7d3942611abbb254850834297674be56d560a06e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 15 Nov 2022 12:21:44 +0100 Subject: [PATCH] Remove ID2D1TransformMapperFactory from APIs --- .../Shaders/Interop/D2D1PixelShaderEffect.cs | 108 +----- .../Effects/PixelShaderEffect.For{T}.cs | 310 +++++++++--------- ...lShaderEffect.ID2D1DrawTransformMethods.cs | 72 ---- .../Interop/Effects/PixelShaderEffect.cs | 11 - 4 files changed, 160 insertions(+), 341 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index 7693ef62..aeeaa69a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -35,53 +35,8 @@ public static unsafe class D2D1PixelShaderEffect ThrowHelper.ThrowArgumentNullException(nameof(d2D1Factory1), "The input ID2D1Factory1 object cannot be null."); } - RegisterForD2D1Factory1(d2D1Factory1, null, out effectId); - } - - /// - /// Registers an effect from an input D2D1 pixel shader, by calling ID2D1Factory1::RegisterEffectFromString. - /// - /// The type of D2D1 pixel shader to register. - /// The type of implementation to register. - /// A pointer to the ID2D1Factory1 instance to use. - /// The of the registered effect, which can be used to call ID2D1DeviceContext::CreateEffect. - /// Thrown if is . - /// Thrown if an effect is registered multiple times with different properties. - /// For more info, see . - public static void RegisterForD2D1Factory1(void* d2D1Factory1, out Guid effectId) - where T : unmanaged, ID2D1PixelShader - where TMapper : class, ID2D1TransformMapper, new() - { - if (d2D1Factory1 is null) - { - ThrowHelper.ThrowArgumentNullException(nameof(d2D1Factory1), "The input ID2D1Factory1 object cannot be null."); - } - - RegisterForD2D1Factory1(d2D1Factory1, D2D1TransformMapper.FactoryOf.Instance, out effectId); - } - - /// - /// Registers an effect from an input D2D1 pixel shader, by calling ID2D1Factory1::RegisterEffectFromString. - /// - /// The type of D2D1 pixel shader to register. - /// A pointer to the ID2D1Factory1 instance to use. - /// An optional factory of instances to use for the transform. - /// The of the registered effect, which can be used to call ID2D1DeviceContext::CreateEffect. - /// Thrown if is . - /// Thrown if an effect is registered multiple times with different properties. - /// For more info, see . - public static void RegisterForD2D1Factory1(void* d2D1Factory1, ID2D1TransformMapperFactory? mapperFactory, out Guid effectId) - where T : unmanaged, ID2D1PixelShader - { - if (d2D1Factory1 is null) - { - ThrowHelper.ThrowArgumentNullException(nameof(d2D1Factory1), "The input ID2D1Factory1 object cannot be null."); - } - effectId = default; - PixelShaderEffect.For.Initialize(mapperFactory); - ArrayPoolBufferWriter writer = new(ArrayPoolBinaryWriter.DefaultInitialBufferSize); // Build the XML text @@ -101,7 +56,7 @@ public static unsafe class D2D1PixelShaderEffect """); // Add the input nodes - for (int i = 0; i < PixelShaderEffect.For.InputCount; i++) + for (int i = 0; i < PixelShaderEffect.For.Instance.InputCount; i++) { writer.WriteRaw(" .Factory); + writer.WriteRaw((nint)PixelShaderEffect.For.Instance.Factory); byte[] registrationBlob = writer.WrittenSpan.ToArray(); writer.Dispose(); // Extract the effect id (the same that was encoded in the registration blob) - effectId = PixelShaderEffect.For.Id; + effectId = PixelShaderEffect.For.Instance.Id; return registrationBlob; } @@ -562,14 +484,12 @@ public static unsafe class D2D1PixelShaderEffect ThrowHelper.ThrowArgumentNullException(nameof(d2D1Effect), "The pointer to the target ID2D1Effect result cannot be null."); } - if (!PixelShaderEffect.For.TryGetId(out Guid id)) + fixed (Guid* pGuid = &PixelShaderEffect.For.Instance.Id) { - ThrowHelper.ThrowInvalidOperationException("The effect for the input shader type has not been initialized yet."); + ((ID2D1DeviceContext*)d2D1DeviceContext)->CreateEffect( + effectId: pGuid, + effect: (ID2D1Effect**)d2D1Effect).Assert(); } - - ((ID2D1DeviceContext*)d2D1DeviceContext)->CreateEffect( - effectId: &id, - effect: (ID2D1Effect**)d2D1Effect).Assert(); } /// diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs index b96e0ed8..237cb296 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.For{T}.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using ComputeSharp.D2D1.Helpers; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; #if NET6_0_OR_GREATER @@ -10,8 +9,6 @@ using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers; using RuntimeHelpers = ComputeSharp.D2D1.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers; #endif -#pragma warning disable CA2002 - namespace ComputeSharp.D2D1.Interop.Effects; /// @@ -31,18 +28,13 @@ internal unsafe partial struct PixelShaderEffect /// A generic pixel shader implementation. /// /// The type of shader. - public static class For + public sealed class For where T : unmanaged, ID2D1PixelShader { /// /// The wrapper for the shader factory. /// - private static readonly FactoryDelegate EffectFactory = CreateEffect; - - /// - /// Indicates whether or not initialization has completed. - /// - private static bool isInitialized; + private readonly FactoryDelegate effectFactory; /// /// The for the shader. @@ -52,229 +44,168 @@ internal unsafe partial struct PixelShaderEffect /// being used to pass its address to a native API, but the attribute is incompatible with collectible assemblies. /// Because of that, it can't be used, as this project is explicitly meant to support plugin-like scenarios. /// - private static Guid shaderId; + private readonly Guid shaderId; /// /// The size of the constant buffer for the shader. /// - private static int constantBufferSize; + private readonly int constantBufferSize; /// /// The number of inputs for the shader. /// - private static int inputCount; + private readonly int inputCount; /// /// The buffer with the types of inputs for the shader. /// - private static D2D1PixelShaderInputType* inputTypes; + private readonly D2D1PixelShaderInputType* inputTypes; /// /// The number of available input descriptions. /// - private static int inputDescriptionCount; + private readonly int inputDescriptionCount; /// /// The buffer with the available input descriptions for the shader. /// - private static D2D1InputDescription* inputDescriptions; + private readonly D2D1InputDescription* inputDescriptions; /// /// The pixel options for the shader. /// - private static D2D1PixelOptions pixelOptions; + private readonly D2D1PixelOptions pixelOptions; /// /// The shader bytecode. /// - private static byte* bytecode; + private readonly byte* bytecode; /// /// The size of . /// - private static int bytecodeSize; + private readonly int bytecodeSize; /// /// The buffer precision for the resulting output buffer. /// - private static D2D1BufferPrecision bufferPrecision; + private readonly D2D1BufferPrecision bufferPrecision; /// /// The channel depth for the resulting output buffer. /// - private static D2D1ChannelDepth channelDepth; + private readonly D2D1ChannelDepth channelDepth; /// /// The number of available resource texture descriptions. /// - private static int resourceTextureDescriptionCount; + private readonly int resourceTextureDescriptionCount; /// /// The buffer with the available resource texture descriptions for the shader. /// - private static D2D1ResourceTextureDescription* resourceTextureDescriptions; + private readonly D2D1ResourceTextureDescription* resourceTextureDescriptions; /// - /// The factory of instances to use for each created effect. + /// Creates a new instance with the specified parameters. /// - private static ID2D1TransformMapperFactory? d2D1DrawTransformMapperFactory; - - /// - /// Initializes the shared state. - /// - /// The factory of instances to use for each created effect. - /// Thrown if initialization is attempted with a mismatched transform factory. - public static void Initialize(ID2D1TransformMapperFactory? d2D1DrawTransformMapperFactory) + /// The wrapper for the shader factory. + /// The for the shader. + /// The size of the constant buffer for the shader. + /// The number of inputs for the shader. + /// The buffer with the types of inputs for the shader. + /// The number of available input descriptions. + /// The buffer with the available input descriptions for the shader. + /// The pixel options for the shader. + /// The shader bytecode. + /// The size of . + /// The buffer precision for the resulting output buffer. + /// The channel depth for the resulting output buffer. + /// The number of available resource texture descriptions. + /// The buffer with the available resource texture descriptions for the shader. + private For( + FactoryDelegate effectFactory, + Guid shaderId, + int constantBufferSize, + int inputCount, + D2D1PixelShaderInputType* inputTypes, + int inputDescriptionCount, + D2D1InputDescription* inputDescriptions, + D2D1PixelOptions pixelOptions, + byte* bytecode, + int bytecodeSize, + D2D1BufferPrecision bufferPrecision, + D2D1ChannelDepth channelDepth, + int resourceTextureDescriptionCount, + D2D1ResourceTextureDescription* resourceTextureDescriptions) { - // This conceptually acts as a static constructor, and this type is - // internal, so in this very specific case locking on the type is fine. - lock (typeof(For)) - { - if (isInitialized) - { - // If the factory is already initialized, ensure the draw transform mapper is the same - if (For.d2D1DrawTransformMapperFactory != d2D1DrawTransformMapperFactory) - { - ThrowHelper.ThrowInvalidOperationException( - "Cannot initialize an ID2D1Effect factory for the same shader type with two different transform mapper factories. " + - "Make sure to only ever register a pixel shader effect with either no transform, or the same transform mapper factory instance."); - } - } - else - { - // Load all shader properties - Guid shaderId = typeof(T).GUID; - int constantBufferSize = D2D1PixelShader.GetConstantBufferSize(); - D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision(); - D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth(); - D2D1PixelOptions pixelOptions = D2D1PixelShader.GetPixelOptions(); - - // Prepare the inputs info - int inputCount = D2D1PixelShader.GetInputCount(); - D2D1PixelShaderInputType* inputTypes = (D2D1PixelShaderInputType*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1PixelShaderInputType) * inputCount); - - for (int i = 0; i < inputCount; i++) - { - inputTypes[i] = D2D1PixelShader.GetInputType(i); - } - - // Prepare the input descriptions - ReadOnlyMemory inputDescriptionsInfo = D2D1PixelShader.GetInputDescriptions(); - int inputDescriptionCount = inputDescriptionsInfo.Length; - D2D1InputDescription* inputDescriptions = (D2D1InputDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1InputDescription) * inputDescriptionCount); - - inputDescriptionsInfo.Span.CopyTo(new Span(inputDescriptions, inputDescriptionCount)); - - // Prepare the resource texture descriptions - ReadOnlyMemory resourceTextureDescriptionsInfo = D2D1PixelShader.GetResourceTextureDescriptions(); - int resourceTextureDescriptionCount = resourceTextureDescriptionsInfo.Length; - D2D1ResourceTextureDescription* resourceTextureDescriptions = (D2D1ResourceTextureDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1ResourceTextureDescription) * resourceTextureDescriptionCount); - - resourceTextureDescriptionsInfo.Span.CopyTo(new Span(resourceTextureDescriptions, resourceTextureDescriptionCount)); - - // Copy the bytecode to the target buffer - ReadOnlyMemory bytecodeInfo = D2D1PixelShader.LoadBytecode(); - int bytecodeSize = bytecodeInfo.Length; - byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), bytecodeSize); - - bytecodeInfo.Span.CopyTo(new Span(bytecode, bytecodeSize)); - - // Set the shared state and mark the type as initialized - For.shaderId = shaderId; - For.constantBufferSize = constantBufferSize; - For.inputCount = inputCount; - For.inputTypes = inputTypes; - For.inputDescriptionCount = inputDescriptionCount; - For.inputDescriptions = inputDescriptions; - For.pixelOptions = pixelOptions; - For.bytecode = bytecode; - For.bytecodeSize = bytecodeSize; - For.bufferPrecision = bufferPrecision; - For.channelDepth = channelDepth; - For.resourceTextureDescriptionCount = resourceTextureDescriptionCount; - For.resourceTextureDescriptions = resourceTextureDescriptions; - For.d2D1DrawTransformMapperFactory = d2D1DrawTransformMapperFactory; - - isInitialized = true; - } - } + this.effectFactory = effectFactory; + this.shaderId = shaderId; + this.constantBufferSize = constantBufferSize; + this.inputCount = inputCount; + this.inputTypes = inputTypes; + this.inputDescriptionCount = inputDescriptionCount; + this.inputDescriptions = inputDescriptions; + this.pixelOptions = pixelOptions; + this.bytecode = bytecode; + this.bytecodeSize = bytecodeSize; + this.bufferPrecision = bufferPrecision; + this.channelDepth = channelDepth; + this.resourceTextureDescriptionCount = resourceTextureDescriptionCount; + this.resourceTextureDescriptions = resourceTextureDescriptions; } /// - /// Gets a reference to the id of the effect. + /// Gets the shader instance. /// - public static ref Guid Id - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ref shaderId; - } + public static For Instance { get; } = CreateInstance(); /// - /// Gets the factory for the current effect. + /// Creates a new instance. /// -#if NET6_0_OR_GREATER - public static delegate* unmanaged[Stdcall] Factory -#else - public static void* Factory -#endif + /// The initialized instance. + private static For CreateInstance() { - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET6_0_OR_GREATER - get => (delegate* unmanaged[Stdcall])Marshal.GetFunctionPointerForDelegate(EffectFactory); -#else - get => (void*)Marshal.GetFunctionPointerForDelegate(EffectFactory); -#endif - } + // Load all shader properties + Guid shaderId = typeof(T).GUID; + int constantBufferSize = D2D1PixelShader.GetConstantBufferSize(); + D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision(); + D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth(); + D2D1PixelOptions pixelOptions = D2D1PixelShader.GetPixelOptions(); - /// - /// Gets the number of inputs for the effect. - /// - public static int InputCount => inputCount; + // Prepare the inputs info + int inputCount = D2D1PixelShader.GetInputCount(); + D2D1PixelShaderInputType* inputTypes = (D2D1PixelShaderInputType*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1PixelShaderInputType) * inputCount); - /// - /// Tries to get the effect id, if it has been initialized. - /// - /// The resulting effect id. - /// Whether or not the effect had been initialized. - public static bool TryGetId(out Guid id) - { - lock (typeof(For)) + for (int i = 0; i < inputCount; i++) { - if (isInitialized) - { - id = Id; - - return true; - } + inputTypes[i] = D2D1PixelShader.GetInputType(i); } - id = default; + // Prepare the input descriptions + ReadOnlyMemory inputDescriptionsInfo = D2D1PixelShader.GetInputDescriptions(); + int inputDescriptionCount = inputDescriptionsInfo.Length; + D2D1InputDescription* inputDescriptions = (D2D1InputDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1InputDescription) * inputDescriptionCount); - return false; - } + inputDescriptionsInfo.Span.CopyTo(new Span(inputDescriptions, inputDescriptionCount)); - /// - private static int CreateEffect(IUnknown** effectImpl) - { - D2D1TransformMapper? d2D1TransformMapper; + // Prepare the resource texture descriptions + ReadOnlyMemory resourceTextureDescriptionsInfo = D2D1PixelShader.GetResourceTextureDescriptions(); + int resourceTextureDescriptionCount = resourceTextureDescriptionsInfo.Length; + D2D1ResourceTextureDescription* resourceTextureDescriptions = (D2D1ResourceTextureDescription*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), sizeof(D2D1ResourceTextureDescription) * resourceTextureDescriptionCount); - // If there is a custom draw transform factory, run it in a try block and handle exceptions. This - // is needed because the factory will be running user code from a method that's invoked by COM, - // and managed exceptions should never cross the ABI boundary. If it throws, just return the HRESULT. - try - { - ID2D1TransformMapper? d2D1DrawTransformMapper = d2D1DrawTransformMapperFactory?.Create(); + resourceTextureDescriptionsInfo.Span.CopyTo(new Span(resourceTextureDescriptions, resourceTextureDescriptionCount)); - d2D1TransformMapper = D2D1TransformMapper.For.Get(d2D1DrawTransformMapper); - } - catch (Exception e) - { - *effectImpl = null; + // Copy the bytecode to the target buffer + ReadOnlyMemory bytecodeInfo = D2D1PixelShader.LoadBytecode(); + int bytecodeSize = bytecodeInfo.Length; + byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For), bytecodeSize); - return e.HResult; - } + bytecodeInfo.Span.CopyTo(new Span(bytecode, bytecodeSize)); - return PixelShaderEffect.Factory( + // Initialize the shared instance with the computed state + return new( + CreateEffect, shaderId, constantBufferSize, inputCount, @@ -287,8 +218,59 @@ internal unsafe partial struct PixelShaderEffect bufferPrecision, channelDepth, resourceTextureDescriptionCount, - resourceTextureDescriptions, - d2D1TransformMapper, + resourceTextureDescriptions); + } + + /// + /// Gets a reference to the id of the effect. + /// + public ref readonly Guid Id + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => ref this.shaderId; + } + + /// + /// Gets the factory for the current effect. + /// +#if NET6_0_OR_GREATER + public delegate* unmanaged[Stdcall] Factory +#else + public void* Factory +#endif + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] +#if NET6_0_OR_GREATER + get => (delegate* unmanaged[Stdcall])Marshal.GetFunctionPointerForDelegate(this.effectFactory); +#else + get => (void*)Marshal.GetFunctionPointerForDelegate(this.effectFactory); +#endif + } + + /// + /// Gets the number of inputs for the effect. + /// + public int InputCount => this.inputCount; + + /// + private static int CreateEffect(IUnknown** effectImpl) + { + For instance = Instance; + + return PixelShaderEffect.Factory( + instance.shaderId, + instance.constantBufferSize, + instance.inputCount, + instance.inputTypes, + instance.inputDescriptionCount, + instance.inputDescriptions, + instance.pixelOptions, + instance.bytecode, + instance.bytecodeSize, + instance.bufferPrecision, + instance.channelDepth, + instance.resourceTextureDescriptionCount, + instance.resourceTextureDescriptions, effectImpl); } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs index 8e0ef156..0347be41 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs @@ -1,5 +1,4 @@ using System; -using System.Drawing; using System.Runtime.InteropServices; using ComputeSharp.D2D1.Extensions; using ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers; @@ -138,31 +137,6 @@ partial struct PixelShaderEffect return hresult; } } - else if (@this->d2D1TransformMapperHandle.Target is D2D1TransformMapper d2D1TransformMapper) - { - Rectangle output = outputRect->ToRectangle(); - Span inputs = stackalloc Rectangle[8].Slice(0, (int)inputRectsCount); - - for (int i = 0; i < (int)inputRectsCount; i++) - { - inputs[i] = inputRects[i].ToRectangle(); - } - - // Invoke MapOutputToInputs and handle exceptions so they don't cross the ABI boundary - try - { - d2D1TransformMapper.MapOutputToInputs(in output, inputs); - } - catch (Exception e) - { - return e.HResult; - } - - for (int i = 0; i < (int)inputRectsCount; i++) - { - inputRects[i] = inputs[i].ToRECT(); - } - } else { // If no custom transform is used, apply the default mapping. In this case, the loop will @@ -233,35 +207,6 @@ partial struct PixelShaderEffect return hresult; } } - else if (@this->d2D1TransformMapperHandle.Target is D2D1TransformMapper d2D1TransformMapper) - { - Span inputs = stackalloc Rectangle[8].Slice(0, (int)inputRectCount); - Span opaqueInputs = stackalloc Rectangle[8].Slice(0, (int)inputRectCount); - - for (int i = 0; i < (int)inputRectCount; i++) - { - inputs[i] = inputRects[i].ToRectangle(); - opaqueInputs[i] = inputOpaqueSubRects[i].ToRectangle(); - } - - ReadOnlySpan buffer = new(@this->constantBuffer, @this->constantBufferSize); - - Rectangle output; - Rectangle opaqueOutput; - - // Handle exceptions, as mentioned above - try - { - d2D1TransformMapper.MapInputsToOutput(buffer, inputs, opaqueInputs, out output, out opaqueOutput); - } - catch (Exception e) - { - return e.HResult; - } - - *outputRect = output.ToRECT(); - *outputOpaqueSubRect = opaqueOutput.ToRECT(); - } else if (inputRectCount == 0) { // If there are no inputs, make the output rectangle infinite. This is useful @@ -332,23 +277,6 @@ partial struct PixelShaderEffect return hresult; } } - else if (@this->d2D1TransformMapperHandle.Target is D2D1TransformMapper d2D1TransformMapper) - { - Rectangle invalidInput = invalidInputRect.ToRectangle(); - Rectangle invalidOutput; - - // Handle exceptions once again - try - { - d2D1TransformMapper.MapInvalidOutput((int)inputIndex, invalidInput, out invalidOutput); - } - catch (Exception e) - { - return e.HResult; - } - - *invalidOutputRect = invalidOutput.ToRECT(); - } else { // The default mapping in this scenario just needs to set the invalid output rect for simple inputs to diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs index 5c05a70a..d38561c2 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs @@ -188,15 +188,9 @@ internal unsafe partial struct PixelShaderEffect /// private D2D1ResourceTextureDescription* resourceTextureDescriptions; - /// - /// The handle for the instance in use, if any. - /// - private GCHandle d2D1TransformMapperHandle; - /// /// The instance to use, if any. /// - /// If present, this takes precedence over . private ID2D1TransformMapper* d2D1TransformMapper; /// @@ -230,7 +224,6 @@ internal unsafe partial struct PixelShaderEffect /// The channel depth for the resulting output buffer. /// The number of available resource texture descriptions. /// The buffer with the available resource texture descriptions for the shader. - /// The instance to use for the effect. /// The resulting effect instance. /// This always returns 0. private static int Factory( @@ -247,7 +240,6 @@ internal unsafe partial struct PixelShaderEffect D2D1ChannelDepth channelDepth, int resourceTextureDescriptionCount, D2D1ResourceTextureDescription* resourceTextureDescriptions, - D2D1TransformMapper? d2D1TransformMapper, IUnknown** effectImpl) { PixelShaderEffect* @this; @@ -282,7 +274,6 @@ internal unsafe partial struct PixelShaderEffect @this->channelDepth = channelDepth; @this->resourceTextureDescriptionCount = resourceTextureDescriptionCount; @this->resourceTextureDescriptions = resourceTextureDescriptions; - @this->d2D1TransformMapperHandle = GCHandle.Alloc(d2D1TransformMapper); @this->d2D1TransformMapper = null; @this->d2D1DrawInfo = null; @this->d2D1EffectContext = null; @@ -347,8 +338,6 @@ internal unsafe partial struct PixelShaderEffect NativeMemory.Free(this.constantBuffer); } - this.d2D1TransformMapperHandle.Free(); - if (this.d2D1TransformMapper is not null) { _ = ((IUnknown*)this.d2D1TransformMapper)->Release();