Added GLSL version override interface and CLI
This change list allows a user to override the GLSL version from the command line or through the C and C++ interfaces. This will override the override happens in ProcessDeferred() before DeduceVersionProfile() so the process should still error out if the version is insufficient for the shader code. - Added --glsl-version <version> to CLI. - Added parameter to route glslVersion as override version to preprocessor and parse functions to C++ interface. - Updated C interface with function to override GLSL version.
This commit is contained in:
parent
9b20b25138
commit
9a98d32366
5 changed files with 83 additions and 17 deletions
|
|
@ -191,6 +191,9 @@ glslang::EShTargetClientVersion ClientVersion; // not valid until Client i
|
|||
glslang::EShTargetLanguage TargetLanguage = glslang::EShTargetNone;
|
||||
glslang::EShTargetLanguageVersion TargetVersion; // not valid until TargetLanguage is set
|
||||
|
||||
// GLSL version
|
||||
int GlslVersion = 0; // GLSL version specified on CLI, overrides #version in shader source
|
||||
|
||||
std::vector<std::string> Processes; // what should be recorded by OpModuleProcessed, or equivalent
|
||||
|
||||
// Per descriptor-set binding base data
|
||||
|
|
@ -653,6 +656,48 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
|||
lowerword == "flatten-uniform-array" ||
|
||||
lowerword == "fua") {
|
||||
Options |= EOptionFlattenUniformArrays;
|
||||
} else if (lowerword == "glsl-version") {
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "100") == 0) {
|
||||
GlslVersion = 100;
|
||||
} else if (strcmp(argv[1], "110") == 0) {
|
||||
GlslVersion = 110;
|
||||
} else if (strcmp(argv[1], "120") == 0) {
|
||||
GlslVersion = 120;
|
||||
} else if (strcmp(argv[1], "130") == 0) {
|
||||
GlslVersion = 130;
|
||||
} else if (strcmp(argv[1], "140") == 0) {
|
||||
GlslVersion = 140;
|
||||
} else if (strcmp(argv[1], "150") == 0) {
|
||||
GlslVersion = 150;
|
||||
} else if (strcmp(argv[1], "300es") == 0) {
|
||||
GlslVersion = 300;
|
||||
} else if (strcmp(argv[1], "310es") == 0) {
|
||||
GlslVersion = 310;
|
||||
} else if (strcmp(argv[1], "320es") == 0) {
|
||||
GlslVersion = 320;
|
||||
} else if (strcmp(argv[1], "330") == 0) {
|
||||
GlslVersion = 330;
|
||||
} else if (strcmp(argv[1], "400") == 0) {
|
||||
GlslVersion = 400;
|
||||
} else if (strcmp(argv[1], "410") == 0) {
|
||||
GlslVersion = 410;
|
||||
} else if (strcmp(argv[1], "420") == 0) {
|
||||
GlslVersion = 420;
|
||||
} else if (strcmp(argv[1], "430") == 0) {
|
||||
GlslVersion = 430;
|
||||
} else if (strcmp(argv[1], "440") == 0) {
|
||||
GlslVersion = 440;
|
||||
} else if (strcmp(argv[1], "450") == 0) {
|
||||
GlslVersion = 450;
|
||||
} else if (strcmp(argv[1], "460") == 0) {
|
||||
GlslVersion = 460;
|
||||
} else
|
||||
Error("--glsl-version expected one of: 100, 110, 120, 130, 140, 150,\n"
|
||||
"300es, 310es, 320es, 330\n"
|
||||
"400, 410, 420, 430, 440, 450, 460");
|
||||
}
|
||||
bumpArg();
|
||||
} else if (lowerword == "hlsl-offsets") {
|
||||
Options |= EOptionHlslOffsets;
|
||||
} else if (lowerword == "hlsl-iomap" ||
|
||||
|
|
@ -1317,7 +1362,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
|||
#ifndef GLSLANG_WEB
|
||||
if (Options & EOptionOutputPreprocessed) {
|
||||
std::string str;
|
||||
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, messages, &str, includer)) {
|
||||
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, GlslVersion, false, messages, &str, includer)) {
|
||||
PutsIfNonEmpty(str.c_str());
|
||||
} else {
|
||||
CompileFailed = true;
|
||||
|
|
@ -1328,7 +1373,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (! shader->parse(&Resources, defaultVersion, false, messages, includer))
|
||||
if (! shader->parse(&Resources, defaultVersion, GlslVersion, false, messages, includer))
|
||||
CompileFailed = true;
|
||||
|
||||
program.addShader(shader);
|
||||
|
|
@ -1850,6 +1895,11 @@ void usage()
|
|||
" -dumpfullversion | -dumpversion print bare major.minor.patchlevel\n"
|
||||
" --flatten-uniform-arrays | --fua flatten uniform texture/sampler arrays to\n"
|
||||
" scalars\n"
|
||||
" --glsl-version {100 | 110 | 120 | 130 | 140 | 150 |\n"
|
||||
" 300es | 310es | 320es | 330\n"
|
||||
" 400 | 410 | 420 | 430 | 440 | 450 | 460}\n"
|
||||
" set GLSL version, overrides #version\n"
|
||||
" in shader sourcen\n"
|
||||
" --hlsl-offsets allow block offsets to follow HLSL rules\n"
|
||||
" works independently of source language\n"
|
||||
" --hlsl-iomap perform IO mapping in HLSL register space\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue