Update WinUI sample to run on NativeAOT

このコミットが含まれているのは:
Sergio Pedri committed 2024-08-24 15:40:58 -07:00
1 親 1286194241
コミット 47204e8f83
8ファイル変更
+31 -23

検索条件に一致するファイルはありません

+18
ファイルの表示
@@ -9,9 +9,26 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<PublishAot>true</PublishAot>
<EnableMsixTooling>true</EnableMsixTooling>
</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>
<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
@@ -33,6 +50,7 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.0-build.5.g1bf778c86e" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.2.240824-pull-488.1154" />
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.2.240824-pull-488.1154" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.1" />
</ItemGroup>
<!--
+1 -1
ファイルの表示
@@ -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"/>.
+1 -7
ファイルの表示
@@ -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>
+1 -7
ファイルの表示
@@ -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>
+2 -2
ファイルの表示
@@ -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>
+1 -1
ファイルの表示
@@ -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.
+6 -4
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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" />