diff --git a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs index d8e3b9b6..9fbceeb7 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.cs @@ -59,8 +59,6 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener return default; } - using ImmutableArrayBuilder diagnostics = new(); - // Get the fields info ConstantBuffer.GetInfo( context.SemanticModel.Compilation, @@ -81,6 +79,13 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener token.ThrowIfCancellationRequested(); + // Get the compile options as well + CompileOptions compileOptions = HlslBytecode.GetCompileOptions(typeSymbol); + + token.ThrowIfCancellationRequested(); + + using ImmutableArrayBuilder diagnostics = new(); + // Transpiled HLSL source info HlslSource.GetInfo( diagnostics, @@ -96,7 +101,7 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener token.ThrowIfCancellationRequested(); - // Get the resources info + // Get the resources info (we must do this after crawling the HLSL source) Resources.GetInfo( context.SemanticModel.Compilation, typeSymbol, @@ -106,11 +111,6 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener token.ThrowIfCancellationRequested(); - // Get the compile options as well - CompileOptions compileOptions = HlslBytecode.GetCompileOptions(typeSymbol); - - token.ThrowIfCancellationRequested(); - // Prepare the lookup key for the HLSL shader bytecode HlslBytecodeInfoKey hlslInfoKey = new(hlslSource, compileOptions, isCompilationEnabled);