From a2d2018a8be41aecd2c1810db8556e0c07595fb9 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 31 Jan 2024 23:53:28 -0800 Subject: Add slangc option to specialize entrypoint + auto glsl mode. (#3531) * Add slangc option to specialize entrypoint. * Auto enable glsl mode when input file has glsl extension name. * Fix test. --------- Co-authored-by: Yong He --- source/slang/slang.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 8eb75c119..a027340b5 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -25,7 +25,6 @@ #include "slang-mangle.h" #include "slang-parser.h" #include "slang-preprocessor.h" - #include "slang-type-layout.h" #include "slang-options.h" @@ -2601,23 +2600,6 @@ SlangResult FrontEndCompileRequest::executeActionsInner() { // Make sure SourceFile representation is available for all translationUnits SLANG_RETURN_ON_FAIL(translationUnit->requireSourceFiles()); - - if(!getLinkage()->getAllowGLSLInput()) - { - // We currently allow GlSL files on the command line so that we can - // drive our "pass-through" mode, but we really want to issue an error - // message if the user is seriously asking us to compile them and - // doesn't explicitly opt into the glsl frontend - switch(translationUnit->sourceLanguage) - { - default: - break; - - case SourceLanguage::GLSL: - getSink()->diagnose(SourceLoc(), Diagnostics::glslIsNotSupported); - return SLANG_FAIL; - } - } } @@ -3138,8 +3120,17 @@ RefPtr Linkage::loadModule( RefPtr translationUnit = new TranslationUnitRequest(frontEndReq); translationUnit->compileRequest = frontEndReq; translationUnit->moduleName = name; + Stage impliedStage; translationUnit->sourceLanguage = SourceLanguage::Slang; + // If we are loading from a file with apparaent glsl extension, + // set the source language to GLSL to enable GLSL compatibility mode. + if ((SourceLanguage)findSourceLanguageFromPath(filePathInfo.getName(), impliedStage) == + SourceLanguage::GLSL) + { + translationUnit->sourceLanguage = SourceLanguage::GLSL; + } + frontEndReq->addTranslationUnit(translationUnit); auto module = translationUnit->getModule(); -- cgit v1.2.3