From 6c75394e22def91e6c8ec25fed6c8f3714e4afd8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 9 Aug 2022 14:44:11 +0200 Subject: [PATCH] Update texture sampling calls in unit tests --- .../ContouredLayers.cs | 2 +- tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs | 6 +++--- tests/ComputeSharp.Tests/ComputeContextTests.cs | 8 ++++---- .../ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs | 2 +- tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs index 7fa460ef..91b0b04d 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs @@ -111,7 +111,7 @@ internal readonly partial struct ContouredLayers : IPixelShader // Layer color. Based on the shade, layer number and smoothing factor. private float3 GetColor(float2 p, float sh, float fi) { - float3 tx = texture[p + Hash21(new float2(sh, fi))].XYZ; + float3 tx = texture.Sample(p + Hash21(new float2(sh, fi))).XYZ; tx *= tx; diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs index 074483ce..d89d18e4 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs @@ -226,11 +226,11 @@ public partial class D2D1PixelShaderTests public Float4 Execute() { float4 pixel1 = myTexture1[0]; - float4 pixel2 = myTexture1[0.4f]; + float4 pixel2 = myTexture1.Sample(0.4f); float4 pixel3 = myTexture2[0, 1]; - float4 pixel4 = myTexture2[0.4f, 0.3f]; + float4 pixel4 = myTexture2.Sample(0.4f, 0.3f); float4 pixel5 = myTexture3[0, 1, 2]; - float4 pixel6 = myTexture3[0.4f, 0.5f, 0.6f]; + float4 pixel6 = myTexture3.Sample(0.4f, 0.5f, 0.6f); return 0; } diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index c7cf2ebf..c47cd66e 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -1288,7 +1288,7 @@ public partial class ComputeContextTests /// public float4 Execute() { - return source[ThreadIds.Normalized.XY]; + return source.Sample(ThreadIds.Normalized.XY); } } @@ -1301,7 +1301,7 @@ public partial class ComputeContextTests /// public void Execute() { - destination[ThreadIds.XYZ] = source[ThreadIds.Normalized.XYZ]; + destination[ThreadIds.XYZ] = source.Sample(ThreadIds.Normalized.XYZ); } } @@ -1313,7 +1313,7 @@ public partial class ComputeContextTests /// public float4 Execute() { - return source[ThreadIds.Normalized.XY]; + return source.Sample(ThreadIds.Normalized.XY); } } @@ -1326,7 +1326,7 @@ public partial class ComputeContextTests /// public void Execute() { - destination[ThreadIds.XYZ] = source[ThreadIds.Normalized.XYZ]; + destination[ThreadIds.XYZ] = source.Sample(ThreadIds.Normalized.XYZ); } } diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs index b982f561..7b33c396 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs @@ -113,7 +113,7 @@ internal readonly partial struct ContouredLayers : IComputeShader // Layer color. Based on the shade, layer number and smoothing factor. private float3 GetColor(float2 p, float sh, float fi) { - float3 tx = texture[p + Hash21(new float2(sh, fi))].XYZ; + float3 tx = texture.Sample(p + Hash21(new float2(sh, fi))).XYZ; tx *= tx; diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs index f357dfc0..91d19797 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs @@ -79,7 +79,7 @@ public partial class Texture2DTests public void Execute() { - destination[ThreadIds.XY] = source[ThreadIds.Normalized.XY]; + destination[ThreadIds.XY] = source.Sample(ThreadIds.Normalized.XY); } } @@ -111,7 +111,7 @@ public partial class Texture2DTests public float4 Execute() { - return texture[ThreadIds.Normalized.XY]; + return texture.Sample(ThreadIds.Normalized.XY); } }