From 2f0ba6ff863e9eff7774b6d4b8a7c4b0d181fdac Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 26 Sep 2022 23:19:47 +0200 Subject: [PATCH] Fix 3D normalized sampling --- tests/ComputeSharp.Tests/ComputeContextTests.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index 616731e0..039bbe46 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -1347,7 +1347,12 @@ public partial class ComputeContextTests /// public void Execute() { - destination[ThreadIds.XYZ] = source.Sample(ThreadIds.Normalized.XYZ); + float3 xyz = ThreadIds.Normalized.XYZ; + + // The source has a depth of 3, but the destination has a depth of 2 + xyz.Z = Hlsl.Lerp(0, 0.5f, xyz.Z); + + destination[ThreadIds.XYZ] = source.Sample(xyz); } } @@ -1396,7 +1401,12 @@ public partial class ComputeContextTests /// public void Execute() { - destination[ThreadIds.XYZ] = source.Sample(ThreadIds.Normalized.XYZ); + float3 xyz = ThreadIds.Normalized.XYZ; + + // See comment in LinearSampling3DComputeShader + xyz.Z = Hlsl.Lerp(0, 0.5f, xyz.Z); + + destination[ThreadIds.XYZ] = source.Sample(xyz); } }