@@ -9101,6 +9101,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
9101
9101
subBuilder->addAutoDiffBuiltinDecoration(irAggType);
9102
9102
}
9103
9103
9104
+ addTargetRequirementDecorations(irAggType, decl);
9104
9105
9105
9106
return LoweredValInfo::simple(finalFinishedVal);
9106
9107
}
@@ -9774,6 +9775,36 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
9774
9775
}
9775
9776
}
9776
9777
9778
+ void addTargetRequirementDecorations(IRInst* inst, Decl* decl)
9779
+ {
9780
+ // If this declaration requires certain GLSL extension (or a particular GLSL version)
9781
+ // for it to be usable, then declare that here. Similarly for SPIR-V or CUDA
9782
+ //
9783
+ // TODO: We should wrap this an `SpecializedForTargetModifier` together into a single
9784
+ // case for enumerating the "capabilities" that a declaration requires.
9785
+ //
9786
+ for (auto extensionMod : decl->getModifiersOfType<RequiredGLSLExtensionModifier>())
9787
+ {
9788
+ getBuilder()->addRequireGLSLExtensionDecoration(
9789
+ inst,
9790
+ extensionMod->extensionNameToken.getContent());
9791
+ }
9792
+ for (auto versionMod : decl->getModifiersOfType<RequiredGLSLVersionModifier>())
9793
+ {
9794
+ getBuilder()->addRequireGLSLVersionDecoration(
9795
+ inst,
9796
+ Int(getIntegerLiteralValue(versionMod->versionNumberToken)));
9797
+ }
9798
+ for (auto versionMod : decl->getModifiersOfType<RequiredSPIRVVersionModifier>())
9799
+ {
9800
+ getBuilder()->addRequireSPIRVVersionDecoration(inst, versionMod->version);
9801
+ }
9802
+ for (auto versionMod : decl->getModifiersOfType<RequiredCUDASMVersionModifier>())
9803
+ {
9804
+ getBuilder()->addRequireCUDASMVersionDecoration(inst, versionMod->version);
9805
+ }
9806
+ }
9807
+
9777
9808
void addBitFieldAccessorDecorations(IRInst* irFunc, Decl* decl)
9778
9809
{
9779
9810
// If this is an accessor and the parent is describing some bitfield,
@@ -10340,6 +10371,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
10340
10371
10341
10372
addCatchAllIntrinsicDecorationIfNeeded(irFunc, decl);
10342
10373
10374
+ addTargetRequirementDecorations(irFunc, decl);
10375
+
10343
10376
bool isInline = false;
10344
10377
10345
10378
addBitFieldAccessorDecorations(irFunc, decl);
0 commit comments