From af70651a4843b16dd24e14b5cedffe399ebeb862 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sat, 20 Aug 2022 01:03:06 -0700 Subject: Call `gfx` in slang program. (#2370) --- source/slang/slang-lower-to-ir.cpp | 50 +++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 1f3da064a..1285afca8 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1185,6 +1185,31 @@ static void addLinkageDecoration( addLinkageDecoration(context, inst, decl, mangledName.getUnownedSlice()); } +bool shouldDeclBeTreatedAsInterfaceRequirement(Decl* requirementDecl) +{ + if (auto funcDecl = as(requirementDecl)) + { + } + else if (auto propertyDecl = as(requirementDecl)) + { + } + else if (auto assocTypeDecl = as(requirementDecl)) + { + } + else if (auto typeConstraint = as(requirementDecl)) + { + } + else if (auto genericDecl = as(requirementDecl)) + { + return shouldDeclBeTreatedAsInterfaceRequirement(genericDecl->inner); + } + else + { + return false; + } + return true; +} + IRStructKey* getInterfaceRequirementKey( IRGenContext* context, Decl* requirementDecl) @@ -1195,6 +1220,12 @@ IRStructKey* getInterfaceRequirementKey( // decl as the requirement key. if (auto genericDecl = as(requirementDecl)) return getInterfaceRequirementKey(context, genericDecl->inner); + + // Only specific types of decls are treated as requirements, e.g. methods and asssociated types. + // Other types of decls are allowed but not regarded as a requirement. + if (!shouldDeclBeTreatedAsInterfaceRequirement(requirementDecl)) + return nullptr; + IRStructKey* requirementKey = nullptr; if(context->shared->interfaceRequirementKeys.TryGetValue(requirementDecl, requirementKey)) { @@ -1356,6 +1387,9 @@ struct ValLoweringVisitor : ValVisitor auto satisfyingWitness = entry.Value; auto irRequirementKey = getInterfaceRequirementKey(requiredMemberDecl); + if (!irRequirementKey) continue; + IRInst* irSatisfyingVal = nullptr; switch(satisfyingWitness.getFlavor()) @@ -6613,6 +6649,9 @@ struct DeclLoweringVisitor : DeclVisitor UInt operandCount = 0; for (auto requirementDecl : decl->members) { + if (!shouldDeclBeTreatedAsInterfaceRequirement(requirementDecl)) + continue; + operandCount++; // As a special case, any type constraints placed // on an associated type will *also* need to be turned @@ -6647,8 +6686,10 @@ struct DeclLoweringVisitor : DeclVisitor for (auto requirementDecl : decl->members) { + auto requirementKey = getInterfaceRequirementKey(requirementDecl); + if (!requirementKey) continue; auto entry = subBuilder->createInterfaceRequirementEntry( - getInterfaceRequirementKey(requirementDecl), + requirementKey, nullptr); if (auto inheritance = as(requirementDecl)) { @@ -8551,6 +8592,13 @@ static void ensureAllDeclsRec( ensureAllDeclsRec(context, memberDecl); } } + else if (auto namespaceDecl = as(decl)) + { + for (auto memberDecl : namespaceDecl->members) + { + ensureAllDeclsRec(context, memberDecl); + } + } else if (auto genericDecl = as(decl)) { ensureAllDeclsRec(context, genericDecl->inner); -- cgit v1.2.3