diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ResourceTextureManagerBuffer.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ResourceTextureManagerBuffer.cs index 6d11ba20..cb5509a7 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ResourceTextureManagerBuffer.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ResourceTextureManagerBuffer.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; #pragma warning disable CS0649 @@ -109,15 +108,5 @@ partial struct PixelShaderEffect return ref @this[index]; } } - - /// - /// Gets a with the items in the current instance. - /// - /// A with the items in the current instance. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Span AsSpan() - { - return new((ID2D1ResourceTextureManager**)Unsafe.AsPointer(ref this), 16); - } } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs index 249f0544..b7f146d6 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs @@ -286,8 +286,7 @@ internal unsafe partial struct PixelShaderEffect @this->d2D1TransformMapperHandle = GCHandle.Alloc(d2D1TransformMapper); @this->d2D1DrawInfo = null; @this->d2D1EffectContext = null; - - @this->resourceTextureManagerBuffer.AsSpan().Clear(); + @this->resourceTextureManagerBuffer = default; *effectImpl = (IUnknown*)@this; diff --git a/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj b/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj index fc7d9be9..c6b0d625 100644 --- a/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj +++ b/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net472;netcoreapp3.1;net6.0 false $(NoWarn);CS0419;CA1416 diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs index fb6fb057..ee6a3673 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs @@ -588,7 +588,9 @@ public partial class D2D1ResourceTextureManagerTests data: texture, strides: null); - byte[] data = RandomNumberGenerator.GetBytes(updateLength); + byte[] data = new byte[updateLength]; + + RandomNumberGenerator.Create().GetBytes(data); resourceTextureManager.Update( minimumExtents: stackalloc uint[] { (uint)startOffset }, @@ -674,7 +676,9 @@ public partial class D2D1ResourceTextureManagerTests data: texture, strides: stackalloc uint[] { (uint)width }); - byte[] data = RandomNumberGenerator.GetBytes(updateLengthX * updateLengthY); + byte[] data = new byte[updateLengthX * updateLengthY]; + + RandomNumberGenerator.Create().GetBytes(data); resourceTextureManager.Update( minimumExtents: stackalloc uint[] { (uint)startOffsetX, (uint)startOffsetY }, @@ -775,7 +779,9 @@ public partial class D2D1ResourceTextureManagerTests data: texture, strides: stackalloc uint[] { (uint)width, (uint)(width * height) }); - byte[] data = RandomNumberGenerator.GetBytes(updateLengthX * updateLengthY * updateLengthZ); + byte[] data = new byte[updateLengthX * updateLengthY * updateLengthZ]; + + RandomNumberGenerator.Create().GetBytes(data); resourceTextureManager.Update( minimumExtents: stackalloc uint[] { (uint)startOffsetX, (uint)startOffsetY, (uint)startOffsetZ }, diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs index 0feb56b8..f2f0e6c5 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs @@ -27,8 +27,8 @@ public partial class D2D1ShaderCompilerTests """; ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile( - source, - "PSMain", + source.AsSpan(), + "PSMain".AsSpan(), D2D1ShaderProfile.PixelShader40Level93, D2D1CompileOptions.Default); @@ -79,8 +79,8 @@ public partial class D2D1ShaderCompilerTests """; ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile( - source, - "PSMain", + source.AsSpan(), + "PSMain".AsSpan(), D2D1ShaderProfile.PixelShader40Level93, D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking); @@ -106,8 +106,8 @@ public partial class D2D1ShaderCompilerTests """; ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile( - source, - "Execute", + source.AsSpan(), + "Execute".AsSpan(), D2D1ShaderProfile.PixelShader40Level93, D2D1CompileOptions.Default); @@ -133,8 +133,8 @@ public partial class D2D1ShaderCompilerTests """; ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile( - source, - "PSMain", + source.AsSpan(), + "PSMain".AsSpan(), D2D1ShaderProfile.PixelShader40Level93, D2D1CompileOptions.Default); @@ -181,8 +181,8 @@ public partial class D2D1ShaderCompilerTests """; ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile( - source, - "PSMain", + source.AsSpan(), + "PSMain".AsSpan(), D2D1ShaderProfile.PixelShader40, D2D1CompileOptions.Default); diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index 75534345..462281f4 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -325,9 +325,9 @@ public sealed partial class BokehBlurEffect using ComPtr compositeEffect = default; using ComPtr borderEffect = default; - Span> verticalConvolutionEffectsForReals = stackalloc ComPtr[numberOfComponents]; - Span> verticalConvolutionEffectsForImaginaries = stackalloc ComPtr[numberOfComponents]; - Span> horizontalConvolutionEffects = stackalloc ComPtr[numberOfComponents]; + Span> verticalConvolutionEffectsForReals = new ComPtr[numberOfComponents]; + Span> verticalConvolutionEffectsForImaginaries = new ComPtr[numberOfComponents]; + Span> horizontalConvolutionEffects = new ComPtr[numberOfComponents]; try { diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs index c60296ed..af460bfd 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs @@ -2,6 +2,13 @@ namespace ComputeSharp.D2D1.Tests.Effects; +#if !NETCOREAPP3_1_OR_GREATER +internal static class MathF +{ + public const float PI = (float)Math.PI; +} +#endif + [D2DInputCount(0)] [D2DRequiresScenePosition] [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] diff --git a/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs b/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs index a34085c7..e0fc8004 100644 --- a/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs +++ b/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs @@ -1,6 +1,8 @@ using System.ComponentModel; using System.Diagnostics; +#if NETCOREAPP3_1_OR_GREATER using System.Diagnostics.CodeAnalysis; +#endif using System.Runtime.CompilerServices; namespace ComputeSharp.D2D1.Tests.Extensions; @@ -46,7 +48,9 @@ internal static class HRESULTExtensions /// Throws a . /// /// The input return code. +#if NETCOREAPP3_1_OR_GREATER [DoesNotReturn] +#endif private static void ThrowWin32Exception(int result) { throw new Win32Exception(result);