Add build configuration with no runtime compilation

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-06 17:43:44 +01:00
1 親 0f6ae572cd
コミット 879330d9aa
10ファイル変更
+75 -6

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

+22 -2
ファイルの表示
@@ -44,10 +44,30 @@ jobs:
run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64
shell: cmd
# Build the whole ComputeSharp solution with /p:DisableShaderCompilationSupport=True
build-solution-release-no-dynamic:
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Setup .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Build
run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64 /p:DisableShaderCompilationSupport=True
shell: cmd
# Run all the unit tests referencing the ComputeSharp project directly
run-tests:
if: success()
needs: [build-solution-debug, build-solution-release]
needs: [build-solution-debug, build-solution-release, build-solution-release-no-dynamic]
runs-on: windows-2022
steps:
- name: Git checkout
@@ -151,7 +171,7 @@ jobs:
# This workflow also uploads the resulting package as an artifact.
build-package:
if: success()
needs: [build-solution-debug, build-solution-release]
needs: [build-solution-debug, build-solution-release, build-solution-release-no-dynamic]
runs-on: windows-2022
steps:
- name: Git checkout
+1 -1
ファイルの表示
@@ -8,7 +8,7 @@
</PropertyGroup>
<PropertyGroup>
<DefineConstants>SOURCE_GENERATOR</DefineConstants>
<DefineConstants>$(DefineConstants);SOURCE_GENERATOR</DefineConstants>
</PropertyGroup>
<!--The source generator cannot contain package references or project references, so instead we're just
+9
ファイルの表示
@@ -5,6 +5,7 @@
<DocumentationFile>ComputeSharp.xml</DocumentationFile>
<Description>ComputeSharp</Description>
<Platforms>AnyCPU;x64;ARM64</Platforms>
<DisableShaderCompilationSupport>false</DisableShaderCompilationSupport>
</PropertyGroup>
<ItemGroup>
@@ -37,8 +38,16 @@
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<Choose>
<!-- Skip bundling any native library if support is disabled -->
<When Condition="'$(DisableShaderCompilationSupport)' == 'true'"/>
<!-- When building locally for x64/ARM64 (using the project through a project reference),
just copy the right native libraries to the output directory, with no subfolders. -->
<When Condition="'$(Platform)' == 'x64'">
+14
ファイルの表示
@@ -1,10 +1,18 @@
using System;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System.Runtime.CompilerServices;
#endif
using ComputeSharp.__Internals;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using ComputeSharp.Core.Extensions;
using ComputeSharp.Shaders.Translation;
#else
using Microsoft.Toolkit.Diagnostics;
#endif
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#endif
#pragma warning disable CS0618
@@ -102,6 +110,11 @@ public static class ReflectionServices
private static unsafe void GetNonGenericShaderInfo<T>(in T shader, out ShaderInfo shaderInfo)
where T : struct, IShader
{
#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
shaderInfo = default;
#else
Unsafe.AsRef(in shader).BuildHlslString(out ArrayPoolStringBuilder shaderSource, 1, 1, 1);
using ComPtr<IDxcBlob> dxcBlobBytecode = ShaderCompiler.Instance.CompileShader(shaderSource.WrittenSpan);
@@ -155,5 +168,6 @@ public static class ReflectionServices
Unsafe.AsRef(shaderInfo.MovcInstructionCount) = d3D12ShaderReflection.Get()->GetMovcInstructionCount();
Unsafe.AsRef(shaderInfo.MovInstructionCount) = d3D12ShaderReflection.Get()->GetMovInstructionCount();
Unsafe.AsRef(shaderInfo.InterfaceSlotCount) = d3D12ShaderReflection.Get()->GetNumInterfaceSlots();
#endif
}
}
+8
ファイルの表示
@@ -4,7 +4,9 @@ using System.Runtime.CompilerServices;
using ComputeSharp.Graphics.Commands;
using ComputeSharp.Shaders.Dispatching;
using ComputeSharp.Shaders.Extensions;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using ComputeSharp.Shaders.Translation;
#endif
using ComputeSharp.Shaders.Translation.Models;
using ComputeSharp.__Internals;
using Microsoft.Toolkit.Diagnostics;
@@ -232,6 +234,11 @@ internal static class ShaderRunner<T>
}
else
{
#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
shaderData = null!;
#else
shader.BuildHlslString(out ArrayPoolStringBuilder builder, threadsX, threadsY, threadsZ);
using ComPtr<IDxcBlob> dxcBlobBytecode = ShaderCompiler.Instance.CompileShader(builder.WrittenSpan);
@@ -239,6 +246,7 @@ internal static class ShaderRunner<T>
builder.Dispose();
shaderData = new ICachedShader.Dynamic(dxcBlobBytecode.Get());
#endif
}
}
+1 -1
ファイルの表示
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT && NET6_0_OR_GREATER
using System;
using System.IO;
+5 -1
ファイルの表示
@@ -1,4 +1,6 @@
using System;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Extensions;
@@ -153,3 +155,5 @@ internal sealed unsafe partial class ShaderCompiler
throw new HlslCompilationException(message);
}
}
#endif
+4
ファイルの表示
@@ -3,6 +3,8 @@
// Ported from um/dxcapi.h in the Windows SDK for Windows 10.0.20348.0
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the University of Illinois Open Source License.
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using System.Runtime.InteropServices;
using TerraFX.Interop.Windows;
@@ -15,3 +17,5 @@ namespace TerraFX.Interop.DirectX
public static extern HRESULT DxcCreateInstance([NativeTypeName("const IID &")] Guid* rclsid, [NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("LPVOID *")] void** ppv);
}
}
#endif
+6
ファイルの表示
@@ -4,6 +4,12 @@
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU;x64;ARM64</Platforms>
<DisableShaderCompilationSupport>false</DisableShaderCompilationSupport>
</PropertyGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<ItemGroup>
+5 -1
ファイルの表示
@@ -1,4 +1,6 @@
using System;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using ComputeSharp.Exceptions;
using ComputeSharp.Shaders.Translation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -45,3 +47,5 @@ public class ShaderCompilerTests
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader.AsSpan());
}
}
#endif