From c72b0c7fd2d820102633d853e7ba31406a176c2d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 8 Jan 2022 16:34:48 +0100 Subject: [PATCH] Remove System.Numerics types from pixel format conversions --- .../HlslBokehBlurProcessor{TPixel}.cs | 40 +++---- .../HlslGaussianBlurProcessor{TPixel}.cs | 20 ++-- src/ComputeSharp/Core/Imaging/Bgra32.cs | 3 +- src/ComputeSharp/Core/Imaging/Rg16.cs | 3 +- src/ComputeSharp/Core/Imaging/Rg32.cs | 3 +- src/ComputeSharp/Core/Imaging/Rgba32.cs | 3 +- src/ComputeSharp/Core/Imaging/Rgba64.cs | 3 +- .../Texture2DTests.Pixels.cs | 8 +- .../Texture2DTests.Pixels.g.cs | 101 ------------------ .../Texture2DTests.Pixels.tt | 11 +- .../Texture3DTests.Pixels.cs | 8 +- .../Texture3DTests.Pixels.g.cs | 101 ------------------ .../Texture3DTests.Pixels.tt | 11 +- 13 files changed, 47 insertions(+), 268 deletions(-) diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index 25c159d1..e8d3318b 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -270,10 +270,10 @@ public sealed partial class HlslBokehBlurProcessor Span span = MemoryMarshal.Cast(pixelSpan); - using ReadWriteTexture2D texture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); - using ReadWriteTexture2D temporary = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear); - using ReadWriteTexture2D reals = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); - using ReadWriteTexture2D imaginaries = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); + using ReadWriteTexture2D texture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); + using ReadWriteTexture2D temporary = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear); + using ReadWriteTexture2D reals = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); + using ReadWriteTexture2D imaginaries = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); using ReadOnlyBuffer kernel = GraphicsDevice.AllocateReadOnlyBuffer(KernelSize); // Preliminary gamma highlight pass @@ -315,16 +315,16 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal partial struct VerticalConvolutionProcessor : IComputeShader { - public IReadWriteTexture2D source; - public ReadWriteTexture2D reals; - public ReadWriteTexture2D imaginaries; + public IReadWriteTexture2D source; + public ReadWriteTexture2D reals; + public ReadWriteTexture2D imaginaries; public ReadOnlyBuffer kernel; /// public void Execute() { - Vector4 real = Vector4.Zero; - Vector4 imaginary = Vector4.Zero; + float4 real = float4.Zero; + float4 imaginary = float4.Zero; int maxY = source.Height; int maxX = source.Width; int kernelLength = kernel.Length; @@ -334,7 +334,7 @@ public sealed partial class HlslBokehBlurProcessor { int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY); int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX); - Vector4 color = source[offsetX, offsetY]; + float4 color = source[offsetX, offsetY]; Complex64 factors = kernel[i]; real += factors.Real * color; @@ -355,16 +355,16 @@ public sealed partial class HlslBokehBlurProcessor public float z; public float w; - public ReadWriteTexture2D reals; - public ReadWriteTexture2D imaginaries; - public ReadWriteTexture2D target; + public ReadWriteTexture2D reals; + public ReadWriteTexture2D imaginaries; + public ReadWriteTexture2D target; public ReadOnlyBuffer kernel; /// public void Execute() { - Vector4 real = Vector4.Zero; - Vector4 imaginary = Vector4.Zero; + float4 real = float4.Zero; + float4 imaginary = float4.Zero; int maxY = target.Height; int maxX = target.Width; int kernelLength = kernel.Length; @@ -374,8 +374,8 @@ public sealed partial class HlslBokehBlurProcessor for (int i = 0; i < kernelLength; i++) { int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX); - Vector4 sourceReal = reals[offsetX, offsetY]; - Vector4 sourceImaginary = imaginaries[offsetX, offsetY]; + float4 sourceReal = reals[offsetX, offsetY]; + float4 sourceImaginary = imaginaries[offsetX, offsetY]; Complex64 factors = kernel[i]; real += factors.Real * sourceReal - factors.Imaginary * sourceImaginary; @@ -392,7 +392,7 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal readonly partial struct GammaHighlightProcessor : IComputeShader { - public readonly IReadWriteTexture2D source; + public readonly IReadWriteTexture2D source; /// public void Execute() @@ -416,8 +416,8 @@ public sealed partial class HlslBokehBlurProcessor [AutoConstructor] internal readonly partial struct InverseGammaHighlightProcessor : IComputeShader { - public readonly ReadWriteTexture2D source; - public readonly IReadWriteTexture2D target; + public readonly ReadWriteTexture2D source; + public readonly IReadWriteTexture2D target; /// public void Execute() diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs index c993f9d2..0079ac2f 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs @@ -101,8 +101,8 @@ public sealed partial class HlslGaussianBlurProcessor Span span = MemoryMarshal.Cast(pixelSpan); - using ReadWriteTexture2D sourceTexture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); - using ReadWriteTexture2D firstPassTexture = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); + using ReadWriteTexture2D sourceTexture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height); + using ReadWriteTexture2D firstPassTexture = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); using ReadOnlyBuffer kernelBuffer = GraphicsDevice.AllocateReadOnlyBuffer(Kernel); using (var context = GraphicsDevice.CreateComputeContext()) @@ -121,14 +121,14 @@ public sealed partial class HlslGaussianBlurProcessor [AutoConstructor] internal readonly partial struct VerticalConvolutionProcessor : IComputeShader { - public readonly IReadWriteTexture2D source; - public readonly IReadWriteTexture2D target; + public readonly IReadWriteTexture2D source; + public readonly IReadWriteTexture2D target; public readonly ReadOnlyBuffer kernel; /// public void Execute() { - Vector4 result = Vector4.Zero; + float4 result = float4.Zero; int maxY = source.Height - 1; int maxX = source.Width - 1; int kernelLength = kernel.Length; @@ -138,7 +138,7 @@ public sealed partial class HlslGaussianBlurProcessor { int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY); int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX); - Vector4 color = source[offsetX, offsetY]; + float4 color = source[offsetX, offsetY]; result += kernel[i] * color; } @@ -153,14 +153,14 @@ public sealed partial class HlslGaussianBlurProcessor [AutoConstructor] internal readonly partial struct HorizontalConvolutionProcessor : IComputeShader { - public readonly IReadWriteTexture2D source; - public readonly IReadWriteTexture2D target; + public readonly IReadWriteTexture2D source; + public readonly IReadWriteTexture2D target; public readonly ReadOnlyBuffer kernel; /// public void Execute() { - Vector4 result = Vector4.Zero; + float4 result = float4.Zero; int maxY = source.Height - 1; int maxX = source.Width - 1; int kernelLength = kernel.Length; @@ -170,7 +170,7 @@ public sealed partial class HlslGaussianBlurProcessor for (int i = 0; i < kernelLength; i++) { int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX); - Vector4 color = source[offsetX, offsetY]; + float4 color = source[offsetX, offsetY]; result += kernel[i] * color; } diff --git a/src/ComputeSharp/Core/Imaging/Bgra32.cs b/src/ComputeSharp/Core/Imaging/Bgra32.cs index 27ed1544..4a06092b 100644 --- a/src/ComputeSharp/Core/Imaging/Bgra32.cs +++ b/src/ComputeSharp/Core/Imaging/Bgra32.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -15,7 +14,7 @@ namespace ComputeSharp; /// /// This struct is fully mutable. [StructLayout(LayoutKind.Sequential)] -public struct Bgra32 : IEquatable, IPixel, IPixel +public struct Bgra32 : IEquatable, IPixel #if NET6_0_OR_GREATER , ISpanFormattable #endif diff --git a/src/ComputeSharp/Core/Imaging/Rg16.cs b/src/ComputeSharp/Core/Imaging/Rg16.cs index c6aab570..0f1e9fc0 100644 --- a/src/ComputeSharp/Core/Imaging/Rg16.cs +++ b/src/ComputeSharp/Core/Imaging/Rg16.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -12,7 +11,7 @@ namespace ComputeSharp; /// /// [StructLayout(LayoutKind.Sequential)] -public struct Rg16 : IEquatable, IPixel, IPixel +public struct Rg16 : IEquatable, IPixel #if NET6_0_OR_GREATER , ISpanFormattable #endif diff --git a/src/ComputeSharp/Core/Imaging/Rg32.cs b/src/ComputeSharp/Core/Imaging/Rg32.cs index dda953ce..f8fc621d 100644 --- a/src/ComputeSharp/Core/Imaging/Rg32.cs +++ b/src/ComputeSharp/Core/Imaging/Rg32.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -12,7 +11,7 @@ namespace ComputeSharp; /// /// [StructLayout(LayoutKind.Sequential)] -public struct Rg32 : IEquatable, IPixel, IPixel +public struct Rg32 : IEquatable, IPixel #if NET6_0_OR_GREATER , ISpanFormattable #endif diff --git a/src/ComputeSharp/Core/Imaging/Rgba32.cs b/src/ComputeSharp/Core/Imaging/Rgba32.cs index 5cc7cd9c..4a54a90c 100644 --- a/src/ComputeSharp/Core/Imaging/Rgba32.cs +++ b/src/ComputeSharp/Core/Imaging/Rgba32.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -14,7 +13,7 @@ namespace ComputeSharp; /// /// This struct is fully mutable. [StructLayout(LayoutKind.Sequential)] -public struct Rgba32 : IEquatable, IPixel, IPixel +public struct Rgba32 : IEquatable, IPixel #if NET6_0_OR_GREATER , ISpanFormattable #endif diff --git a/src/ComputeSharp/Core/Imaging/Rgba64.cs b/src/ComputeSharp/Core/Imaging/Rgba64.cs index 6652717b..6655f2b4 100644 --- a/src/ComputeSharp/Core/Imaging/Rgba64.cs +++ b/src/ComputeSharp/Core/Imaging/Rgba64.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -14,7 +13,7 @@ namespace ComputeSharp; /// /// This struct is fully mutable. [StructLayout(LayoutKind.Sequential)] -public struct Rgba64 : IEquatable, IPixel, IPixel +public struct Rgba64 : IEquatable, IPixel #if NET6_0_OR_GREATER , ISpanFormattable #endif diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs index 63a8943f..e7c7624c 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Numerics; using System.Reflection; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; @@ -17,17 +16,12 @@ public partial class Texture2DTests [AllDevices] [Resource(typeof(ReadOnlyTexture2D<,>))] [Resource(typeof(ReadWriteTexture2D<,>))] - [Data(typeof(Bgra32), typeof(Vector4))] [Data(typeof(Bgra32), typeof(float4))] [Data(typeof(R16), typeof(float))] [Data(typeof(R8), typeof(float))] - [Data(typeof(Rg16), typeof(Vector2))] [Data(typeof(Rg16), typeof(float2))] - [Data(typeof(Rg32), typeof(Vector2))] [Data(typeof(Rg32), typeof(float2))] - [Data(typeof(Rgba32), typeof(Vector4))] [Data(typeof(Rgba32), typeof(float4))] - [Data(typeof(Rgba64), typeof(Vector4))] [Data(typeof(Rgba64), typeof(float4))] public void Allocate_Uninitialized_Pixel_Ok(Device device, Type textureType, Type t, Type tPixel) { @@ -54,7 +48,7 @@ public partial class Texture2DTests try { - new Action(Test).Method.GetGenericMethodDefinition().MakeGenericMethod(t, tPixel).Invoke(null, new object[] { device, textureType }); + new Action(Test).Method.GetGenericMethodDefinition().MakeGenericMethod(t, tPixel).Invoke(null, new object[] { device, textureType }); } catch (TargetInvocationException e) when (e.InnerException is not null) { diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.g.cs b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.g.cs index b7ca519a..a32e6235 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.g.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.g.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; @@ -9,27 +8,15 @@ public partial class Texture2DTests { [CombinatorialTestMethod] [AllDevices] - [Data(typeof(Bgra32), typeof(Vector4))] [Data(typeof(Bgra32), typeof(Float4))] [Data(typeof(R16), typeof(float))] [Data(typeof(R8), typeof(float))] - [Data(typeof(Rg16), typeof(Vector2))] [Data(typeof(Rg16), typeof(Float2))] - [Data(typeof(Rg32), typeof(Vector2))] [Data(typeof(Rg32), typeof(Float2))] - [Data(typeof(Rgba32), typeof(Vector4))] [Data(typeof(Rgba32), typeof(Float4))] - [Data(typeof(Rgba64), typeof(Vector4))] [Data(typeof(Rgba64), typeof(Float4))] public void Dispatch_NormalizedTexture2D(Device device, Type t, Type tPixel) { - if (t == typeof(Bgra32) && tPixel == typeof(Vector4)) - { - using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); - using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(128, 128); - - device.Get().For(128, 128, new Shader_Unorm_Bgra32_Vector4(source, destination)); - } if (t == typeof(Bgra32) && tPixel == typeof(Float4)) { using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); @@ -51,13 +38,6 @@ public partial class Texture2DTests device.Get().For(128, 128, new Shader_Unorm_R8_float(source, destination)); } - if (t == typeof(Rg16) && tPixel == typeof(Vector2)) - { - using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); - using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(128, 128); - - device.Get().For(128, 128, new Shader_Unorm_Rg16_Vector2(source, destination)); - } if (t == typeof(Rg16) && tPixel == typeof(Float2)) { using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); @@ -65,13 +45,6 @@ public partial class Texture2DTests device.Get().For(128, 128, new Shader_Unorm_Rg16_Float2(source, destination)); } - if (t == typeof(Rg32) && tPixel == typeof(Vector2)) - { - using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); - using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(128, 128); - - device.Get().For(128, 128, new Shader_Unorm_Rg32_Vector2(source, destination)); - } if (t == typeof(Rg32) && tPixel == typeof(Float2)) { using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); @@ -79,13 +52,6 @@ public partial class Texture2DTests device.Get().For(128, 128, new Shader_Unorm_Rg32_Float2(source, destination)); } - if (t == typeof(Rgba32) && tPixel == typeof(Vector4)) - { - using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); - using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(128, 128); - - device.Get().For(128, 128, new Shader_Unorm_Rgba32_Vector4(source, destination)); - } if (t == typeof(Rgba32) && tPixel == typeof(Float4)) { using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); @@ -93,13 +59,6 @@ public partial class Texture2DTests device.Get().For(128, 128, new Shader_Unorm_Rgba32_Float4(source, destination)); } - if (t == typeof(Rgba64) && tPixel == typeof(Vector4)) - { - using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); - using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(128, 128); - - device.Get().For(128, 128, new Shader_Unorm_Rgba64_Vector4(source, destination)); - } if (t == typeof(Rgba64) && tPixel == typeof(Float4)) { using ReadOnlyTexture2D source = device.Get().AllocateReadOnlyTexture2D(128, 128); @@ -109,18 +68,6 @@ public partial class Texture2DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Bgra32_Vector4 : IComputeShader - { - public readonly ReadOnlyTexture2D source; - public readonly ReadWriteTexture2D destination; - - public void Execute() - { - destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Bgra32_Float4 : IComputeShader { @@ -157,18 +104,6 @@ public partial class Texture2DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rg16_Vector2 : IComputeShader - { - public readonly ReadOnlyTexture2D source; - public readonly ReadWriteTexture2D destination; - - public void Execute() - { - destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rg16_Float2 : IComputeShader { @@ -181,18 +116,6 @@ public partial class Texture2DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rg32_Vector2 : IComputeShader - { - public readonly ReadOnlyTexture2D source; - public readonly ReadWriteTexture2D destination; - - public void Execute() - { - destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rg32_Float2 : IComputeShader { @@ -205,18 +128,6 @@ public partial class Texture2DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rgba32_Vector4 : IComputeShader - { - public readonly ReadOnlyTexture2D source; - public readonly ReadWriteTexture2D destination; - - public void Execute() - { - destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rgba32_Float4 : IComputeShader { @@ -229,18 +140,6 @@ public partial class Texture2DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rgba64_Vector4 : IComputeShader - { - public readonly ReadOnlyTexture2D source; - public readonly ReadWriteTexture2D destination; - - public void Execute() - { - destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rgba64_Float4 : IComputeShader { diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt index f62aa010..43d11ee2 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt @@ -7,13 +7,13 @@ <# var typesMap = new Dictionary { - ["Bgra32"] = new[] { "Vector4", "Float4" }, + ["Bgra32"] = new[] { "Float4" }, ["R16"] = new[] { "float" }, ["R8"] = new[] { "float" }, - ["Rg16"] = new[] { "Vector2", "Float2" }, - ["Rg32"] = new[] { "Vector2", "Float2" }, - ["Rgba32"] = new[] { "Vector4", "Float4" }, - ["Rgba64"] = new[] { "Vector4", "Float4" } + ["Rg16"] = new[] { "Float2" }, + ["Rg32"] = new[] { "Float2" }, + ["Rgba32"] = new[] { "Float4" }, + ["Rgba64"] = new[] { "Float4" } }; IEnumerable<(string T, string TPixel)> EnumerateTypes() @@ -24,7 +24,6 @@ IEnumerable<(string T, string TPixel)> EnumerateTypes() } #> using System; -using System.Numerics; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs index 0441ae8e..ec8f9a64 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using System.Reflection; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; @@ -14,17 +13,12 @@ public partial class Texture3DTests [AllDevices] [Resource(typeof(ReadOnlyTexture3D<,>))] [Resource(typeof(ReadWriteTexture3D<,>))] - [Data(typeof(Bgra32), typeof(Vector4))] [Data(typeof(Bgra32), typeof(float4))] [Data(typeof(R16), typeof(float))] [Data(typeof(R8), typeof(float))] - [Data(typeof(Rg16), typeof(Vector2))] [Data(typeof(Rg16), typeof(float2))] - [Data(typeof(Rg32), typeof(Vector2))] [Data(typeof(Rg32), typeof(float2))] - [Data(typeof(Rgba32), typeof(Vector4))] [Data(typeof(Rgba32), typeof(float4))] - [Data(typeof(Rgba64), typeof(Vector4))] [Data(typeof(Rgba64), typeof(float4))] public void Allocate_Uninitialized_Pixel_Ok(Device device, Type textureType, Type t, Type tPixel) { @@ -52,7 +46,7 @@ public partial class Texture3DTests try { - new Action(Test).Method.GetGenericMethodDefinition().MakeGenericMethod(t, tPixel).Invoke(null, new object[] { device, textureType }); + new Action(Test).Method.GetGenericMethodDefinition().MakeGenericMethod(t, tPixel).Invoke(null, new object[] { device, textureType }); } catch (TargetInvocationException e) when (e.InnerException is not null) { diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.g.cs b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.g.cs index 23a9d4c5..9debe150 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.g.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.g.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; @@ -9,27 +8,15 @@ public partial class Texture3DTests { [CombinatorialTestMethod] [AllDevices] - [Data(typeof(Bgra32), typeof(Vector4))] [Data(typeof(Bgra32), typeof(Float4))] [Data(typeof(R16), typeof(float))] [Data(typeof(R8), typeof(float))] - [Data(typeof(Rg16), typeof(Vector2))] [Data(typeof(Rg16), typeof(Float2))] - [Data(typeof(Rg32), typeof(Vector2))] [Data(typeof(Rg32), typeof(Float2))] - [Data(typeof(Rgba32), typeof(Vector4))] [Data(typeof(Rgba32), typeof(Float4))] - [Data(typeof(Rgba64), typeof(Vector4))] [Data(typeof(Rgba64), typeof(Float4))] public void Dispatch_NormalizedTexture3D(Device device, Type t, Type tPixel) { - if (t == typeof(Bgra32) && tPixel == typeof(Vector4)) - { - using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); - using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(128, 128, 2); - - device.Get().For(128, 128, 2, new Shader_Unorm_Bgra32_Vector4(source, destination)); - } if (t == typeof(Bgra32) && tPixel == typeof(Float4)) { using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); @@ -51,13 +38,6 @@ public partial class Texture3DTests device.Get().For(128, 128, 2, new Shader_Unorm_R8_float(source, destination)); } - if (t == typeof(Rg16) && tPixel == typeof(Vector2)) - { - using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); - using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(128, 128, 2); - - device.Get().For(128, 128, 2, new Shader_Unorm_Rg16_Vector2(source, destination)); - } if (t == typeof(Rg16) && tPixel == typeof(Float2)) { using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); @@ -65,13 +45,6 @@ public partial class Texture3DTests device.Get().For(128, 128, 2, new Shader_Unorm_Rg16_Float2(source, destination)); } - if (t == typeof(Rg32) && tPixel == typeof(Vector2)) - { - using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); - using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(128, 128, 2); - - device.Get().For(128, 128, 2, new Shader_Unorm_Rg32_Vector2(source, destination)); - } if (t == typeof(Rg32) && tPixel == typeof(Float2)) { using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); @@ -79,13 +52,6 @@ public partial class Texture3DTests device.Get().For(128, 128, 2, new Shader_Unorm_Rg32_Float2(source, destination)); } - if (t == typeof(Rgba32) && tPixel == typeof(Vector4)) - { - using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); - using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(128, 128, 2); - - device.Get().For(128, 128, 2, new Shader_Unorm_Rgba32_Vector4(source, destination)); - } if (t == typeof(Rgba32) && tPixel == typeof(Float4)) { using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); @@ -93,13 +59,6 @@ public partial class Texture3DTests device.Get().For(128, 128, 2, new Shader_Unorm_Rgba32_Float4(source, destination)); } - if (t == typeof(Rgba64) && tPixel == typeof(Vector4)) - { - using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); - using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(128, 128, 2); - - device.Get().For(128, 128, 2, new Shader_Unorm_Rgba64_Vector4(source, destination)); - } if (t == typeof(Rgba64) && tPixel == typeof(Float4)) { using ReadOnlyTexture3D source = device.Get().AllocateReadOnlyTexture3D(128, 128, 2); @@ -109,18 +68,6 @@ public partial class Texture3DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Bgra32_Vector4 : IComputeShader - { - public readonly ReadOnlyTexture3D source; - public readonly ReadWriteTexture3D destination; - - public void Execute() - { - destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Bgra32_Float4 : IComputeShader { @@ -157,18 +104,6 @@ public partial class Texture3DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rg16_Vector2 : IComputeShader - { - public readonly ReadOnlyTexture3D source; - public readonly ReadWriteTexture3D destination; - - public void Execute() - { - destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rg16_Float2 : IComputeShader { @@ -181,18 +116,6 @@ public partial class Texture3DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rg32_Vector2 : IComputeShader - { - public readonly ReadOnlyTexture3D source; - public readonly ReadWriteTexture3D destination; - - public void Execute() - { - destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rg32_Float2 : IComputeShader { @@ -205,18 +128,6 @@ public partial class Texture3DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rgba32_Vector4 : IComputeShader - { - public readonly ReadOnlyTexture3D source; - public readonly ReadWriteTexture3D destination; - - public void Execute() - { - destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rgba32_Float4 : IComputeShader { @@ -229,18 +140,6 @@ public partial class Texture3DTests } } - [AutoConstructor] - internal readonly partial struct Shader_Unorm_Rgba64_Vector4 : IComputeShader - { - public readonly ReadOnlyTexture3D source; - public readonly ReadWriteTexture3D destination; - - public void Execute() - { - destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; - } - } - [AutoConstructor] internal readonly partial struct Shader_Unorm_Rgba64_Float4 : IComputeShader { diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt index b1fdbeed..e83e615a 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt @@ -7,13 +7,13 @@ <# var typesMap = new Dictionary { - ["Bgra32"] = new[] { "Vector4", "Float4" }, + ["Bgra32"] = new[] { "Float4" }, ["R16"] = new[] { "float" }, ["R8"] = new[] { "float" }, - ["Rg16"] = new[] { "Vector2", "Float2" }, - ["Rg32"] = new[] { "Vector2", "Float2" }, - ["Rgba32"] = new[] { "Vector4", "Float4" }, - ["Rgba64"] = new[] { "Vector4", "Float4" } + ["Rg16"] = new[] { "Float2" }, + ["Rg32"] = new[] { "Float2" }, + ["Rgba32"] = new[] { "Float4" }, + ["Rgba64"] = new[] { "Float4" } }; IEnumerable<(string T, string TPixel)> EnumerateTypes() @@ -24,7 +24,6 @@ IEnumerable<(string T, string TPixel)> EnumerateTypes() } #> using System; -using System.Numerics; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions;