diff --git a/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj b/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj index ef77ef12..e60dcf6f 100644 --- a/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj +++ b/samples/ComputeSharp.SwapChain.Cli/ComputeSharp.SwapChain.Cli.csproj @@ -6,20 +6,16 @@ x64;ARM64 $(DefineConstants);SAMPLE_APP $(NoWarn);CA1416 - true true - false true true false - false - false - false - false + true + Speed @@ -29,6 +25,12 @@ + + + + + + diff --git a/samples/ComputeSharp.SwapChain.Cli/Program.cs b/samples/ComputeSharp.SwapChain.Cli/Program.cs index 78742303..68d9578a 100644 --- a/samples/ComputeSharp.SwapChain.Cli/Program.cs +++ b/samples/ComputeSharp.SwapChain.Cli/Program.cs @@ -1 +1,63 @@ -Console.WriteLine(string.Join(", ", args)); \ No newline at end of file +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