From 12f7237e4060388494c549623f4a640327b7ca08 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 14 Nov 2023 17:46:05 -0800 Subject: Add GLSL Compatibility. (#3321) * Parse glsl buffer blocks to GLSLInterfaceBlockDecl * Parse glsl local size layout declarations * Parse (and ignore) glsl version directives * spelling * Better l-value interpretation for glsl interface blocks * Better l-value interpretation for glsl interface blocks * Add compile flag for enabling glsl * Parse and ignore precision modifiers. * Automatically import `glsl` module for compatiblity. * Complete vector and matrix types for glsl * Remove generated file from repo * Bump .gitignore * do not mark out globals as params * Synthesize entrypoint layout from global inout vars. * update test result. * Allow HLSL semantic on global variables. * Fix. * Fix test. * Fix win32 compile error. * Add more builtin input/output and texture intrinsics. * Add struct/array constructor syntax. * Skip `#extension` lines. * overide operator * for matrix/vector multiplication. * Add `matrixCompMult`. * Parse modifiers in for loop init var declr. * Add more glsl intrinsics, add stage into to var layout. * Allow `int[3] x` syntax. * Fix array type syntax. --------- Co-authored-by: Ellie Hermaszewska Co-authored-by: Yong He --- source/slang/slang-check-overload.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-check-overload.cpp') diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 27062fc0c..2d7315cd2 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -2005,13 +2005,25 @@ namespace Slang typeCheckingCache->resolvedOperatorOverloadCache[key] = *context.bestCandidate; return CompleteOverloadCandidate(context, *context.bestCandidate); } - else + else if (auto typetype = as(funcExprType)) { - // Nothing at all was found that we could even consider invoking - getSink()->diagnose(expr->functionExpr, Diagnostics::expectedFunction, funcExprType); - expr->type = QualType(m_astBuilder->getErrorType()); - return expr; - } + // We allow a special case when `funcExpr` represents a composite type, + // in which case we will try to construct the type via memberwise assignment from the arguments. + // + auto initListExpr = m_astBuilder->create(); + initListExpr->loc = expr->loc; + initListExpr->args.addRange(expr->arguments); + initListExpr->type = m_astBuilder->getInitializerListType(); + Expr* outExpr = nullptr; + if (_coerceInitializerList(typetype->getType(), &outExpr, initListExpr)) + return outExpr; + } + + // Nothing at all was found that we could even consider invoking. + // In all other cases, this is an error. + getSink()->diagnose(expr->functionExpr, Diagnostics::expectedFunction, funcExprType); + expr->type = QualType(m_astBuilder->getErrorType()); + return expr; } void SemanticsVisitor::AddGenericOverloadCandidate( -- cgit v1.2.3