Merge pull request #842 from Sergio0694/dev/aot-winui-sample
Add NativeAOT support to WinUI 3 sample app
このコミットが含まれているのは:
10ファイル変更
+77
-41
検索条件に一致するファイルはありません
@@ -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
|
||||
|
||||
@@ -10,29 +10,68 @@
|
||||
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<RestoreSources>
|
||||
https://api.nuget.org/v3/index.json;
|
||||
https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-MainLatest/nuget/v3/index.json;
|
||||
</RestoreSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<!--
|
||||
Temporary workaround: don't fail builds for 'IL2059' errors, like this:
|
||||
"XamlTypeInfo.g.cs(495): Trim analysis warning IL2059: ComputeSharp.SwapChain.WinUI.ComputeSharp_SwapChain_WinUI_XamlTypeInfo.XamlTypeInfoProvider.
|
||||
StaticInitializer_38_Nullable(): Unrecognized value passed to the parameter 'type' of method 'System.Runtime. CompilerServices.RuntimeHelpers
|
||||
.RunClassConstructor(RuntimeTypeHandle)'. It's not possible to guarantee the availability of the target static constructor."
|
||||
This is due to a bug in the .NET trim analyzer and in ILC, see: https://github.com/dotnet/runtime/issues/106939.
|
||||
The best fix would also be to update the XAML compiler in WinAppSDK to skip generating unnecessary static constructor stubs.
|
||||
-->
|
||||
<TrimmerSingleWarn>false</TrimmerSingleWarn>
|
||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);IL2059</WarningsNotAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Additional CsWinRT properties (temporary, until the .NET SDK is updated) -->
|
||||
<PropertyGroup>
|
||||
|
||||
<!--
|
||||
We're only referencing CsWinRT for the source generators, we don't need to read any WinRT metadata.
|
||||
CsWinRT is in projection mode by default, so we want to disable it (or it'd need the Windows SDK).
|
||||
-->
|
||||
<CsWinRTGenerateProjection>false</CsWinRTGenerateProjection>
|
||||
|
||||
<!-- We'll never have any IIDs to patch in this library -->
|
||||
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
|
||||
|
||||
<!-- Enable AOT warnings for types implementing projected WinRT interfaces mapped to built-in types (eg. 'INotifyPropertyChanged') -->
|
||||
<CsWinRTAotWarningLevel>2</CsWinRTAotWarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- CsWinRT size saving options -->
|
||||
<PropertyGroup>
|
||||
<CsWinRTEnableDynamicObjectsSupport>false</CsWinRTEnableDynamicObjectsSupport>
|
||||
<CsWinRTUseExceptionResourceKeys>true</CsWinRTUseExceptionResourceKeys>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- NativeAOT options -->
|
||||
<PropertyGroup>
|
||||
<PublishAot>true</PublishAot>
|
||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<StackTraceSupport>false</StackTraceSupport>
|
||||
<OptimizationPreference>Speed</OptimizationPreference>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Misc\noise_low.png" />
|
||||
<Content Include="..\ComputeSharp.SwapChain\Textures\RustyMetal.png">
|
||||
<Link>Assets\Textures\RustyMetal.png</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Core" Version="7.1.2" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Media" Version="7.1.2" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.0-build.5" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.2.240824-build.1155" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.240824-build.1155" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ComputeSharp.SwapChain.WinUI.Views;
|
||||
/// A custom <see cref="Control"/> that can be used to render animated backgrounds via Win2D.
|
||||
/// </summary>
|
||||
[TemplatePart(Name = "PART_CanvasAnimatedControl", Type = typeof(CanvasAnimatedControl))]
|
||||
public sealed class D2D1AnimatedPixelShaderPanel : Control
|
||||
public sealed partial class D2D1AnimatedPixelShaderPanel : Control
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="DependencyProperty"/> backing <see cref="PixelShaderEffect"/>.
|
||||
|
||||
@@ -6,13 +6,7 @@
|
||||
<Platform>arm64</Platform>
|
||||
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
|
||||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
|
||||
<PublishAot>true</PublishAot>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<!--
|
||||
See https://github.com/microsoft/CsWinRT/issues/373
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
-->
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -6,13 +6,7 @@
|
||||
<Platform>x64</Platform>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
|
||||
<PublishAot>true</PublishAot>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<!--
|
||||
See https://github.com/microsoft/CsWinRT/issues/373
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
-->
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Core.Shaders;
|
||||
/// <summary>
|
||||
/// An base effect for an animated pixel shader.
|
||||
/// </summary>
|
||||
public abstract class PixelShaderEffect : CanvasEffect
|
||||
public abstract partial class PixelShaderEffect : CanvasEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The current elapsed time.
|
||||
@@ -57,7 +57,7 @@ public abstract class PixelShaderEffect : CanvasEffect
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of pixel shader to render.</typeparam>
|
||||
/// <param name="factory">The input <typeparamref name="T"/> factory.</param>
|
||||
public sealed class For<T>(For<T>.Factory factory) : PixelShaderEffect
|
||||
public sealed partial class For<T>(For<T>.Factory factory) : PixelShaderEffect
|
||||
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace ComputeSharp.SwapChain.Core.Shaders.Runners;
|
||||
/// <summary>
|
||||
/// A specialized <see cref="PixelShaderEffect"/> for <see cref="ContouredLayers"/>.
|
||||
/// </summary>
|
||||
public sealed class D2D1ContouredLayersEffect : PixelShaderEffect
|
||||
public sealed partial class D2D1ContouredLayersEffect : PixelShaderEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The reusable <see cref="PixelShaderEffect{T}"/> node to use to render frames.
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
@@ -68,13 +70,13 @@ public sealed partial class MainViewModel : ObservableObject
|
||||
/// <summary>
|
||||
/// Gets the available resolution scaling options (as percentage values).
|
||||
/// </summary>
|
||||
public IList<int> ResolutionScaleOptions { get; } = [25, 50, 75, 100];
|
||||
public IList<int> ResolutionScaleOptions { get; } = new int[] { 25, 50, 75, 100 };
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of available compute shader.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ShaderRunnerViewModel> ComputeShaderOptions { get; } =
|
||||
[
|
||||
public IReadOnlyList<ShaderRunnerViewModel> ComputeShaderOptions { get; } = new ShaderRunnerViewModel[]
|
||||
{
|
||||
new(
|
||||
nameof(ColorfulInfinity),
|
||||
new ShaderRunner<ColorfulInfinity>(static time => new((float)time.TotalSeconds)),
|
||||
@@ -112,7 +114,7 @@ public sealed partial class MainViewModel : ObservableObject
|
||||
nameof(TerracedHills),
|
||||
new ShaderRunner<TerracedHills>(static time => new((float)time.TotalSeconds)),
|
||||
new PixelShaderEffect.For<SwapChain.Shaders.D2D1.TerracedHills>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
|
||||
];
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the resolution scale can currently be expliclty set.
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
x:Class="ComputeSharp.SwapChain.WinUI.Views.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:animations="using:CommunityToolkit.WinUI.UI.Animations"
|
||||
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
|
||||
xmlns:computesharp="using:ComputeSharp.WinUI"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
|
||||
xmlns:enums="using:ComputeSharp.SwapChain.Core.Enums"
|
||||
xmlns:media="using:CommunityToolkit.WinUI.UI.Media"
|
||||
xmlns:ui="using:CommunityToolkit.WinUI.UI"
|
||||
xmlns:media="using:CommunityToolkit.WinUI.Media"
|
||||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
xmlns:viewModels="using:ComputeSharp.SwapChain.Core.ViewModels"
|
||||
xmlns:views="using:ComputeSharp.SwapChain.WinUI.Views"
|
||||
SizeChanged="Window_SizeChanged">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240807006-preview1" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240821007-preview2" />
|
||||
|
||||
<!-- Reference CsWinRT locally for the source generators (see comments in ComputeSharp.D2D1.WinUI) -->
|
||||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.1" PrivateAssets="all" />
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする