summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 4961518f1..c9e19dffc 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -3466,9 +3466,38 @@ struct EmitVisitor
IREmitMode mode,
EOpInfo outerPrec)
{
+ auto funcValue = inst->getOperand(0);
+
+ // Does this function declare any requirements on GLSL version or
+ // extensions, which should affect our output?
+ if(getTarget(ctx) == CodeGenTarget::GLSL)
+ {
+ auto decoratedValue = funcValue;
+ while (auto specInst = as<IRSpecialize>(decoratedValue))
+ {
+ decoratedValue = getSpecializedValue(specInst);
+ }
+
+ for( auto decoration = decoratedValue->firstDecoration; decoration; decoration = decoration->next )
+ {
+ switch(decoration->op)
+ {
+ default:
+ break;
+
+ case kIRDecorationOp_RequireGLSLExtension:
+ requireGLSLExtension(String(((IRRequireGLSLExtensionDecoration*)decoration)->extensionName));
+ break;
+
+ case kIRDecorationOp_RequireGLSLVersion:
+ requireGLSLVersion(int(((IRRequireGLSLVersionDecoration*)decoration)->languageVersion));
+ break;
+ }
+ }
+ }
+
// We want to detect any call to an intrinsic operation,
// that we can emit it directly without mangling, etc.
- auto funcValue = inst->getOperand(0);
if(auto irFunc = asTargetIntrinsic(ctx, funcValue))
{
emitIntrinsicCallExpr(ctx, inst, irFunc, mode, outerPrec);