diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs index dd8bffd0..6c727f3f 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs @@ -266,10 +266,14 @@ namespace ComputeSharp.Shaders.Translation fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,>) || fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,>) || fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,,,>))) + fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,,,>)) && + fieldType.GenericTypeArguments.All(type => HlslKnownTypes.IsKnownScalarType(type) || + HlslKnownTypes.IsKnownVectorType(type))) { + // Captured static Func (and available generic type combinations) LoadStaticMethodSource(fieldName, func.Method); } + else throw new InvalidOperationException($"Invalid captured variable \"{fieldName}\" of type {fieldType}"); } ///