Share HlslBytecodeInfo model across D3D12/D2D1 generators

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-14 00:35:04 +02:00
1 親 fa8d9446cd
コミット 2c8d0d2385
8ファイル変更
+11 -47

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

@@ -2,6 +2,7 @@ using System.Linq;
using ComputeSharp.D2D1.SourceGenerators.Models;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using ComputeSharp.SourceGeneration.Models;
using Microsoft.CodeAnalysis;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -188,7 +188,7 @@ partial class D2DPixelShaderDescriptorGenerator
}
catch (FxcCompilationException e)
{
return new HlslBytecodeInfo.FxcError(D3DCompiler.PrettifyFxcErrorMessage(e.Message));
return new HlslBytecodeInfo.CompilerError(D3DCompiler.PrettifyFxcErrorMessage(e.Message));
}
}
@@ -218,7 +218,7 @@ partial class D2DPixelShaderDescriptorGenerator
structDeclarationSymbol,
new object[] { structDeclarationSymbol, win32Error.HResult, win32Error.Message });
}
else if (info is HlslBytecodeInfo.FxcError fxcError)
else if (info is HlslBytecodeInfo.CompilerError fxcError)
{
diagnostic = DiagnosticInfo.Create(
EmbeddedBytecodeFailedWithFxcCompilationException,
+1 -1
ファイルの表示
@@ -142,7 +142,7 @@ partial class D2DPixelShaderSourceGenerator
methodSymbol,
new object[] { methodSymbol, methodSymbol.ContainingType, win32Error.HResult, win32Error.Message });
}
else if (info is HlslBytecodeInfo.FxcError fxcError)
else if (info is HlslBytecodeInfo.CompilerError fxcError)
{
diagnostic = DiagnosticInfo.Create(
D2DPixelShaderSourceCompilationFailedWithFxcCompilationException,
-39
ファイルの表示
@@ -1,39 +0,0 @@
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <summary>
/// A model representing info on compiled HLSL bytecode, if available.
/// </summary>
internal abstract record HlslBytecodeInfo
{
/// <summary>
/// A successfully compiled HLSL shader.
/// </summary>
/// <param name="Bytecode">The resulting HLSL bytecode.</param>
public sealed record Success(EquatableArray<byte> Bytecode) : HlslBytecodeInfo;
/// <summary>
/// An HLSL shader that failed to compile due to a Win32 error.
/// </summary>
/// <param name="HResult">The HRESULT for the error.</param>
/// <param name="Message">The error message from compiling the shader.</param>
public sealed record Win32Error(int HResult, string Message) : HlslBytecodeInfo;
/// <summary>
/// An HLSL shader that failed to compile due to an FXC compiler error.
/// </summary>
/// <param name="Message">The error message from compiling the shader.</param>
public sealed record FxcError(string Message) : HlslBytecodeInfo;
/// <summary>
/// No HLSL bytecode is available (ie. compilation was not requested or some other error was detected).
/// </summary>
public sealed record Missing : HlslBytecodeInfo
{
/// <summary>
/// Gets the shared <see cref="Missing"/> instance.
/// </summary>
public static Missing Instance { get; } = new();
}
}
@@ -21,6 +21,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownProperties.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownSizes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\HlslBytecodeInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.Diagnostics.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\ShaderSourceRewriter.cs" />
@@ -1,6 +1,6 @@
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.SourceGenerators.Models;
namespace ComputeSharp.SourceGeneration.Models;
/// <summary>
/// A model representing info on compiled HLSL bytecode, if available.
@@ -21,10 +21,10 @@ internal abstract record HlslBytecodeInfo
public sealed record Win32Error(int HResult, string Message) : HlslBytecodeInfo;
/// <summary>
/// An HLSL shader that failed to compile due to an DXC compiler error.
/// An HLSL shader that failed to compile due to a compiler error.
/// </summary>
/// <param name="Message">The error message from compiling the shader.</param>
public sealed record DxcError(string Message) : HlslBytecodeInfo;
public sealed record CompilerError(string Message) : HlslBytecodeInfo;
/// <summary>
/// No HLSL bytecode is available (ie. compilation was not requested or some other error was detected).
@@ -1,5 +1,6 @@
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using ComputeSharp.SourceGeneration.Models;
using ComputeSharp.SourceGenerators.Models;
namespace ComputeSharp.SourceGenerators;
+2 -2
ファイルの表示
@@ -160,7 +160,7 @@ partial class IShaderGenerator
}
catch (DxcCompilationException e)
{
return new HlslBytecodeInfo.DxcError(FixupExceptionMessage(e.Message));
return new HlslBytecodeInfo.CompilerError(FixupExceptionMessage(e.Message));
}
}
@@ -184,7 +184,7 @@ partial class IShaderGenerator
structDeclarationSymbol,
new object[] { structDeclarationSymbol, win32Error.HResult, win32Error.Message });
}
else if (info is HlslBytecodeInfo.DxcError dxcError)
else if (info is HlslBytecodeInfo.CompilerError dxcError)
{
diagnostic = DiagnosticInfo.Create(
EmbeddedBytecodeFailedWithDxcCompilationException,