diff options
| author | Yong He <yonghe@outlook.com> | 2020-09-02 12:21:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-02 12:21:28 -0700 |
| commit | a2a7c4d988b2b7126130d9dcbe4ec94e1ce8424b (patch) | |
| tree | 5e9559abd79b9e2f7d4f22f65a77daaaae3eed16 /source/slang/slang-lower-to-ir.cpp | |
| parent | 7f567df6937b33c653c424af3abb20d32eb80561 (diff) | |
Allow unspecialized existential shader parameters (dynamic dispatch). (#1529)
* Allow unspecialized existential shader parameters (dynamic dispatch).
* Fixes.
* Fixes
* disable cuda test
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 539027e74..ee5338236 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1038,6 +1038,11 @@ static void addLinkageDecoration( { builder->addExportDecoration(inst, mangledName); } + if (decl->findModifier<PublicModifier>()) + { + builder->addPublicDecoration(inst); + builder->addKeepAliveDecoration(inst); + } } static void addLinkageDecoration( @@ -5161,6 +5166,15 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> return LoweredValInfo::simple(inst); } + bool isPublicType(Type* type) + { + if (auto declRefType = as<DeclRefType>(type)) + { + if (declRefType->declRef.getDecl()->findModifier<PublicModifier>()) + return true; + } + return false; + } void lowerWitnessTable( IRGenContext* subContext, @@ -5211,6 +5225,12 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> astReqWitnessTable->witnessedType, astReqWitnessTable->baseType); subBuilder->addExportDecoration(irSatisfyingWitnessTable, mangledName.getUnownedSlice()); + if (isPublicType(astReqWitnessTable->witnessedType)) + { + subBuilder->addPublicDecoration(irSatisfyingWitnessTable); + subBuilder->addKeepAliveDecoration(irSatisfyingWitnessTable); + } + // Recursively lower the sub-table. lowerWitnessTable( subContext, @@ -5327,6 +5347,11 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // Create the IR-level witness table auto irWitnessTable = subBuilder->createWitnessTable(irWitnessTableBaseType); addLinkageDecoration(context, irWitnessTable, inheritanceDecl, mangledName.getUnownedSlice()); + if (parentDecl->findModifier<PublicModifier>()) + { + subBuilder->addPublicDecoration(irWitnessTable); + subBuilder->addKeepAliveDecoration(irWitnessTable); + } // Register the value now, rather than later, to avoid any possible infinite recursion. setGlobalValue(context, inheritanceDecl, LoweredValInfo::simple(irWitnessTable)); @@ -6154,6 +6179,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> SLANG_UNREACHABLE("associatedtype should have been handled by visitAssocTypeDecl."); } + bool isPublicType = decl->findModifier<PublicModifier>() != nullptr; + // Given a declaration of a type, we need to make sure // to output "witness tables" for any interfaces this // type has declared conformance to. @@ -6171,11 +6198,11 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // Emit any generics that should wrap the actual type. auto outerGeneric = emitOuterGenerics(subContext, decl, decl); - IRStructType* irStruct = subBuilder->createStructType(); addNameHint(context, irStruct, decl); addLinkageDecoration(context, irStruct, decl); + subBuilder->setInsertInto(irStruct); // A `struct` that inherits from another `struct` must start @@ -6183,6 +6210,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // for( auto inheritanceDecl : decl->getMembersOfType<InheritanceDecl>() ) { + if (isPublicType) + ensureDecl(context, inheritanceDecl); auto superType = inheritanceDecl->base; if(auto superDeclRefType = as<DeclRefType>(superType)) { |
