From 6fe06ea4b2b8be4d4038d79840e215448e8f3893 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 5 Sep 2021 14:41:26 +0200 Subject: [PATCH] Updated pixel tests T4 templates to file scoped using directives --- .../Texture2DTests.Pixels.tt | 79 +++++++++---------- .../Texture3DTests.Pixels.tt | 79 +++++++++---------- 2 files changed, 78 insertions(+), 80 deletions(-) diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt index e0de4242..f62aa010 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.tt @@ -28,56 +28,55 @@ using System.Numerics; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; -namespace ComputeSharp.Tests +namespace ComputeSharp.Tests; + +public partial class Texture2DTests { - public partial class Texture2DTests + [CombinatorialTestMethod] + [AllDevices] +<# +foreach (var (t, tPixel) in EnumerateTypes()) +{ +#> + [Data(typeof(<#=t#>), typeof(<#=tPixel#>))] +<# +} +#> + public void Dispatch_NormalizedTexture2D(Device device, Type t, Type tPixel) { - [CombinatorialTestMethod] - [AllDevices] <# foreach (var (t, tPixel) in EnumerateTypes()) { #> - [Data(typeof(<#=t#>), typeof(<#=tPixel#>))] -<# -} -#> - public void Dispatch_NormalizedTexture2D(Device device, Type t, Type tPixel) + if (t == typeof(<#=t#>) && tPixel == typeof(<#=tPixel#>)) { -<# -foreach (var (t, tPixel) in EnumerateTypes()) -{ -#> - if (t == typeof(<#=t#>) && tPixel == typeof(<#=tPixel#>)) - { - using ReadOnlyTexture2D<<#=t#>, <#=tPixel#>> source = device.Get().AllocateReadOnlyTexture2D<<#=t#>, <#=tPixel#>>(128, 128); - using ReadWriteTexture2D<<#=t#>, <#=tPixel#>> destination = device.Get().AllocateReadWriteTexture2D<<#=t#>, <#=tPixel#>>(128, 128); + using ReadOnlyTexture2D<<#=t#>, <#=tPixel#>> source = device.Get().AllocateReadOnlyTexture2D<<#=t#>, <#=tPixel#>>(128, 128); + using ReadWriteTexture2D<<#=t#>, <#=tPixel#>> destination = device.Get().AllocateReadWriteTexture2D<<#=t#>, <#=tPixel#>>(128, 128); - device.Get().For(128, 128, new Shader_Unorm_<#=t#>_<#=tPixel#>(source, destination)); - } -<# -} -#> - } -<# - -foreach (var (t, tPixel) in EnumerateTypes()) -{ -#> - - [AutoConstructor] - internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader - { - public readonly ReadOnlyTexture2D<<#=t#>, <#=tPixel#>> source; - public readonly ReadWriteTexture2D<<#=t#>, <#=tPixel#>> destination; - - public void Execute() - { - destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; - } + device.Get().For(128, 128, new Shader_Unorm_<#=t#>_<#=tPixel#>(source, destination)); } <# } #> } -} \ No newline at end of file +<# + +foreach (var (t, tPixel) in EnumerateTypes()) +{ +#> + + [AutoConstructor] + internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader + { + public readonly ReadOnlyTexture2D<<#=t#>, <#=tPixel#>> source; + public readonly ReadWriteTexture2D<<#=t#>, <#=tPixel#>> destination; + + public void Execute() + { + destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2; + } + } +<# +} +#> +} diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt index 97dfb563..b1fdbeed 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.tt @@ -28,56 +28,55 @@ using System.Numerics; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; -namespace ComputeSharp.Tests +namespace ComputeSharp.Tests; + +public partial class Texture3DTests { - public partial class Texture3DTests + [CombinatorialTestMethod] + [AllDevices] +<# +foreach (var (t, tPixel) in EnumerateTypes()) +{ +#> + [Data(typeof(<#=t#>), typeof(<#=tPixel#>))] +<# +} +#> + public void Dispatch_NormalizedTexture3D(Device device, Type t, Type tPixel) { - [CombinatorialTestMethod] - [AllDevices] <# foreach (var (t, tPixel) in EnumerateTypes()) { #> - [Data(typeof(<#=t#>), typeof(<#=tPixel#>))] -<# -} -#> - public void Dispatch_NormalizedTexture3D(Device device, Type t, Type tPixel) + if (t == typeof(<#=t#>) && tPixel == typeof(<#=tPixel#>)) { -<# -foreach (var (t, tPixel) in EnumerateTypes()) -{ -#> - if (t == typeof(<#=t#>) && tPixel == typeof(<#=tPixel#>)) - { - using ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source = device.Get().AllocateReadOnlyTexture3D<<#=t#>, <#=tPixel#>>(128, 128, 2); - using ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination = device.Get().AllocateReadWriteTexture3D<<#=t#>, <#=tPixel#>>(128, 128, 2); + using ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source = device.Get().AllocateReadOnlyTexture3D<<#=t#>, <#=tPixel#>>(128, 128, 2); + using ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination = device.Get().AllocateReadWriteTexture3D<<#=t#>, <#=tPixel#>>(128, 128, 2); - device.Get().For(128, 128, 2, new Shader_Unorm_<#=t#>_<#=tPixel#>(source, destination)); - } -<# -} -#> - } -<# - -foreach (var (t, tPixel) in EnumerateTypes()) -{ -#> - - [AutoConstructor] - internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader - { - public readonly ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source; - public readonly ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination; - - public void Execute() - { - destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; - } + device.Get().For(128, 128, 2, new Shader_Unorm_<#=t#>_<#=tPixel#>(source, destination)); } <# } #> } -} \ No newline at end of file +<# + +foreach (var (t, tPixel) in EnumerateTypes()) +{ +#> + + [AutoConstructor] + internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader + { + public readonly ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source; + public readonly ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination; + + public void Execute() + { + destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; + } + } +<# +} +#> +}