diff --git a/src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs b/src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs index b82df4d0..40ebf95d 100644 --- a/src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/AutoConstructorGenerator.cs @@ -42,12 +42,11 @@ namespace ComputeSharp.SourceGenerators var structName = structDeclaration.Identifier.Text; var structModifiers = structDeclaration.Modifiers; var fields = ( - from fieldDeclaration in structDeclaration.Members.OfType() - let fieldType = fieldDeclaration.Declaration.Type - let typeName = semanticModel.GetTypeInfo(fieldType).Type!.ToDisplayString() + from fieldSymbol in structDeclarationSymbol.GetMembers().OfType() + where !fieldSymbol.IsConst + let typeName = fieldSymbol.Type!.ToDisplayString() let fieldFullType = ParseTypeName(typeName) - from fieldVariable in fieldDeclaration.Declaration.Variables - select (Type: fieldFullType, fieldVariable.Identifier)).ToImmutableArray(); + select (Type: fieldFullType, Identifier: Identifier(fieldSymbol.Name))).ToImmutableArray(); // Create the constructor declaration for the type. This will // produce a constructor with simple initialization of all variables: diff --git a/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs index 1d1e59ec..2922aa8a 100644 --- a/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs @@ -141,6 +141,8 @@ namespace ComputeSharp.SourceGenerators } else if (HlslKnownTypes.IsScalarOrVectorType(typeName)) { + if (fieldSymbol.IsConst) continue; + var (fieldSize, fieldPack) = HlslKnownSizes.GetTypeInfo(typeName); // Calculate the right offset with 16-bytes padding (HLSL constant buffer).