diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index af0b139b..9fef8219 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -67,6 +67,7 @@ internal static partial class HlslKnownTypes Dictionary knownTypes = new() { [typeof(bool).FullName] = "bool", + [typeof(Bool).FullName] = "bool", [typeof(int).FullName] = "int", [typeof(uint).FullName] = "uint", [typeof(float).FullName] = "float", @@ -256,6 +257,15 @@ internal static partial class HlslKnownTypes // Explore all input types and their nested types foreach (INamedTypeSymbol type in discoveredTypes) { + // Special case for bool types. These types are blocked if they appear as fields in custom struct types, + // but are otherwise allowed. For instance, it is fine to use them in captured values for a shader (as + // the dispatch data loader will perform the correct marshalling) as well as in locals/parameters. This + // branch prevents crawling a processed type if it's just bool at the top level (ie. not a custom struct). + if (type.SpecialType == SpecialType.System_Boolean) + { + continue; + } + ExploreTypes(type, customTypes, invalidTypes2); }