From 02f77bbf12981abe376b2d5987684224a50ae4b2 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 12 Jul 2017 14:21:52 -0700 Subject: Add ability for intrinsics to require GLSL extensions When cross-compiling, we need to detect when an intrinsic is used that required non-default GLSL capabilities and emit an appropriate `#extension ... : require` line. I'm handling this by attaching a custom modifier to declarations that require an extension in order to be callable. --- source/slang/parser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/slang/parser.cpp') diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index de63793b1..8314b0930 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -717,6 +717,17 @@ namespace Slang AddModifier(&modifierLink, modifier); } + else if (AdvanceIf(parser, "__glsl_extension")) + { + auto modifier = new RequiredGLSLExtensionModifier(); + modifier->Position = loc; + + parser->ReadToken(TokenType::LParent); + modifier->extensionNameToken = parser->ReadToken(TokenType::Identifier); + parser->ReadToken(TokenType::RParent); + + AddModifier(&modifierLink, modifier); + } else if (AdvanceIf(parser, "layout")) { -- cgit v1.2.3