From 9024a8c5a27b3d9a8b07d0709bc65ca6a78c190d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 20 Nov 2022 15:10:11 +0100 Subject: [PATCH] Add shader compiler tests for scoped parameters --- .../ComputeSharp.Tests/ShaderCompilerTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index 9893e27b..d17c8344 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -467,6 +467,49 @@ namespace ComputeSharp.Tests results[ThreadIds.X] = result1 + result2 + bufferA[ThreadIds.X].Sum() + bufferB[0].Combine(); } } + + [TestMethod] + public void PixelShaderWithScopedParameterInMethods() + { + _ = ReflectionServices.GetShaderInfo(); + } + + internal static class HelpersForPixelShaderWithScopedParameterInMethods + { + public static void Baz(scoped in float a, scoped ref float b) + { + b = a; + } + } + + [AutoConstructor] + internal readonly partial struct PixelShaderWithScopedParameterInMethodsShader : IComputeShader + { + public readonly ReadWriteBuffer buffer; + public readonly float number; + + private static void Foo(scoped ref float a, ref float b) + { + b = a; + } + + private void Bar(scoped ref float a, scoped ref float b) + { + b = a; + } + + /// + public void Execute() + { + float number = this.number; + + Foo(ref this.buffer[ThreadIds.X], ref number); + Bar(ref this.buffer[ThreadIds.X], ref number); + HelpersForPixelShaderWithScopedParameterInMethods.Baz(in this.buffer[ThreadIds.X], ref number); + + this.buffer[ThreadIds.X] *= number; + } + } } }