From 37670e8f4c11ef42bc2696cad21c5627829f1cf5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 28 Dec 2021 14:05:30 +0100 Subject: [PATCH] Fix unit tests using ComputeContext APIs --- .../ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs | 1 + .../Processors/HlslBokehBlurProcessor{TPixel}.cs | 3 +++ .../Processors/HlslGaussianBlurProcessor{TPixel}.cs | 1 + tests/ComputeSharp.Tests/ComputeContextTests.cs | 3 +++ 4 files changed, 8 insertions(+) diff --git a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs index a757d8fe..99f6bd4a 100644 --- a/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs +++ b/samples/ComputeSharp.Benchmark/Dispatching/DispatchingBenchmark.cs @@ -74,6 +74,7 @@ public partial class DispatchingBenchmark : IDisposable using var context = GraphicsDevice.Default.CreateComputeContext(); context.For(64, new TestShader(Buffer!)); + context.FullBarrier(Buffer!); context.For(64, new TestShader(Buffer!)); } diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index 9d8a3089..74efc9d5 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -293,6 +293,9 @@ public sealed partial class HlslBokehBlurProcessor source.Height, new(texture, reals, imaginaries, kernel)); + context.FullBarrier(reals); + context.FullBarrier(imaginaries); + context.For( source.Width, source.Height, diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs index 59cd2930..95fd3633 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs @@ -108,6 +108,7 @@ public sealed partial class HlslGaussianBlurProcessor using (var context = GraphicsDevice.CreateComputeContext()) { context.For(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer)); + context.FullBarrier(firstPassTexture); context.For(source.Width, source.Height, new(firstPassTexture, sourceTexture, kernelBuffer)); } diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index 8e25271d..d16ea217 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -45,6 +45,7 @@ public partial class ComputeContextTests using (ComputeContext context = device.Get().CreateComputeContext()) { context.ForEach(texture, default(ClearPixelShader)); + context.FullBarrier(texture); context.ForEach(texture, new ColorPixelShader(new float4(0.22f, 0.44f, 0.66f, 0.88f))); } @@ -73,7 +74,9 @@ public partial class ComputeContextTests context.For(512, new OffsetComputeShader(buffer, 0)); context.For(64, new OffsetComputeShader(buffer, 512)); context.ForEach(texture, default(ClearPixelShader)); + context.StartBarrier(texture); context.For(299, new OffsetComputeShader(buffer, 576)); + context.EndBarrier(texture); context.ForEach(texture, new ColorPixelShader(new float4(0.22f, 0.44f, 0.66f, 0.88f))); context.For(149, new OffsetComputeShader(buffer, 875)); }