From 1286194241488cbae6fe57fec8e8bed80cd3e742 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 24 Aug 2024 15:24:03 -0700 Subject: [PATCH 1/8] Update Toolkit in WinUI sample app --- .../ComputeSharp.SwapChain.WinUI.csproj | 6 +++--- .../ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index b796eefd..e3011a7b 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -30,9 +30,9 @@ - - - + + + + + + + false + + + true + + + 2 + + @@ -33,6 +50,7 @@ + \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.WinUI/Properties/PublishProfiles/win-x64.pubxml b/samples/ComputeSharp.SwapChain.WinUI/Properties/PublishProfiles/win-x64.pubxml index 69645733..bb66783c 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Properties/PublishProfiles/win-x64.pubxml +++ b/samples/ComputeSharp.SwapChain.WinUI/Properties/PublishProfiles/win-x64.pubxml @@ -6,13 +6,7 @@ x64 win-x64 bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true true - False - False - True - \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.WinUI/Shaders/PixelShaderEffect.cs b/samples/ComputeSharp.SwapChain.WinUI/Shaders/PixelShaderEffect.cs index f4dcf177..f9273e44 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Shaders/PixelShaderEffect.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/Shaders/PixelShaderEffect.cs @@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Core.Shaders; /// /// An base effect for an animated pixel shader. /// -public abstract class PixelShaderEffect : CanvasEffect +public abstract partial class PixelShaderEffect : CanvasEffect { /// /// The current elapsed time. @@ -57,7 +57,7 @@ public abstract class PixelShaderEffect : CanvasEffect /// /// The type of pixel shader to render. /// The input factory. - public sealed class For(For.Factory factory) : PixelShaderEffect + public sealed partial class For(For.Factory factory) : PixelShaderEffect where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { /// diff --git a/samples/ComputeSharp.SwapChain.WinUI/Shaders/Runners/D2D1ContouredLayersRunner.cs b/samples/ComputeSharp.SwapChain.WinUI/Shaders/Runners/D2D1ContouredLayersRunner.cs index a49c6659..70c2ec39 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Shaders/Runners/D2D1ContouredLayersRunner.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/Shaders/Runners/D2D1ContouredLayersRunner.cs @@ -11,7 +11,7 @@ namespace ComputeSharp.SwapChain.Core.Shaders.Runners; /// /// A specialized for . /// -public sealed class D2D1ContouredLayersEffect : PixelShaderEffect +public sealed partial class D2D1ContouredLayersEffect : PixelShaderEffect { /// /// The reusable node to use to render frames. diff --git a/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs b/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs index 7abe34bf..e9dd941b 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs @@ -7,6 +7,8 @@ using ComputeSharp.SwapChain.Core.Shaders.Runners; using ComputeSharp.SwapChain.Shaders; using ComputeSharp.WinUI; +#pragma warning disable IDE0300 // CsWinRT does not support marshalling collection expression (https://github.com/microsoft/CsWinRT/issues/1661) + namespace ComputeSharp.SwapChain.Core.ViewModels; /// @@ -68,13 +70,13 @@ public sealed partial class MainViewModel : ObservableObject /// /// Gets the available resolution scaling options (as percentage values). /// - public IList ResolutionScaleOptions { get; } = [25, 50, 75, 100]; + public IList ResolutionScaleOptions { get; } = new int[] { 25, 50, 75, 100 }; /// /// Gets the collection of available compute shader. /// - public IReadOnlyList ComputeShaderOptions { get; } = - [ + public IReadOnlyList ComputeShaderOptions { get; } = new ShaderRunnerViewModel[] + { new( nameof(ColorfulInfinity), new ShaderRunner(static time => new((float)time.TotalSeconds)), @@ -112,7 +114,7 @@ public sealed partial class MainViewModel : ObservableObject nameof(TerracedHills), new ShaderRunner(static time => new((float)time.TotalSeconds)), new PixelShaderEffect.For(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))), - ]; + }; /// /// Checks whether the resolution scale can currently be expliclty set. diff --git a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj index 6509d14e..5f2f2c25 100644 --- a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj +++ b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj @@ -20,7 +20,7 @@ - + From d769acbbcd0dd914ba09441456dff8edee883ff2 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 24 Aug 2024 15:42:19 -0700 Subject: [PATCH 3/8] Remove unnecessary 'Manifest' item in .csproj --- .../ComputeSharp.SwapChain.WinUI.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index b81085b2..ad100f30 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -42,10 +42,6 @@ - - - - From fc0fe7f6973771ad33609752a0504c4a97d3000a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 24 Aug 2024 15:55:30 -0700 Subject: [PATCH 4/8] Add NativeAOT and CsWinRT additional properties --- .../ComputeSharp.SwapChain.WinUI.csproj | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index ad100f30..1f372793 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -9,7 +9,6 @@ win-x64;win-arm64 win-$(Platform).pubxml true - true true @@ -29,6 +28,21 @@ 2 + + + false + true + + + + + true + true + true + false + Speed + + From 294ae060f117b438740224593ad5ae16b295b1f1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 25 Aug 2024 10:32:37 -0700 Subject: [PATCH 5/8] Switch to Toolkit packages from main-latest feed --- .../ComputeSharp.SwapChain.WinUI.csproj | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index 1f372793..c9f7d9c8 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -10,6 +10,10 @@ win-$(Platform).pubxml true true + + https://api.nuget.org/v3/index.json; + https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json; + @@ -57,9 +61,9 @@ - - - + + + From 45bba9d689337db3118a4bc45dba1451f78f2fa7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 25 Aug 2024 10:35:04 -0700 Subject: [PATCH 6/8] Remove unnecessary 'Content' .csproj items --- .../ComputeSharp.SwapChain.WinUI.csproj | 7 ------- 1 file changed, 7 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index c9f7d9c8..050e829c 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -48,13 +48,6 @@ - - - - - - - Assets\Textures\RustyMetal.png From 57e23fa740cc2c6fb89d51421df1bd50b7bff988 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 25 Aug 2024 11:08:33 -0700 Subject: [PATCH 7/8] Workaround for 'IL2059' errors in WinUI sample --- .../ComputeSharp.SwapChain.WinUI.csproj | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index 050e829c..313f8c0c 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -16,6 +16,20 @@ + + + + false + $(WarningsNotAsErrors);IL2059 + + From 6a040d821947a36d524d2bd327edc880bab13016 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 25 Aug 2024 11:13:50 -0700 Subject: [PATCH 8/8] Publish the WinUI sample with NativeAOT in CI --- .github/workflows/dotnet.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index b41c31fe..8d463907 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -326,6 +326,13 @@ jobs: run: > msbuild samples\ComputeSharp.NativeLibrary.WinRT\ComputeSharp.NativeLibrary.WinRT.csproj /restore -t:publish /p:Configuration=Release /p:Platform=${{matrix.platform}} /p:RuntimeIdentifier=win-${{matrix.platform}} + + # Publish the WinUI 3 sample app with NativeAOT + - if: matrix.platform == 'x64' + name: Publish ComputeSharp.SwapChain.WinUI + run: > + msbuild samples\ComputeSharp.SwapChain.WinUI\ComputeSharp.SwapChain.WinUI.csproj /restore -t:publish + /p:Configuration=Release /p:Platform=${{matrix.platform}} /p:RuntimeIdentifier=win-${{matrix.platform}} # 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