diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs
index 50639df8..9ba4c22e 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs
@@ -32,12 +32,14 @@ partial class ID2D1ShaderGenerator
/// The input object currently in use.
/// The node to process.
/// The for .
+ /// The number of inputs for the shader.
/// The resulting diagnostics from the processing operation.
/// The HLSL source for the shader.
public static string GetHlslSource(
Compilation compilation,
StructDeclarationSyntax structDeclaration,
INamedTypeSymbol structDeclarationSymbol,
+ out int inputCount,
out ImmutableArray diagnostics)
{
ImmutableArray.Builder builder = ImmutableArray.CreateBuilder();
@@ -62,7 +64,7 @@ partial class ID2D1ShaderGenerator
GatherD2D1AttributeInfo(
builder,
structDeclarationSymbol,
- out int inputCount,
+ out inputCount,
out ImmutableArray inputSimpleIndices,
out ImmutableArray 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 inputSimpleIndicesAsSet = new(inputSimpleIndicesBuilder);
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs
index 797a7e72..f616dd12 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.cs
@@ -43,16 +43,11 @@ partial class ID2D1ShaderGenerator
/// Extracts the metadata definition for the current shader.
///
/// The input instance to process.
+ /// The number of inputs for the shader.
/// Whether the shader only has simple inputs.
- 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())
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
index 5679afbd..62b802d5 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
@@ -71,14 +71,15 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
item.Right,
item.Left.Syntax,
item.Left.Symbol,
+ out int inputCount,
out ImmutableArray 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,