From a48290873e98b746e59a8425d1d03bbbe875d388 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 14 Dec 2021 23:05:09 +0100 Subject: [PATCH] Update unit test projects --- .github/workflows/dotnet.yml | 26 +----- ...arp.Tests.DisableDynamicCompilation.csproj | 5 -- .../DispatchTests.cs | 47 ----------- .../ComputeSharp.Tests.Internals.csproj | 7 +- .../ShaderBytecodeTests.cs | 79 ------------------- .../ShaderCompilerTests.cs | 6 +- .../ComputeSharp.Tests.csproj | 1 + 7 files changed, 6 insertions(+), 165 deletions(-) delete mode 100644 tests/ComputeSharp.Tests.Internals/ShaderBytecodeTests.cs diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 415368bb..61a00d20 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -44,26 +44,6 @@ jobs: run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64 shell: cmd - # Build the whole ComputeSharp solution with /p:DisableShaderCompilationSupport=True - build-solution-release-no-dynamic: - runs-on: windows-2022 - steps: - - name: Git checkout - uses: actions/checkout@v2 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.3 - - name: Setup .NET Core 3.1 SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.x - - name: Setup .NET 6 SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Build - run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64 /p:DisableShaderCompilationSupport=True - shell: cmd - # Run all the unit tests referencing the ComputeSharp project directly run-tests: if: success() @@ -84,7 +64,7 @@ jobs: run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed" shell: cmd - name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET 6) - run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net6.0 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed" + run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed" shell: cmd - name: Run ComputeSharp.Tests.Internals (.NET 6) run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed" @@ -93,7 +73,7 @@ jobs: run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed" shell: cmd - name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET Core 3.1) - run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed" + run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed" shell: cmd - name: Run ComputeSharp.Tests.Internals (.NET Core 3.1) run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed" @@ -102,7 +82,7 @@ jobs: run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed" shell: cmd - name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET Framework 4.7.2) - run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net472 /p:Platform=x64 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed" + run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed" shell: cmd - name: Run ComputeSharp.Tests.Internals (.NET Framework 4.7.2) run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed" diff --git a/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj b/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj index c38a80d2..6c45efbd 100644 --- a/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj +++ b/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj @@ -22,11 +22,6 @@ PrivateAssets="contentfiles;build" /> - - - $(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT - - diff --git a/tests/ComputeSharp.Tests.DisableDynamicCompilation/DispatchTests.cs b/tests/ComputeSharp.Tests.DisableDynamicCompilation/DispatchTests.cs index ca43ee2f..62549288 100644 --- a/tests/ComputeSharp.Tests.DisableDynamicCompilation/DispatchTests.cs +++ b/tests/ComputeSharp.Tests.DisableDynamicCompilation/DispatchTests.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using ComputeSharp.Interop; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -11,22 +10,10 @@ namespace ComputeSharp.Tests.DisableDynamicCompilation; [TestCategory("Dispatch")] public partial class DispatchTests { - private static readonly bool IsDynamicCompilationDisabled = -#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT - true; -#else - false; -#endif - [CombinatorialTestMethod] [AllDevices] public void ComputeShader_Test_Ok(Device device) { - if (!IsDynamicCompilationDisabled) - { - Assert.Inconclusive(); - } - float[] array = Enumerable.Range(0, 128).Select(static i => (float)i).ToArray(); using ReadWriteBuffer buffer = device.Get().AllocateReadWriteBuffer(array); @@ -48,11 +35,6 @@ public partial class DispatchTests [ExpectedException(typeof(NotSupportedException))] public void ComputeShader_Test_Fail(Device device) { - if (!IsDynamicCompilationDisabled) - { - Assert.Inconclusive(); - } - using ReadWriteBuffer buffer = device.Get().AllocateReadWriteBuffer(128); device.Get().For(128, 1, 1, 64, 1, 1, new ComputeShader(buffer, 2.0f)); @@ -76,11 +58,6 @@ public partial class DispatchTests [AllDevices] public void PixelShader_Test_Ok(Device device) { - if (!IsDynamicCompilationDisabled) - { - Assert.Inconclusive(); - } - using ReadWriteTexture2D texture = device.Get().AllocateReadWriteTexture2D(128, 128); device.Get().ForEach(texture, new PixelShader(0.3f, 0.6f)); @@ -120,28 +97,4 @@ public partial class DispatchTests return new(ThreadIds.Normalized.X, ThreadIds.Normalized.Y, b, a); } } - - [TestMethod] - [ExpectedException(typeof(NotSupportedException))] - public void ReflectionService_ComputeShader() - { - if (!IsDynamicCompilationDisabled) - { - Assert.Inconclusive(); - } - - ReflectionServices.GetShaderInfo(out _); - } - - [TestMethod] - [ExpectedException(typeof(NotSupportedException))] - public void ReflectionService_PixelShader() - { - if (!IsDynamicCompilationDisabled) - { - Assert.Inconclusive(); - } - - ReflectionServices.GetShaderInfo(out _); - } } diff --git a/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj b/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj index 190815c1..156a2712 100644 --- a/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj +++ b/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj @@ -4,12 +4,6 @@ net472;netcoreapp3.1;net6.0 false AnyCPU;x64;ARM64 - false - - - - - $(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT @@ -20,6 +14,7 @@ + bytecode)); - Assert.IsFalse(bytecode.Length > 0); - } - - [AutoConstructor] - internal readonly partial struct NonPrecompiledShader : IComputeShader - { - public readonly ReadWriteBuffer buffer; - public readonly float factor; - - /// - public void Execute() - { - buffer[ThreadIds.X] *= factor; - } - } - - [TestMethod] - public void ComputeShader_Test() - { - Assert.IsTrue(((IComputeShader)default(ComputeShader)).TryGetBytecode(32, 1, 1, out ReadOnlySpan bytecode)); - Assert.IsTrue(bytecode.Length > 0); - - Assert.IsFalse(((IComputeShader)default(ComputeShader)).TryGetBytecode(64, 1, 1, out bytecode)); - Assert.IsFalse(bytecode.Length > 0); - } - - [AutoConstructor] - [EmbeddedBytecode(32, 1, 1)] - internal readonly partial struct ComputeShader : IComputeShader - { - public readonly ReadWriteBuffer buffer; - public readonly float factor; - - /// - public void Execute() - { - buffer[ThreadIds.X] *= factor; - } - } - - [TestMethod] - public void PixelShader_Test() - { - Assert.IsTrue(((IPixelShader)default(PixelShader)).TryGetBytecode(8, 8, 1, out ReadOnlySpan bytecode)); - Assert.IsTrue(bytecode.Length > 0); - - Assert.IsFalse(((IPixelShader)default(PixelShader)).TryGetBytecode(32, 1, 1, out bytecode)); - Assert.IsFalse(bytecode.Length > 0); - } - - [AutoConstructor] - [EmbeddedBytecode(8, 8, 1)] - internal readonly partial struct PixelShader : IPixelShader - { - public readonly ReadWriteTexture2D buffer; - public readonly float factor; - - /// - public float4 Execute() - { - return buffer[ThreadIds.XY] * factor; - } - } -} diff --git a/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs index 0c10427f..e563da4a 100644 --- a/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs @@ -1,6 +1,4 @@ -#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT - -using System; +using System; using ComputeSharp.Exceptions; using ComputeSharp.Shaders.Translation; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -47,5 +45,3 @@ public class ShaderCompilerTests using ComPtr dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader.AsSpan()); } } - -#endif diff --git a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj index d4c166a1..e8d85f91 100644 --- a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj +++ b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj @@ -16,6 +16,7 @@ +