From 12f7237e4060388494c549623f4a640327b7ca08 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 14 Nov 2023 17:46:05 -0800 Subject: Add GLSL Compatibility. (#3321) * Parse glsl buffer blocks to GLSLInterfaceBlockDecl * Parse glsl local size layout declarations * Parse (and ignore) glsl version directives * spelling * Better l-value interpretation for glsl interface blocks * Better l-value interpretation for glsl interface blocks * Add compile flag for enabling glsl * Parse and ignore precision modifiers. * Automatically import `glsl` module for compatiblity. * Complete vector and matrix types for glsl * Remove generated file from repo * Bump .gitignore * do not mark out globals as params * Synthesize entrypoint layout from global inout vars. * update test result. * Allow HLSL semantic on global variables. * Fix. * Fix test. * Fix win32 compile error. * Add more builtin input/output and texture intrinsics. * Add struct/array constructor syntax. * Skip `#extension` lines. * overide operator * for matrix/vector multiplication. * Add `matrixCompMult`. * Parse modifiers in for loop init var declr. * Add more glsl intrinsics, add stage into to var layout. * Allow `int[3] x` syntax. * Fix array type syntax. --------- Co-authored-by: Ellie Hermaszewska Co-authored-by: Yong He --- source/slang/slang-options.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 67f95df1e..1c1ad8f1c 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -141,6 +141,7 @@ enum class OptionKind FileSystem, Heterogeneous, NoMangle, + AllowGLSL, // Internal @@ -621,7 +622,8 @@ void initCommandOptions(CommandOptions& options) { OptionKind::FileSystem, "-file-system", "-file-system ", "Set the filesystem hook to use for a compile request."}, { OptionKind::Heterogeneous, "-heterogeneous", nullptr, "Output heterogeneity-related code." }, - { OptionKind::NoMangle, "-no-mangle", nullptr, "Do as little mangling of names as possible." } + { OptionKind::NoMangle, "-no-mangle", nullptr, "Do as little mangling of names as possible." }, + { OptionKind::AllowGLSL, "-allow-glsl", nullptr, "Enable GLSL as an input language." }, }; _addOptions(makeConstArrayView(experimentalOpts), options); @@ -912,6 +914,8 @@ struct OptionsParser String m_spirvCoreGrammarJSONPath; + bool m_allowGLSLInput = false; + CommandLineReader m_reader; CommandOptionsWriter::Style m_helpStyle = CommandOptionsWriter::Style::Text; @@ -1812,6 +1816,7 @@ SlangResult OptionsParser::_parse( switch (optionKind) { case OptionKind::NoMangle: m_flags |= SLANG_COMPILE_FLAG_NO_MANGLING; break; + case OptionKind::AllowGLSL: m_allowGLSLInput = true; break; case OptionKind::EmitIr: m_requestImpl->m_emitIr = true; break; case OptionKind::LoadStdLib: { @@ -2152,7 +2157,7 @@ SlangResult OptionsParser::_parse( m_compileRequest->setEnableEffectAnnotations(true); break; } - + case OptionKind::EntryPointName: { CommandLineArg name; @@ -2482,6 +2487,8 @@ SlangResult OptionsParser::_parse( m_compileRequest->setCompileFlags(m_flags); + m_compileRequest->setAllowGLSLInput(m_allowGLSLInput); + // As a compatability feature, if the user didn't list any explicit entry // point names, *and* they are compiling a single translation unit, *and* they // have either specified a stage, or we can assume one from the naming -- cgit v1.2.3