diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c47dc653..d33abc62 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -119,8 +119,10 @@ jobs: needs: [build-solution] strategy: matrix: - framework: [net6.0, netcoreapp3.1, net472] + framework: [net7.0, net6.0, netcoreapp3.1, net472] runs-on: windows-2022 + env: + CI_RUNNER_SAMPLES_INTEGRATION_TESTS: true steps: - name: Git checkout uses: actions/checkout@v3 @@ -136,6 +138,28 @@ jobs: run: > dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -p:Platform=x64 -v n; ${{matrix.command}} samples\ComputeSharp.ImageProcessing\bin\x64\Release\${{matrix.framework}}\win-x64\ComputeSharp.ImageProcessing.exe + + # Also publish the NativeAOT test when .NET 7 is used + - if: matrix.framework == 'net7.0' + name: Publish ComputeSharp.SwapChain.Cli with NativeAOT + run: > + $env:COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT='true'; + dotnet publish samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj -c Release -f net7.0 -r win-x64 -v n + - if: matrix.framework == 'net7.0' + name: Run ComputeSharp.SwapChain.Cli + run: > + $process = (Start-Process samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe -PassThru); + sleep -Seconds 2; + $process.CloseMainWindow() | Out-Null; + $process.WaitForExit(); + $process.ExitCode + - if: matrix.framework == 'net7.0' + name: Upload NativeAOT CLI sample + uses: actions/upload-artifact@v3 + with: + name: computesharp.cli.exe + path: samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe + if-no-files-found: error # Download the NuGet packages generated in the previous job and use them # to build and run the sample project referencing them. This is used as diff --git a/ComputeSharp.sln b/ComputeSharp.sln index 5325e343..e3314f79 100644 --- a/ComputeSharp.sln +++ b/ComputeSharp.sln @@ -48,6 +48,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Tests.NativeLi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.SwapChain", "samples\ComputeSharp.SwapChain\ComputeSharp.SwapChain.csproj", "{E7C9247D-016B-4819-AF9F-0E9B3591E04B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputeSharp.SwapChain.Cli", "samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj", "{C12D7ACE-98ED-4813-8118-6667C34F484F}" +EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ComputeSharp.Sample.FSharp", "samples\ComputeSharp.Sample.FSharp\ComputeSharp.Sample.FSharp.fsproj", "{7C625EC4-F599-4350-A915-F046DF2406D3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Sample.FSharp.Shaders", "samples\ComputeSharp.Sample.FSharp.Shaders\ComputeSharp.Sample.FSharp.Shaders.csproj", "{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}" @@ -362,6 +364,14 @@ Global {669A414F-3B46-4B55-B587-061AF63C3067}.Release|ARM64.Build.0 = Release|Any CPU {669A414F-3B46-4B55-B587-061AF63C3067}.Release|x64.ActiveCfg = Release|Any CPU {669A414F-3B46-4B55-B587-061AF63C3067}.Release|x64.Build.0 = Release|Any CPU + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|ARM64.Build.0 = Debug|ARM64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|x64.ActiveCfg = Debug|x64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|x64.Build.0 = Debug|x64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|ARM64.ActiveCfg = Release|ARM64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|ARM64.Build.0 = Release|ARM64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|x64.ActiveCfg = Release|x64 + {C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -396,6 +406,7 @@ Global {5DE90C85-ED26-4B5A-A0D7-2FF966A210AC} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7} {669A414F-3B46-4B55-B587-061AF63C3067} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7} {B86A48A7-18BD-4946-B995-3CE26B092DDF} = {1A9C4108-F61A-4ABE-B5CF-F524521EAE2D} + {C12D7ACE-98ED-4813-8118-6667C34F484F} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC} @@ -423,6 +434,7 @@ Global src\ComputeSharp.UI\ComputeSharp.UI.projitems*{afaafdc9-be42-45d4-8c79-0ee8c8edbf52}*SharedItemsImports = 5 src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{bfb003d1-788b-48de-8065-39479c162cb0}*SharedItemsImports = 5 src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{bfb003d1-788b-48de-8065-39479c162cb0}*SharedItemsImports = 5 + samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{c12d7ace-98ed-4813-8118-6667c34f484f}*SharedItemsImports = 5 src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 src\ComputeSharp.D2D1.NetStandard\ComputeSharp.D2D1.NetStandard.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5 diff --git a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj index d708f8f8..bf266575 100644 --- a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj +++ b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj @@ -1,8 +1,8 @@ - + Exe - net472;netcoreapp3.1;net6.0 + net472;netcoreapp3.1;net6.0;net7.0 AnyCPU;x64;ARM64 $(NoWarn);CA1416 diff --git a/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj b/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj index 4ac1ef65..b0389dd1 100644 --- a/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj +++ b/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj @@ -1,8 +1,8 @@ - + Exe - net472;netcoreapp3.1;net6.0 + net472;netcoreapp3.1;net6.0;net7.0 AnyCPU;x64;ARM64 5.0 diff --git a/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj b/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj index c35936d1..bd4f75e8 100644 --- a/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj +++ b/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj @@ -1,8 +1,8 @@ - + Exe - net472;netcoreapp3.1;net6.0 + net472;netcoreapp3.1;net6.0;net7.0 AnyCPU;x64;ARM64 $(NoWarn);CA1416 diff --git a/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj b/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj new file mode 100644 index 00000000..b12c54b2 --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj @@ -0,0 +1,56 @@ + + + + + + Exe + WinExe + net7.0 + x64;ARM64 + $(DefineConstants);SAMPLE_APP + $(NoWarn);CA1416 + computesharp.cli + icon.ico + + + + + true + true + true + false + true + Speed + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ComputeSharp.SwapChain.Cli/Program.cs b/samples/ComputeSharp.SwapChain.Cli/Program.cs new file mode 100644 index 00000000..68d9578a --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Cli/Program.cs @@ -0,0 +1,63 @@ +using System; +using ComputeSharp.SwapChain.Backend; +using ComputeSharp.SwapChain.Shaders; +using TerraFX.Interop.Windows; + +// Accepted inputs: +// - [] +// - [] +if (args is [] or [_]) +{ + // If there are no args, just run the default shader + if (args is not [string shaderName]) + { + shaderName = nameof(ColorfulInfinity); + } + + // Get the requested shader, if possible + Win32Application? application = shaderName.ToLowerInvariant() switch + { + "helloworld" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "colorfulinfinity" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "fractaltiling" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "twotiledtruchet" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "mengerjourney" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "octagrams" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "proteanclouds" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "extrudedtruchetpattern" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "pyramidpattern" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "trianglegridcontouring" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + "terracedhills" => new SwapChainApplication(static time => new((float)time.TotalSeconds)), + _ => null + }; + + // If a shader is found, run it + if (application is not null) + { + return Win32ApplicationRunner.Run(application, "ComputeSharp", "ComputeSharp"); + } + + // If no shader matches, check if help was requested + if (shaderName is "-h") + { + Console.WriteLine($""" + Available shaders: + + - {nameof(HelloWorld)} + - {nameof(ColorfulInfinity)} + - {nameof(FractalTiling)} + - {nameof(TwoTiledTruchet)} + - {nameof(MengerJourney)} + - {nameof(Octagrams)} + - {nameof(ProteanClouds)} + - {nameof(ExtrudedTruchetPattern)} + - {nameof(PyramidPattern)} + - {nameof(TriangleGridContouring)} + - {nameof(TerracedHills)} + """); + + return S.S_OK; + } +} + +return E.E_INVALIDARG; \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.Cli/icon.ico b/samples/ComputeSharp.SwapChain.Cli/icon.ico new file mode 100644 index 00000000..fd2c7ce7 Binary files /dev/null and b/samples/ComputeSharp.SwapChain.Cli/icon.ico differ diff --git a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs index 9affa55c..41713dbe 100644 --- a/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs +++ b/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication{T}.cs @@ -287,6 +287,7 @@ internal sealed class SwapChainApplication : Win32Application // Execute the command list to perform the copy this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList**)this.d3D12GraphicsCommandList.GetAddressOf()); + _ = this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue); // Present the new frame