summaryrefslogtreecommitdiff
path: root/source/slang/lower-to-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
-rw-r--r--source/slang/lower-to-ir.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp
index 7b63f510f..5f3b00b24 100644
--- a/source/slang/lower-to-ir.cpp
+++ b/source/slang/lower-to-ir.cpp
@@ -5112,6 +5112,23 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// for a particular target, then handle that here.
addTargetIntrinsicDecorations(irFunc, decl);
+ // If this declaration requires certain GLSL extension (or a particular GLSL version)
+ // for it to be usable, then declare that here.
+ //
+ // 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>())
+ {
+ auto decoration = getBuilder()->addDecoration<IRRequireGLSLExtensionDecoration>(irFunc);
+ decoration->extensionName = getBuilder()->addStringToFree(extensionMod->extensionNameToken.Content);
+ }
+ for(auto versionMod : decl->GetModifiersOfType<RequiredGLSLVersionModifier>())
+ {
+ auto decoration = getBuilder()->addDecoration<IRRequireGLSLVersionDecoration>(irFunc);
+ decoration->languageVersion = Int(getIntegerLiteralValue(versionMod->versionNumberToken));
+ }
+
// For convenience, ensure that any additional global
// values that were emitted while outputting the function
// body appear before the function itself in the list