Add HlslBytecodeSyntaxProcessor shared helper type
このコミットが含まれているのは:
1 親
ef821be2b2
コミット
2a519c3f51
11ファイル変更
+284
-22
検索条件に一致するファイルはありません
@@ -1,6 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<DefineConstants>$(DefineConstants);D2D1_SOURCE_GENERATOR</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
+3
-3
@@ -265,7 +265,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
else if (info is HlslBytecodeInfo.CompilerError fxcError)
|
||||
{
|
||||
diagnostic = DiagnosticInfo.Create(
|
||||
HlslBytecodeFailedWithFxcCompilationException,
|
||||
HlslBytecodeFailedWithCompilationException,
|
||||
structDeclarationSymbol,
|
||||
structDeclarationSymbol,
|
||||
fxcError.Message);
|
||||
@@ -304,14 +304,14 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
if (!hasD2DRequiresDoublePrecisionSupportAttribute && success.RequiresDoublePrecisionSupport)
|
||||
{
|
||||
diagnostics.Add(DiagnosticInfo.Create(
|
||||
MissingD2DRequiresDoublePrecisionSupportAttribute,
|
||||
MissingRequiresDoublePrecisionSupportAttribute,
|
||||
structDeclarationSymbol,
|
||||
structDeclarationSymbol));
|
||||
}
|
||||
else if (hasD2DRequiresDoublePrecisionSupportAttribute && !success.RequiresDoublePrecisionSupport)
|
||||
{
|
||||
diagnostics.Add(DiagnosticInfo.Create(
|
||||
UnnecessaryD2DRequiresDoublePrecisionSupportAttribute,
|
||||
UnnecessaryRequiresDoublePrecisionSupportAttribute,
|
||||
attributeData!.GetLocation(),
|
||||
structDeclarationSymbol));
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ partial 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 HlslBytecodeFailedWithFxcCompilationException = new(
|
||||
public static readonly DiagnosticDescriptor HlslBytecodeFailedWithCompilationException = new(
|
||||
id: "CMPSD2D0034",
|
||||
title: "HLSL 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}")""",
|
||||
@@ -1197,7 +1197,7 @@ partial class DiagnosticDescriptors
|
||||
/// Format: <c>"The shader {0} requires double precision support, but it does not have the [D2DRequiresDoublePrecisionSupport] attribute on it (adding the attribute is necessary to explicitly opt-in to that functionality)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor MissingD2DRequiresDoublePrecisionSupportAttribute = new(
|
||||
public static readonly DiagnosticDescriptor MissingRequiresDoublePrecisionSupportAttribute = new(
|
||||
id: "CMPSD2D0080",
|
||||
title: "Missing [D2DRequiresDoublePrecisionSupport] attribute",
|
||||
messageFormat: "The shader {0} requires double precision support, but it does not have the [D2DRequiresDoublePrecisionSupport] attribute on it (adding the attribute is necessary to explicitly opt-in to that functionality)",
|
||||
@@ -1213,7 +1213,7 @@ partial class DiagnosticDescriptors
|
||||
/// Format: <c>"The shader {0} does not require double precision support, but it has the [D2DRequiresDoublePrecisionSupport] attribute on it (using the attribute is not needed if the shader is not performing any double precision operations)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor UnnecessaryD2DRequiresDoublePrecisionSupportAttribute = new(
|
||||
public static readonly DiagnosticDescriptor UnnecessaryRequiresDoublePrecisionSupportAttribute = new(
|
||||
id: "CMPSD2D0081",
|
||||
title: "Unnecessary [D2DRequiresDoublePrecisionSupport] attribute",
|
||||
messageFormat: "The shader {0} does not require double precision support, but it has the [D2DRequiresDoublePrecisionSupport] attribute on it (using the attribute is not needed if the shader is not performing any double precision operations)",
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using ComputeSharp.D2D1.Shaders.Translation;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Graphics.Direct3D;
|
||||
|
||||
namespace ComputeSharp.SourceGeneration.SyntaxProcessors;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class HlslBytecodeSyntaxProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the attribute to enable double precision support.
|
||||
/// </summary>
|
||||
private const string RequiresDoublePrecisionSupportAttributeName = "ComputeSharp.D2D1.D2DRequiresDoublePrecisionSupportAttribute";
|
||||
|
||||
/// <inheritdoc/>
|
||||
private static partial ComPtr<ID3DBlob> Compile(HlslBytecodeInfoKey key, CancellationToken token)
|
||||
{
|
||||
return D3DCompiler.Compile(
|
||||
key.HlslSource.AsSpan(),
|
||||
key.ShaderProfile,
|
||||
key.CompileOptions,
|
||||
token);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
private static unsafe partial bool IsDoublePrecisionSupportRequired(ID3DBlob* d3DBlob)
|
||||
{
|
||||
return D3DCompiler.IsDoublePrecisionSupportRequired(d3DBlob);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
private static partial string FixupErrorMessage(string message)
|
||||
{
|
||||
return D3DCompiler.PrettifyFxcErrorMessage(message);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする