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); } static HelloWorld HelloWorld(TimeSpan time) => new((float)time.TotalSeconds); static ColorfulInfinity ColorfulInfinity(TimeSpan time) => new((float)time.TotalSeconds); static FractalTiling FractalTiling(TimeSpan time) => new((float)time.TotalSeconds); static TwoTiledTruchet TwoTiledTruchet(TimeSpan time) => new((float)time.TotalSeconds); static MengerJourney MengerJourney(TimeSpan time) => new((float)time.TotalSeconds); static Octagrams Octagrams(TimeSpan time) => new((float)time.TotalSeconds); static ProteanClouds ProteanClouds(TimeSpan time) => new((float)time.TotalSeconds); static ExtrudedTruchetPattern ExtrudedTruchetPattern(TimeSpan time) => new((float)time.TotalSeconds); static PyramidPattern PyramidPattern(TimeSpan time) => new((float)time.TotalSeconds); static TriangleGridContouring TriangleGridContouring(TimeSpan time) => new((float)time.TotalSeconds); static TerracedHills TerracedHills(TimeSpan time) => new((float)time.TotalSeconds); Win32Application? application; unsafe { // Get the requested shader, if possible application = shaderName.ToLowerInvariant() switch { "helloworld" => new SwapChainApplication(&HelloWorld), "colorfulinfinity" => new SwapChainApplication(&ColorfulInfinity), "fractaltiling" => new SwapChainApplication(&FractalTiling), "twotiledtruchet" => new SwapChainApplication(&TwoTiledTruchet), "mengerjourney" => new SwapChainApplication(&MengerJourney), "octagrams" => new SwapChainApplication(&Octagrams), "proteanclouds" => new SwapChainApplication(&ProteanClouds), "extrudedtruchetpattern" => new SwapChainApplication(&ExtrudedTruchetPattern), "pyramidpattern" => new SwapChainApplication(&PyramidPattern), "trianglegridcontouring" => new SwapChainApplication(&TriangleGridContouring), "terracedhills" => new SwapChainApplication(&TerracedHills), _ => 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;