From 2c44c8fdbdc443c244a210f3a2ac7d204b6e6e20 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 5 Sep 2019 14:47:01 +0200 Subject: [PATCH] Added support for all types of delegates with a return type --- .../Translation/ShaderLoader.cs | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs index 4c20e6b7..16803a60 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs @@ -249,28 +249,11 @@ namespace ComputeSharp.Shaders.Translation else if (fieldType.IsClass && fieldType.IsGenericType && fieldType.IsSubclassOf(typeof(Delegate)) && memberInfo.GetValue(Action.Target) is Delegate func && func.Method.IsStatic && - fieldType.GetGenericTypeDefinition() is Type fieldTypeDefinition && ( - fieldTypeDefinition == typeof(Func<>) || - fieldTypeDefinition == typeof(Func<,>) || - fieldTypeDefinition == typeof(Func<,,>) || - fieldTypeDefinition == typeof(Func<,,,>) || - fieldTypeDefinition == typeof(Func<,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,,>) || - fieldTypeDefinition == typeof(Func<,,,,,,,,,,,,,,,,>)) && + (HlslKnownTypes.IsKnownScalarType(func.Method.ReturnType) || HlslKnownTypes.IsKnownVectorType(func.Method.ReturnType)) && fieldType.GenericTypeArguments.All(type => HlslKnownTypes.IsKnownScalarType(type) || HlslKnownTypes.IsKnownVectorType(type))) { - // Captured static Func (and available generic type combinations) + // Captured static delegates with a return type LoadStaticMethodSource(fieldName, func.Method); } }