From 7761d0bbd8eba349fb0f11ca31e04fcd2fe670e7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 30 Nov 2022 03:10:24 +0100 Subject: [PATCH] Improve consistency in interop API parameters ordering --- .../PixelShaderEffect{T}.ICanvasImageInterop.cs | 2 +- .../PixelShaderEffect{T}.Properties.Interop.cs | 2 +- .../Shaders/Interop/D2D1PixelShader.cs | 4 ++-- .../Shaders/Interop/D2D1PixelShaderEffect.cs | 4 ++-- .../D2D1PixelShaderEffectTests.cs | 2 +- .../D2D1PixelShaderTests.cs | 2 +- .../D2D1ResourceTextureManagerTests.cs | 16 ++++++++-------- .../D2D1TransformMapperTests.cs | 2 +- .../Effects/BokehBlurEffect.cs | 6 +++--- .../Helpers/D2D1TestRunner.cs | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs index a8c2afce..210da512 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs @@ -223,7 +223,7 @@ unsafe partial class PixelShaderEffect } // Set the constant buffer for the effect - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(this.value, this.d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(this.d2D1Effect.Get(), in this.value); // If there is a transform mapper, set it in the effect if (this.transformMapper is not null) diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs index b011115e..eb9d81d0 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Interop.cs @@ -40,7 +40,7 @@ unsafe partial class PixelShaderEffect // If the effect is realized, set the property on the underlying ID2D1Effect object if (this.d2D1Effect.Get() is not null) { - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in value, this.d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(this.d2D1Effect.Get(), in value); } else { diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs index 4203a859..e49184e8 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs @@ -426,11 +426,11 @@ public static class D2D1PixelShader /// Sets the constant buffer from an input D2D1 pixel shader, by calling ID2D1DrawInfo::SetPixelShaderConstantBuffer. /// /// The type of D2D1 pixel shader to set the constant buffer for. - /// The input D2D1 pixel shader to set the contant buffer for. /// A pointer to the ID2D1DrawInfo instance to use. + /// The input D2D1 pixel shader to set the contant buffer for. /// Thrown if is . /// For more info, see . - public static unsafe void SetConstantBufferForD2D1DrawInfo(in T shader, void* d2D1DrawInfo) + public static unsafe void SetConstantBufferForD2D1DrawInfo(void* d2D1DrawInfo, in T shader) where T : unmanaged, ID2D1PixelShader { if (d2D1DrawInfo is null) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index b0b63c86..3ce44ca3 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -497,11 +497,11 @@ public static unsafe class D2D1PixelShaderEffect /// Sets the constant buffer from an input D2D1 effect, by calling ID2D1Effect::SetValue. /// /// The type of D2D1 pixel shader to set the constant buffer for. - /// The input D2D1 pixel shader to set the contant buffer for. /// A pointer to the ID2D1Effect instance to use. + /// The input D2D1 pixel shader to set the contant buffer for. /// Thrown if is . /// For more info, see . - public static void SetConstantBufferForD2D1Effect(in T shader, void* d2D1Effect) + public static void SetConstantBufferForD2D1Effect(void* d2D1Effect, in T shader) where T : unmanaged, ID2D1PixelShader { if (d2D1Effect is null) diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs index f6782eba..ac7a715f 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs @@ -47,7 +47,7 @@ public partial class D2D1PixelShaderEffectTests [ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)] public unsafe void SetConstantBufferForD2D1Effect_NullD2D1Effect() { - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(default, null); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(null, default); } [TestMethod] diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs index 6c264798..abbee5eb 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs @@ -630,6 +630,6 @@ public partial class D2D1PixelShaderTests [ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)] public unsafe void SetConstantBufferForD2D1DrawInfo_NullD2D1DrawInfo() { - D2D1PixelShader.SetConstantBufferForD2D1DrawInfo(default, null); + D2D1PixelShader.SetConstantBufferForD2D1DrawInfo(null, default); } } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs index 61dd5d58..47f3c49b 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs @@ -198,7 +198,7 @@ public partial class D2D1ResourceTextureManagerTests D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(default(IndexFrom2DResourceTextureShader), d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), default(IndexFrom2DResourceTextureShader)); using ComPtr resourceTextureManager = default; @@ -257,7 +257,7 @@ public partial class D2D1ResourceTextureManagerTests D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(default(IndexFrom2DResourceTextureShader), d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), default(IndexFrom2DResourceTextureShader)); using ComPtr resourceTextureManager = default; @@ -321,7 +321,7 @@ public partial class D2D1ResourceTextureManagerTests D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(default(IndexFrom2DResourceTextureShader), d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), default(IndexFrom2DResourceTextureShader)); string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; string expectedPath = Path.Combine(assemblyPath, "Assets", "Landscape.png"); @@ -498,7 +498,7 @@ public partial class D2D1ResourceTextureManagerTests IndexFrom3DResourceTextureShader shader = new(expected.Height / 4); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in shader, d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), in shader); using ComPtr resourceTextureManager = default; @@ -575,7 +575,7 @@ public partial class D2D1ResourceTextureManagerTests CopyFromResourceTexture1DShader shader = new(width); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in shader, d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), in shader); byte[] texture = new byte[width]; @@ -663,7 +663,7 @@ public partial class D2D1ResourceTextureManagerTests CopyFromResourceTexture2DShader shader = new(width, height); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in shader, d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), in shader); byte[] texture = new byte[width * height]; @@ -766,7 +766,7 @@ public partial class D2D1ResourceTextureManagerTests CopyFromResourceTexture3DShader shader = new(width, height, depth); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in shader, d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), in shader); byte[] texture = new byte[width * height * depth]; @@ -860,7 +860,7 @@ public partial class D2D1ResourceTextureManagerTests D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(default(NullResourceTextureShader), d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), default(NullResourceTextureShader)); using ComPtr d2D1BitmapTarget = D2D1Helper.CreateD2D1BitmapAndSetAsTarget(d2D1DeviceContext.Get(), 128, 128); diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1TransformMapperTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1TransformMapperTests.cs index ee0e42a4..b7be7722 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1TransformMapperTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1TransformMapperTests.cs @@ -158,7 +158,7 @@ public partial class D2D1TransformMapperTests D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(new ShaderWithDispatchArea(111, 222), d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), new ShaderWithDispatchArea(111, 222)); DispatchAreaTransformMapper transformMapper = new() { ExpectedWidth = 111, ExpectedHeight = 222 }; diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index c3b1d893..9fcd8452 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -425,9 +425,9 @@ public sealed partial class BokehBlurEffect // Set the constant buffers for (int i = 0; i < numberOfComponents; i++) { - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(new VerticalConvolution.Shader((int)kernelSize), verticalConvolutionEffectsForReals[i].Get()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(new VerticalConvolution.Shader((int)kernelSize), verticalConvolutionEffectsForImaginaries[i].Get()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(new HorizontalConvolutionAndAccumulatePartials.Shader((int)kernelSize, this.kernelParameters[i].Z, this.kernelParameters[i].W), horizontalConvolutionEffects[i].Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(verticalConvolutionEffectsForReals[i].Get(), new VerticalConvolution.Shader((int)kernelSize)); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(verticalConvolutionEffectsForImaginaries[i].Get(), new VerticalConvolution.Shader((int)kernelSize)); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(horizontalConvolutionEffects[i].Get(), new HorizontalConvolutionAndAccumulatePartials.Shader((int)kernelSize, this.kernelParameters[i].Z, this.kernelParameters[i].W)); } // Build the effect graph: diff --git a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs index df176f89..2e7de96e 100644 --- a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs +++ b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs @@ -124,7 +124,7 @@ internal static class D2D1TestRunner D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in shader, d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), in shader); if (transformMapper is not null) { @@ -173,7 +173,7 @@ internal static class D2D1TestRunner D2D1PixelShaderEffect.CreateFromD2D1DeviceContext(d2D1DeviceContext.Get(), (void**)d2D1Effect.GetAddressOf()); - D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(in shader, d2D1Effect.Get()); + D2D1PixelShaderEffect.SetConstantBufferForD2D1Effect(d2D1Effect.Get(), in shader); if (transformMapper is not null) {