From fcb8d028b2d43ef8624b3441e14dbf06483bc75f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 27 Apr 2022 12:47:23 +0200 Subject: [PATCH] Add unit tests for fields with this. expressions --- .../ComputeSharp.Tests/ShaderCompilerTests.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index fbaca8b5..0c497090 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -32,6 +32,43 @@ namespace ComputeSharp.Tests } } + [TestMethod] + public void ReservedKeywordsPrecompiled() + { + _ = ReflectionServices.GetShaderInfo(); + } + + [AutoConstructor] + [EmbeddedBytecode(DispatchAxis.X)] + public readonly partial struct ReservedKeywordsPrecompiledShader : IComputeShader + { + public readonly ReadWriteBuffer row_major; + public readonly float dword; + public readonly float float2; + public readonly int int2x2; + private readonly float sin; + private readonly float cos; + private readonly float scale; + private readonly float intensity; + + public void Execute() + { + float exp = Hlsl.Exp(dword * row_major[ThreadIds.X]); + float log = Hlsl.Log(1 + exp); + + float s1 = this.cos * exp * this.sin * log; + float t1 = -this.sin * exp * this.cos * log; + + float s2 = s1 + this.intensity + Hlsl.Tan(s1 * this.scale); + float t2 = t1 + this.intensity + Hlsl.Tan(t1 * this.scale); + + float u2 = this.cos * s2 - this.sin * t2; + float v2 = this.sin * s2 - this.cos * t2; + + row_major[ThreadIds.X] = log / dword + float2 + int2x2 + u2 + v2; + } + } + [TestMethod] public void SpecialTypeAsReturnType() {