Fix D2D1 generator error when checking for simple inputs

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:04:33 +02:00
1 親 e1d823a833
コミット f7612b587e
3ファイル変更
+9 -9

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

@@ -32,12 +32,14 @@ partial class ID2D1ShaderGenerator
/// <param name="compilation">The input <see cref="Compilation"/> object currently in use.</param>
/// <param name="structDeclaration">The <see cref="StructDeclarationSyntax"/> node to process.</param>
/// <param name="structDeclarationSymbol">The <see cref="INamedTypeSymbol"/> for <paramref name="structDeclaration"/>.</param>
/// <param name="inputCount">The number of inputs for the shader.</param>
/// <param name="diagnostics">The resulting diagnostics from the processing operation.</param>
/// <returns>The HLSL source for the shader.</returns>
public static string GetHlslSource(
Compilation compilation,
StructDeclarationSyntax structDeclaration,
INamedTypeSymbol structDeclarationSymbol,
out int inputCount,
out ImmutableArray<Diagnostic> diagnostics)
{
ImmutableArray<Diagnostic>.Builder builder = ImmutableArray.CreateBuilder<Diagnostic>();
@@ -62,7 +64,7 @@ partial class ID2D1ShaderGenerator
GatherD2D1AttributeInfo(
builder,
structDeclarationSymbol,
out int inputCount,
out inputCount,
out ImmutableArray<int> inputSimpleIndices,
out ImmutableArray<int> inputComplexIndices,
out bool requiresScenePosition);
@@ -428,6 +430,8 @@ partial class ID2D1ShaderGenerator
if (inputSimpleIndicesBuilder.Concat(inputComplexIndicesBuilder).Any(i => (uint)i >= rawInputCount))
{
diagnostics.Add(OutOfRangeInputIndex, structDeclarationSymbol, structDeclarationSymbol);
return;
}
HashSet<int> inputSimpleIndicesAsSet = new(inputSimpleIndicesBuilder);
@@ -43,16 +43,11 @@ partial class ID2D1ShaderGenerator
/// Extracts the metadata definition for the current shader.
/// </summary>
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
/// <param name="inputCount">The number of inputs for the shader.</param>
/// <returns>Whether the shader only has simple inputs.</returns>
public static bool IsSimpleInputShader(INamedTypeSymbol structDeclarationSymbol)
public static bool IsSimpleInputShader(INamedTypeSymbol structDeclarationSymbol, int inputCount)
{
if (!structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DInputCountAttribute", out AttributeData? inputCountAttribute))
{
return false;
}
// Build a map of all simple inputs (unmarked inputs default to being complex)
int inputCount = (int)inputCountAttribute!.ConstructorArguments[0].Value!;
bool[] simpleInputsMap = new bool[inputCount];
foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes())
+2 -1
ファイルの表示
@@ -71,14 +71,15 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
item.Right,
item.Left.Syntax,
item.Left.Symbol,
out int inputCount,
out ImmutableArray<Diagnostic> hlslSourceDiagnostics);
token.ThrowIfCancellationRequested();
// Get the shader profile and linking info for LoadBytecode()
D2D1ShaderProfile? shaderProfile = LoadBytecode.GetShaderProfile(item.Left.Symbol);
bool isLinkingSupported = LoadBytecode.IsSimpleInputShader(item.Left.Symbol);
bool hasErrors = !dispatchDataDiagnostics.IsDefaultOrEmpty || !hlslSourceDiagnostics.IsDefaultOrEmpty;
bool isLinkingSupported = !hasErrors && LoadBytecode.IsSimpleInputShader(item.Left.Symbol, inputCount);
HlslShaderSourceInfo sourceInfo = new(
hlslSource,