glslang: Add API override of version and profile for testing purposes. From Lei Zhang <antiagainst@google.com>.
Add defaultProfile and forceDefaultVersionAndProfile into shader compilation interface. forceDefaultVersionAndProfile allows us to force parsing the input shaders using defaultVersion and defaultProfile, regardless of the #version directive in input shaders. These two parameters enables us to programmatically invoke glslang but specify version and profile from somewhere else like command line. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31504 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
99a3c59fae
commit
edadf45605
5 changed files with 48 additions and 18 deletions
|
|
@ -453,6 +453,10 @@ bool CompileDeferred(
|
|||
const EShOptimizationLevel optLevel,
|
||||
const TBuiltInResource* resources,
|
||||
int defaultVersion, // use 100 for ES environment, 110 for desktop
|
||||
EProfile defaultProfile,
|
||||
// set version/profile to defaultVersion/defaultProfile regardless of the #version
|
||||
// directive in the source code
|
||||
bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, // give errors for use of deprecated features
|
||||
EShMessages messages, // warnings/errors/AST; things to print out
|
||||
TIntermediate& intermediate // returned tree, etc.
|
||||
|
|
@ -497,6 +501,23 @@ bool CompileDeferred(
|
|||
bool versionNotFirstToken;
|
||||
bool versionNotFirst = userInput.scanVersion(version, profile, versionNotFirstToken);
|
||||
bool versionNotFound = version == 0;
|
||||
if (forceDefaultVersionAndProfile) {
|
||||
if (!(messages & EShMsgSuppressWarnings) && !versionNotFound &&
|
||||
(version != defaultVersion || profile != defaultProfile)) {
|
||||
compiler->infoSink.info << "Warning, (version, profile) forced to be ("
|
||||
<< defaultVersion << ", " << ProfileName(defaultProfile)
|
||||
<< "), while in source code it is ("
|
||||
<< version << ", " << ProfileName(profile) << ")\n";
|
||||
}
|
||||
|
||||
if (versionNotFound) {
|
||||
versionNotFirstToken = false;
|
||||
versionNotFirst = false;
|
||||
versionNotFound = false;
|
||||
}
|
||||
version = defaultVersion;
|
||||
profile = defaultProfile;
|
||||
}
|
||||
bool goodVersion = DeduceVersionProfile(compiler->infoSink, compiler->getLanguage(), versionNotFirst, defaultVersion, version, profile);
|
||||
bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
|
||||
bool warnVersionNotFirst = false;
|
||||
|
|
@ -727,7 +748,7 @@ int ShCompile(
|
|||
compiler->infoSink.debug.erase();
|
||||
|
||||
TIntermediate intermediate(compiler->getLanguage());
|
||||
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, "", optLevel, resources, defaultVersion, forwardCompatible, messages, intermediate);
|
||||
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, "", optLevel, resources, defaultVersion, ENoProfile, false, forwardCompatible, messages, intermediate);
|
||||
|
||||
//
|
||||
// Call the machine dependent compiler
|
||||
|
|
@ -1006,7 +1027,7 @@ TShader::~TShader()
|
|||
//
|
||||
// Returns true for success.
|
||||
//
|
||||
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages)
|
||||
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, bool forwardCompatible, EShMessages messages)
|
||||
{
|
||||
if (! InitThread())
|
||||
return false;
|
||||
|
|
@ -1016,7 +1037,12 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
|
|||
if (! preamble)
|
||||
preamble = "";
|
||||
|
||||
return CompileDeferred(compiler, strings, numStrings, nullptr, preamble, EShOptNone, builtInResources, defaultVersion, forwardCompatible, messages, *intermediate);
|
||||
return CompileDeferred(compiler, strings, numStrings, nullptr, preamble, EShOptNone, builtInResources, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, *intermediate);
|
||||
}
|
||||
|
||||
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages)
|
||||
{
|
||||
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages);
|
||||
}
|
||||
|
||||
const char* TShader::getInfoLog()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue