diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 8 | ||||
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 33 |
2 files changed, 37 insertions, 4 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 98bddad9b..180ef9909 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -3722,10 +3722,6 @@ void CLikeSourceEmitter::emitSimpleFuncImpl(IRFunc* func) emitEntryPointAttributes(func, entryPointDecor); } - // Deal with required features/capabilities of the function - // - handleRequiredCapabilitiesImpl(func); - emitFunctionPreambleImpl(func); emitFuncDecorations(func); @@ -4885,6 +4881,10 @@ void CLikeSourceEmitter::emitGlobalInstImpl(IRInst* inst) { m_writer->advanceToSourceLocation(inst->sourceLoc); + // Deal with required features/capabilities of the global inst + // + handleRequiredCapabilitiesImpl(inst); + switch (inst->getOp()) { case kIROp_GlobalHashedStringLiterals: diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 76b8e38e9..ba6b3413d 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -9101,6 +9101,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> subBuilder->addAutoDiffBuiltinDecoration(irAggType); } + addTargetRequirementDecorations(irAggType, decl); return LoweredValInfo::simple(finalFinishedVal); } @@ -9774,6 +9775,36 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> } } + void addTargetRequirementDecorations(IRInst* inst, Decl* decl) + { + // If this declaration requires certain GLSL extension (or a particular GLSL version) + // for it to be usable, then declare that here. Similarly for SPIR-V or CUDA + // + // TODO: We should wrap this an `SpecializedForTargetModifier` together into a single + // case for enumerating the "capabilities" that a declaration requires. + // + for (auto extensionMod : decl->getModifiersOfType<RequiredGLSLExtensionModifier>()) + { + getBuilder()->addRequireGLSLExtensionDecoration( + inst, + extensionMod->extensionNameToken.getContent()); + } + for (auto versionMod : decl->getModifiersOfType<RequiredGLSLVersionModifier>()) + { + getBuilder()->addRequireGLSLVersionDecoration( + inst, + Int(getIntegerLiteralValue(versionMod->versionNumberToken))); + } + for (auto versionMod : decl->getModifiersOfType<RequiredSPIRVVersionModifier>()) + { + getBuilder()->addRequireSPIRVVersionDecoration(inst, versionMod->version); + } + for (auto versionMod : decl->getModifiersOfType<RequiredCUDASMVersionModifier>()) + { + getBuilder()->addRequireCUDASMVersionDecoration(inst, versionMod->version); + } + } + void addBitFieldAccessorDecorations(IRInst* irFunc, Decl* decl) { // If this is an accessor and the parent is describing some bitfield, @@ -10340,6 +10371,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> addCatchAllIntrinsicDecorationIfNeeded(irFunc, decl); + addTargetRequirementDecorations(irFunc, decl); + bool isInline = false; addBitFieldAccessorDecorations(irFunc, decl); |
