From 645c0f4e911e95d143330eaf76179146f07dbbfa Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 7 Jan 2024 21:07:19 +0100 Subject: [PATCH] Reorder steps in the DX12 generator --- .../ComputeShaderDescriptorGenerator.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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);