Merge pull request #436 from Sergio0694/dev/swapchain-cli
Add reflection-free NativeAOT swap chain CLI sample
このコミットが含まれているのは:
9ファイル変更
+163
-7
検索条件に一致するファイルはありません
@@ -119,8 +119,10 @@ jobs:
|
||||
needs: [build-solution]
|
||||
strategy:
|
||||
matrix:
|
||||
framework: [net6.0, netcoreapp3.1, net472]
|
||||
framework: [net7.0, net6.0, netcoreapp3.1, net472]
|
||||
runs-on: windows-2022
|
||||
env:
|
||||
CI_RUNNER_SAMPLES_INTEGRATION_TESTS: true
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -136,6 +138,28 @@ jobs:
|
||||
run: >
|
||||
dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -p:Platform=x64 -v n;
|
||||
${{matrix.command}} samples\ComputeSharp.ImageProcessing\bin\x64\Release\${{matrix.framework}}\win-x64\ComputeSharp.ImageProcessing.exe
|
||||
|
||||
# Also publish the NativeAOT test when .NET 7 is used
|
||||
- if: matrix.framework == 'net7.0'
|
||||
name: Publish ComputeSharp.SwapChain.Cli with NativeAOT
|
||||
run: >
|
||||
$env:COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT='true';
|
||||
dotnet publish samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj -c Release -f net7.0 -r win-x64 -v n
|
||||
- if: matrix.framework == 'net7.0'
|
||||
name: Run ComputeSharp.SwapChain.Cli
|
||||
run: >
|
||||
$process = (Start-Process samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe -PassThru);
|
||||
sleep -Seconds 2;
|
||||
$process.CloseMainWindow() | Out-Null;
|
||||
$process.WaitForExit();
|
||||
$process.ExitCode
|
||||
- if: matrix.framework == 'net7.0'
|
||||
name: Upload NativeAOT CLI sample
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: computesharp.cli.exe
|
||||
path: samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe
|
||||
if-no-files-found: error
|
||||
|
||||
# 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
|
||||
|
||||
@@ -48,6 +48,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Tests.NativeLi
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.SwapChain", "samples\ComputeSharp.SwapChain\ComputeSharp.SwapChain.csproj", "{E7C9247D-016B-4819-AF9F-0E9B3591E04B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputeSharp.SwapChain.Cli", "samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj", "{C12D7ACE-98ED-4813-8118-6667C34F484F}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ComputeSharp.Sample.FSharp", "samples\ComputeSharp.Sample.FSharp\ComputeSharp.Sample.FSharp.fsproj", "{7C625EC4-F599-4350-A915-F046DF2406D3}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Sample.FSharp.Shaders", "samples\ComputeSharp.Sample.FSharp.Shaders\ComputeSharp.Sample.FSharp.Shaders.csproj", "{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}"
|
||||
@@ -362,6 +364,14 @@ Global
|
||||
{669A414F-3B46-4B55-B587-061AF63C3067}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{669A414F-3B46-4B55-B587-061AF63C3067}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{669A414F-3B46-4B55-B587-061AF63C3067}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Debug|x64.Build.0 = Debug|x64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|x64.ActiveCfg = Release|x64
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -396,6 +406,7 @@ Global
|
||||
{5DE90C85-ED26-4B5A-A0D7-2FF966A210AC} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
|
||||
{669A414F-3B46-4B55-B587-061AF63C3067} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
|
||||
{B86A48A7-18BD-4946-B995-3CE26B092DDF} = {1A9C4108-F61A-4ABE-B5CF-F524521EAE2D}
|
||||
{C12D7ACE-98ED-4813-8118-6667C34F484F} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
|
||||
@@ -423,6 +434,7 @@ Global
|
||||
src\ComputeSharp.UI\ComputeSharp.UI.projitems*{afaafdc9-be42-45d4-8c79-0ee8c8edbf52}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{bfb003d1-788b-48de-8065-39479c162cb0}*SharedItemsImports = 5
|
||||
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{bfb003d1-788b-48de-8065-39479c162cb0}*SharedItemsImports = 5
|
||||
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{c12d7ace-98ed-4813-8118-6667c34f484f}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5
|
||||
src\ComputeSharp.D2D1.NetStandard\ComputeSharp.D2D1.NetStandard.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5
|
||||
src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.projitems*{e44053bd-a761-47fb-aa78-087a599672ea}*SharedItemsImports = 5
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
<LangVersion>5.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<!--
|
||||
When running in the CI, set the executable type to be 'Exe', so that a console will
|
||||
be available and the PowerShell test script will be able to await the published app.
|
||||
When not in the CI, use 'WinExe' instead so that the render window will open directly.
|
||||
-->
|
||||
<OutputType Condition="'$(CI_RUNNER_SAMPLES_INTEGRATION_TESTS)' == 'true'">Exe</OutputType>
|
||||
<OutputType Condition="'$(CI_RUNNER_SAMPLES_INTEGRATION_TESTS)' != 'true'">WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<DefineConstants>$(DefineConstants);SAMPLE_APP</DefineConstants>
|
||||
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||
<AssemblyName>computesharp.cli</AssemblyName>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
NativeAOT settings (NativeAOT publishing + reflection-free mode).
|
||||
Note: the COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT environment variable is used to trigger
|
||||
publishing with NativeAOT so that this project won't cause build errors in the CI. This is
|
||||
because NativeAOT doesn't support cross-compiling, but the CI will also build the solution
|
||||
targeting Arm64, from a VM running on x64, which would then fail due to mismatched RIDs.
|
||||
-->
|
||||
<PropertyGroup Condition="'$(COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT)' == 'true'">
|
||||
<PublishAot>true</PublishAot>
|
||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
||||
<IlcDisableReflection>true</IlcDisableReflection>
|
||||
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Application icon -->
|
||||
<ItemGroup>
|
||||
<Content Include="icon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core\ComputeSharp.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Backend\SwapChainApplication{T}.cs" Link="Backend\SwapChainApplication{T}.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Backend\Win32Application.cs" Link="Backend\Win32Application.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Backend\Win32ApplicationRunner.cs" Link="Backend\Win32ApplicationRunner.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems" Label="Shared" />
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using ComputeSharp.SwapChain.Backend;
|
||||
using ComputeSharp.SwapChain.Shaders;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
// Accepted inputs:
|
||||
// - []
|
||||
// - [<SHADER_NAME>]
|
||||
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<HelloWorld>(static time => new((float)time.TotalSeconds)),
|
||||
"colorfulinfinity" => new SwapChainApplication<ColorfulInfinity>(static time => new((float)time.TotalSeconds)),
|
||||
"fractaltiling" => new SwapChainApplication<FractalTiling>(static time => new((float)time.TotalSeconds)),
|
||||
"twotiledtruchet" => new SwapChainApplication<TwoTiledTruchet>(static time => new((float)time.TotalSeconds)),
|
||||
"mengerjourney" => new SwapChainApplication<MengerJourney>(static time => new((float)time.TotalSeconds)),
|
||||
"octagrams" => new SwapChainApplication<Octagrams>(static time => new((float)time.TotalSeconds)),
|
||||
"proteanclouds" => new SwapChainApplication<ProteanClouds>(static time => new((float)time.TotalSeconds)),
|
||||
"extrudedtruchetpattern" => new SwapChainApplication<ExtrudedTruchetPattern>(static time => new((float)time.TotalSeconds)),
|
||||
"pyramidpattern" => new SwapChainApplication<PyramidPattern>(static time => new((float)time.TotalSeconds)),
|
||||
"trianglegridcontouring" => new SwapChainApplication<TriangleGridContouring>(static time => new((float)time.TotalSeconds)),
|
||||
"terracedhills" => new SwapChainApplication<TerracedHills>(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;
|
||||
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 98 KiB |
@@ -287,6 +287,7 @@ internal sealed class SwapChainApplication<T> : Win32Application
|
||||
|
||||
// Execute the command list to perform the copy
|
||||
this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList**)this.d3D12GraphicsCommandList.GetAddressOf());
|
||||
|
||||
_ = this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);
|
||||
|
||||
// Present the new frame
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする