Move code to new ComputeSharp.D2D1Interop project
このコミットが含まれているのは:
1 親
ae6d68d7a1
コミット
d605b345df
14ファイル変更
+167
-18
検索条件に一致するファイルはありません
@@ -75,6 +75,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Dynamic", "src
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "TerraFX.Interop.Windows.Dynamic", "src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.shproj", "{158F984D-CD96-4062-BD02-2268946031A0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1Interop", "src\ComputeSharp.D2D1Interop\ComputeSharp.D2D1Interop.csproj", "{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5
|
||||
@@ -337,6 +339,18 @@ Global
|
||||
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|x64.ActiveCfg = Release|x64
|
||||
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|x64.Build.0 = Release|x64
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -361,6 +375,7 @@ Global
|
||||
{751BB05B-563D-4B3A-94C6-15E2D79D35EA} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
|
||||
{4A8FCE22-851C-442A-8BC9-3EC3FD00B637} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
|
||||
{158F984D-CD96-4062-BD02-2268946031A0} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA}
|
||||
{6892B4F9-163D-4F08-9910-114C2A3B986F} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DocumentationFile>ComputeSharp.D2D1Interop.xml</DocumentationFile>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Enable trimming support on .NET 6 -->
|
||||
<PropertyGroup>
|
||||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Helper methods for working with the <see cref="ComPtr{T}"/> type.
|
||||
/// </summary>
|
||||
/// <remarks>Trimmed down version of the same file in <c>ComputeSharp</c>.</remarks>
|
||||
internal static class ComPtrExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Moves the current <see cref="ComPtr{T}"/> instance and resets it without releasing the reference.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to wrap in the current <see cref="ComPtr{T}"/> instance.</typeparam>
|
||||
/// <param name="ptr">The input <see cref="ComPtr{T}"/> instance to move.</param>
|
||||
/// <returns>The moved <see cref="ComPtr{T}"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ComPtr<T> Move<T>(this in ComPtr<T> ptr)
|
||||
where T : unmanaged, IUnknown.Interface
|
||||
{
|
||||
ComPtr<T> copy = default;
|
||||
|
||||
Unsafe.AsRef(in ptr).Swap(ref copy);
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Helper methods to efficiently throw exceptions.
|
||||
/// </summary>
|
||||
/// <remarks>Trimmed down version of the same file in <c>ComputeSharp</c>.</remarks>
|
||||
[DebuggerStepThrough]
|
||||
internal static class HResultExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/> if <paramref name="result"/> represents an error.
|
||||
/// </summary>
|
||||
/// <param name="result">The input <see cref="HRESULT"/> to check.</param>
|
||||
/// <exception cref="Win32Exception">Thrown if <paramref name="result"/> represents an error.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Assert(this HRESULT result)
|
||||
{
|
||||
if ((int)result < 0)
|
||||
{
|
||||
ThrowWin32Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/> if <paramref name="result"/> represents an error.
|
||||
/// </summary>
|
||||
/// <param name="result">The input <see cref="int"/> to check.</param>
|
||||
/// <exception cref="Win32Exception">Thrown if <paramref name="result"/> represents an error.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Assert(this int result)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
ThrowWin32Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws a <see cref="Win32Exception"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The input return code.</param>
|
||||
[DoesNotReturn]
|
||||
private static void ThrowWin32Exception(int result)
|
||||
{
|
||||
throw new Win32Exception(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="Exception"/> type that indicates when a shader compilation with the FXC compiler has failed.
|
||||
/// </summary>
|
||||
public sealed class FxcCompilationException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FxcCompilationException"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="error">The error message produced by the DXC compiler.</param>
|
||||
internal FxcCompilationException(string error)
|
||||
: base(GetExceptionMessage(error))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a formatted exception message for a given compilation error.
|
||||
/// </summary>
|
||||
/// <param name="error">The input compilatin error message from the FXC compiler.</param>
|
||||
/// <returns>A formatted error message for a new <see cref="FxcCompilationException"/> instance.</returns>
|
||||
private static string GetExceptionMessage(string error)
|
||||
{
|
||||
StringBuilder builder = new(512);
|
||||
|
||||
builder.AppendLine("The FXC compiler encountered one or more errors while trying to compile the shader:");
|
||||
builder.AppendLine();
|
||||
builder.AppendLine(error.Trim());
|
||||
builder.AppendLine();
|
||||
builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp.");
|
||||
builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message.");
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -3,17 +3,14 @@ using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.D2D1Interop.Exceptions;
|
||||
using ComputeSharp.D2D1Interop.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using DirectX = TerraFX.Interop.DirectX.DirectX2;
|
||||
#endif
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
|
||||
namespace ComputeSharp.Shaders.Translation;
|
||||
namespace ComputeSharp.D2D1Interop.Shaders.Translation;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that uses the FXC APIs to compile D2D1 pixel shaders.
|
||||
@@ -212,7 +209,7 @@ internal static unsafe class D2D1ShaderCompiler
|
||||
{
|
||||
string message = new((sbyte*)d3DOperationResult->GetBufferPointer());
|
||||
|
||||
throw new HlslCompilationException(message);
|
||||
throw new FxcCompilationException(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -12,7 +12,7 @@
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Referece to the main non-dynamic library-->
|
||||
<!-- Reference to the main non-dynamic library-->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputeSharp\ComputeSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
+4
-4
@@ -6,13 +6,13 @@ namespace ComputeSharp.Exceptions;
|
||||
/// <summary>
|
||||
/// A custom <see cref="Exception"/> type that indicates when a shader compilation with the DXC compiler has failed.
|
||||
/// </summary>
|
||||
public sealed class HlslCompilationException : Exception
|
||||
public sealed class DxcCompilationException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslCompilationException"/> instance.
|
||||
/// Creates a new <see cref="DxcCompilationException"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="error">The error message produced by the DXC compiler.</param>
|
||||
internal HlslCompilationException(string error)
|
||||
internal DxcCompilationException(string error)
|
||||
: base(GetExceptionMessage(error))
|
||||
{
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public sealed class HlslCompilationException : Exception
|
||||
/// Gets a formatted exception message for a given compilation error.
|
||||
/// </summary>
|
||||
/// <param name="error">The input compilatin error message from the DXC compiler.</param>
|
||||
/// <returns>A formatted error message for a new <see cref="HlslCompilationException"/> instance.</returns>
|
||||
/// <returns>A formatted error message for a new <see cref="DxcCompilationException"/> instance.</returns>
|
||||
private static string GetExceptionMessage(string error)
|
||||
{
|
||||
StringBuilder builder = new(512);
|
||||
@@ -151,6 +151,6 @@ internal sealed unsafe partial class ShaderCompiler
|
||||
|
||||
string message = new((sbyte*)dxcBlobEncodingError.Get()->GetBufferPointer());
|
||||
|
||||
throw new HlslCompilationException(message);
|
||||
throw new DxcCompilationException(message);
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@
|
||||
<Compile Include="..\ComputeSharp\Core\Primitives\UInt\UIntMxN.g.cs" Link="ComputeSharp\Core\Primitives\UInt\UIntMxN.g.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Primitives\MatrixIndex.cs" Link="ComputeSharp\Core\Primitives\MatrixIndex.cs" />
|
||||
<Compile Include="..\ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" Link="ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Exceptions\HlslCompilationException.cs" Link="ComputeSharp\Shaders\Exceptions\HlslCompilationException.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Exceptions\DxcCompilationException.cs" Link="ComputeSharp\Shaders\Exceptions\DxcCompilationException.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Translation\ShaderCompiler.cs" Link="ComputeSharp\Shaders\Translation\ShaderCompiler.cs" />
|
||||
<Compile Include="..\ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" Link="ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -639,7 +639,7 @@ internal static class DiagnosticDescriptors
|
||||
/// Format: <c>"The shader of type {{0}} failed to compile due to an HLSL compiler error (Message: "{1}")"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithHlslCompilationException = new DiagnosticDescriptor(
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithDxcCompilationException = new DiagnosticDescriptor(
|
||||
id: "CMPS0046",
|
||||
title: "Embedded bytecode compilation failed due to an HLSL compiler error",
|
||||
messageFormat: "The shader of type {0} failed to compile due to an HLSL compiler error (Message: \"{1}\")",
|
||||
|
||||
@@ -188,9 +188,9 @@ public sealed partial class IShaderGenerator
|
||||
{
|
||||
diagnostic = new DiagnosticInfo(EmbeddedBytecodeFailedWithWin32Exception, e.HResult, e.Message);
|
||||
}
|
||||
catch (HlslCompilationException e)
|
||||
catch (DxcCompilationException e)
|
||||
{
|
||||
diagnostic = new DiagnosticInfo(EmbeddedBytecodeFailedWithHlslCompilationException, e.Message);
|
||||
diagnostic = new DiagnosticInfo(EmbeddedBytecodeFailedWithDxcCompilationException, e.Message);
|
||||
}
|
||||
|
||||
End:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[module: SkipLocalsInit]
|
||||
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.Dynamic")]
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.D2D1Interop")]
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.Uwp")]
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.WinUI")]
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ShaderCompilerTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(HlslCompilationException))]
|
||||
[ExpectedException(typeof(DxcCompilationException))]
|
||||
public void CompileTest_Fail()
|
||||
{
|
||||
var faultyShader = ShaderSource.Replace("ids.x", "ids.X");
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする