Revisions to GLSL version override
- Reverted public function interface changes for C++. - Added override member variable to TShader. - Added accessor TShader::setOverrideVersion. - Reverted changes to tests.
This commit is contained in:
parent
356928a96b
commit
1f10dddac4
@ -1261,6 +1261,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
|||||||
shader->setSourceEntryPoint(sourceEntryPointName);
|
shader->setSourceEntryPoint(sourceEntryPointName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shader->setOverrideVersion(GlslVersion);
|
||||||
|
|
||||||
std::string intrinsicString = getIntrinsic(compUnit.text, compUnit.count);
|
std::string intrinsicString = getIntrinsic(compUnit.text, compUnit.count);
|
||||||
|
|
||||||
PreambleString = "";
|
PreambleString = "";
|
||||||
@ -1362,7 +1364,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
|||||||
#ifndef GLSLANG_WEB
|
#ifndef GLSLANG_WEB
|
||||||
if (Options & EOptionOutputPreprocessed) {
|
if (Options & EOptionOutputPreprocessed) {
|
||||||
std::string str;
|
std::string str;
|
||||||
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, GlslVersion, false, messages, &str, includer)) {
|
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, messages, &str, includer)) {
|
||||||
PutsIfNonEmpty(str.c_str());
|
PutsIfNonEmpty(str.c_str());
|
||||||
} else {
|
} else {
|
||||||
CompileFailed = true;
|
CompileFailed = true;
|
||||||
@ -1373,7 +1375,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (! shader->parse(&Resources, defaultVersion, GlslVersion, false, messages, includer))
|
if (! shader->parse(&Resources, defaultVersion, false, messages, includer))
|
||||||
CompileFailed = true;
|
CompileFailed = true;
|
||||||
|
|
||||||
program.addShader(shader);
|
program.addShader(shader);
|
||||||
|
|||||||
@ -57,7 +57,6 @@ static_assert(sizeof(glslang_resource_t) == sizeof(TBuiltInResource), "");
|
|||||||
typedef struct glslang_shader_s {
|
typedef struct glslang_shader_s {
|
||||||
glslang::TShader* shader;
|
glslang::TShader* shader;
|
||||||
std::string preprocessedGLSL;
|
std::string preprocessedGLSL;
|
||||||
int glslVersion;
|
|
||||||
} glslang_shader_t;
|
} glslang_shader_t;
|
||||||
|
|
||||||
typedef struct glslang_program_s {
|
typedef struct glslang_program_s {
|
||||||
@ -378,7 +377,7 @@ GLSLANG_EXPORT void glslang_shader_set_options(glslang_shader_t* shader, int opt
|
|||||||
|
|
||||||
GLSLANG_EXPORT void glslang_shader_set_glsl_version(glslang_shader_t* shader, int version)
|
GLSLANG_EXPORT void glslang_shader_set_glsl_version(glslang_shader_t* shader, int version)
|
||||||
{
|
{
|
||||||
shader->glslVersion = version;
|
shader->shader->setOverrideVersion(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader)
|
GLSLANG_EXPORT const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader)
|
||||||
@ -395,7 +394,6 @@ GLSLANG_EXPORT int glslang_shader_preprocess(glslang_shader_t* shader, const gls
|
|||||||
input->default_version,
|
input->default_version,
|
||||||
c_shader_profile(input->default_profile),
|
c_shader_profile(input->default_profile),
|
||||||
input->force_default_version_and_profile != 0,
|
input->force_default_version_and_profile != 0,
|
||||||
shader->glslVersion,
|
|
||||||
input->forward_compatible != 0,
|
input->forward_compatible != 0,
|
||||||
(EShMessages)c_shader_messages(input->messages),
|
(EShMessages)c_shader_messages(input->messages),
|
||||||
&shader->preprocessedGLSL,
|
&shader->preprocessedGLSL,
|
||||||
@ -411,7 +409,6 @@ GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_
|
|||||||
return shader->shader->parse(
|
return shader->shader->parse(
|
||||||
reinterpret_cast<const TBuiltInResource*>(input->resource),
|
reinterpret_cast<const TBuiltInResource*>(input->resource),
|
||||||
input->default_version,
|
input->default_version,
|
||||||
shader->glslVersion,
|
|
||||||
input->forward_compatible != 0,
|
input->forward_compatible != 0,
|
||||||
(EShMessages)c_shader_messages(input->messages)
|
(EShMessages)c_shader_messages(input->messages)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1483,7 +1483,6 @@ int ShCompile(
|
|||||||
const TBuiltInResource* resources,
|
const TBuiltInResource* resources,
|
||||||
int /*debugOptions*/,
|
int /*debugOptions*/,
|
||||||
int defaultVersion, // use 100 for ES environment, 110 for desktop
|
int defaultVersion, // use 100 for ES environment, 110 for desktop
|
||||||
int overrideVersion, // use 0 if not overriding GLSL version
|
|
||||||
bool forwardCompatible, // give errors for use of deprecated features
|
bool forwardCompatible, // give errors for use of deprecated features
|
||||||
EShMessages messages // warnings/errors/AST; things to print out
|
EShMessages messages // warnings/errors/AST; things to print out
|
||||||
)
|
)
|
||||||
@ -1505,7 +1504,7 @@ int ShCompile(
|
|||||||
TIntermediate intermediate(compiler->getLanguage());
|
TIntermediate intermediate(compiler->getLanguage());
|
||||||
TShader::ForbidIncluder includer;
|
TShader::ForbidIncluder includer;
|
||||||
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr,
|
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr,
|
||||||
"", optLevel, resources, defaultVersion, ENoProfile, false, overrideVersion,
|
"", optLevel, resources, defaultVersion, ENoProfile, false, 0,
|
||||||
forwardCompatible, messages, intermediate, includer);
|
forwardCompatible, messages, intermediate, includer);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1766,7 +1765,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
TShader::TShader(EShLanguage s)
|
TShader::TShader(EShLanguage s)
|
||||||
: stage(s), lengths(nullptr), stringNames(nullptr), preamble("")
|
: stage(s), lengths(nullptr), stringNames(nullptr), preamble(""), overrideVersion(0)
|
||||||
{
|
{
|
||||||
pool = new TPoolAllocator;
|
pool = new TPoolAllocator;
|
||||||
infoSink = new TInfoSink;
|
infoSink = new TInfoSink;
|
||||||
@ -1835,6 +1834,11 @@ void TShader::setUniqueId(unsigned long long id)
|
|||||||
intermediate->setUniqueId(id);
|
intermediate->setUniqueId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TShader::setOverrideVersion(int version)
|
||||||
|
{
|
||||||
|
overrideVersion = version;
|
||||||
|
}
|
||||||
|
|
||||||
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
||||||
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
|
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
|
||||||
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
|
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
|
||||||
@ -1904,7 +1908,7 @@ void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlatt
|
|||||||
//
|
//
|
||||||
// Returns true for success.
|
// Returns true for success.
|
||||||
//
|
//
|
||||||
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, int overrideVersion,
|
bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
||||||
bool forwardCompatible, EShMessages messages, Includer& includer)
|
bool forwardCompatible, EShMessages messages, Includer& includer)
|
||||||
{
|
{
|
||||||
if (! InitThread())
|
if (! InitThread())
|
||||||
@ -1929,7 +1933,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
|
|||||||
// is not an officially supported or fully working path.
|
// is not an officially supported or fully working path.
|
||||||
bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
||||||
int defaultVersion, EProfile defaultProfile,
|
int defaultVersion, EProfile defaultProfile,
|
||||||
bool forceDefaultVersionAndProfile, int overrideVersion,
|
bool forceDefaultVersionAndProfile,
|
||||||
bool forwardCompatible, EShMessages message,
|
bool forwardCompatible, EShMessages message,
|
||||||
std::string* output_string,
|
std::string* output_string,
|
||||||
Includer& includer)
|
Includer& includer)
|
||||||
|
|||||||
@ -334,7 +334,6 @@ GLSLANG_EXPORT int ShCompile(
|
|||||||
const TBuiltInResource *resources,
|
const TBuiltInResource *resources,
|
||||||
int debugOptions,
|
int debugOptions,
|
||||||
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
|
int defaultVersion = 110, // use 100 for ES environment, overridden by #version in shader
|
||||||
int overrideVersion = 0, // overrides #version in GLSL shader, use 0 to disable
|
|
||||||
bool forwardCompatible = false, // give errors for use of deprecated features
|
bool forwardCompatible = false, // give errors for use of deprecated features
|
||||||
EShMessages messages = EShMsgDefault // warnings and errors
|
EShMessages messages = EShMsgDefault // warnings and errors
|
||||||
);
|
);
|
||||||
@ -471,6 +470,7 @@ public:
|
|||||||
GLSLANG_EXPORT void setSourceEntryPoint(const char* sourceEntryPointName);
|
GLSLANG_EXPORT void setSourceEntryPoint(const char* sourceEntryPointName);
|
||||||
GLSLANG_EXPORT void addProcesses(const std::vector<std::string>&);
|
GLSLANG_EXPORT void addProcesses(const std::vector<std::string>&);
|
||||||
GLSLANG_EXPORT void setUniqueId(unsigned long long id);
|
GLSLANG_EXPORT void setUniqueId(unsigned long long id);
|
||||||
|
GLSLANG_EXPORT void setOverrideVersion(int version);
|
||||||
|
|
||||||
// IO resolver binding data: see comments in ShaderLang.cpp
|
// IO resolver binding data: see comments in ShaderLang.cpp
|
||||||
GLSLANG_EXPORT void setShiftBinding(TResourceType res, unsigned int base);
|
GLSLANG_EXPORT void setShiftBinding(TResourceType res, unsigned int base);
|
||||||
@ -648,33 +648,33 @@ public:
|
|||||||
|
|
||||||
GLSLANG_EXPORT bool parse(
|
GLSLANG_EXPORT bool parse(
|
||||||
const TBuiltInResource*, int defaultVersion, EProfile defaultProfile,
|
const TBuiltInResource*, int defaultVersion, EProfile defaultProfile,
|
||||||
bool forceDefaultVersionAndProfile, int overrideVersion, bool forwardCompatible,
|
bool forceDefaultVersionAndProfile, bool forwardCompatible,
|
||||||
EShMessages, Includer&);
|
EShMessages, Includer&);
|
||||||
|
|
||||||
bool parse(const TBuiltInResource* res, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile, int overrideVersion,
|
bool parse(const TBuiltInResource* res, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
||||||
bool forwardCompatible, EShMessages messages)
|
bool forwardCompatible, EShMessages messages)
|
||||||
{
|
{
|
||||||
TShader::ForbidIncluder includer;
|
TShader::ForbidIncluder includer;
|
||||||
return parse(res, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, overrideVersion, forwardCompatible, messages, includer);
|
return parse(res, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, includer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equivalent to parse() without a default profile and without forcing defaults.
|
// Equivalent to parse() without a default profile and without forcing defaults.
|
||||||
bool parse(const TBuiltInResource* builtInResources, int defaultVersion, int overrideVersion, bool forwardCompatible, EShMessages messages)
|
bool parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages)
|
||||||
{
|
{
|
||||||
return parse(builtInResources, defaultVersion, ENoProfile, false, overrideVersion, forwardCompatible, messages);
|
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse(const TBuiltInResource* builtInResources, int defaultVersion, int overrideVersion, bool forwardCompatible, EShMessages messages,
|
bool parse(const TBuiltInResource* builtInResources, int defaultVersion, bool forwardCompatible, EShMessages messages,
|
||||||
Includer& includer)
|
Includer& includer)
|
||||||
{
|
{
|
||||||
return parse(builtInResources, defaultVersion, ENoProfile, false, overrideVersion, forwardCompatible, messages, includer);
|
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages, includer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
|
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
|
||||||
// is not an officially supported or fully working path.
|
// is not an officially supported or fully working path.
|
||||||
GLSLANG_EXPORT bool preprocess(
|
GLSLANG_EXPORT bool preprocess(
|
||||||
const TBuiltInResource* builtInResources, int defaultVersion,
|
const TBuiltInResource* builtInResources, int defaultVersion,
|
||||||
EProfile defaultProfile, bool forceDefaultVersionAndProfile, int overrideVersion,
|
EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
||||||
bool forwardCompatible, EShMessages message, std::string* outputString,
|
bool forwardCompatible, EShMessages message, std::string* outputString,
|
||||||
Includer& includer);
|
Includer& includer);
|
||||||
|
|
||||||
@ -707,6 +707,9 @@ protected:
|
|||||||
// a function in the source string can be renamed FROM this TO the name given in setEntryPoint.
|
// a function in the source string can be renamed FROM this TO the name given in setEntryPoint.
|
||||||
std::string sourceEntryPointName;
|
std::string sourceEntryPointName;
|
||||||
|
|
||||||
|
// overrides #version in shader source or default version if #version isn't present
|
||||||
|
int overrideVersion;
|
||||||
|
|
||||||
TEnvironment environment;
|
TEnvironment environment;
|
||||||
|
|
||||||
friend class TProgram;
|
friend class TProgram;
|
||||||
|
|||||||
@ -200,7 +200,7 @@ public:
|
|||||||
if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str());
|
if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str());
|
||||||
return shader->parse(
|
return shader->parse(
|
||||||
(resources ? resources : &glslang::DefaultTBuiltInResource),
|
(resources ? resources : &glslang::DefaultTBuiltInResource),
|
||||||
defaultVersion, 0, isForwardCompatible, controls);
|
defaultVersion, isForwardCompatible, controls);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compiles and links the given source |code| of the given shader
|
// Compiles and links the given source |code| of the given shader
|
||||||
@ -635,7 +635,7 @@ public:
|
|||||||
glslang::TShader::ForbidIncluder includer;
|
glslang::TShader::ForbidIncluder includer;
|
||||||
const bool success = shader.preprocess(
|
const bool success = shader.preprocess(
|
||||||
&glslang::DefaultTBuiltInResource, defaultVersion, defaultProfile,
|
&glslang::DefaultTBuiltInResource, defaultVersion, defaultProfile,
|
||||||
forceVersionProfile, 0, isForwardCompatible, (EShMessages)(EShMsgOnlyPreprocessor | EShMsgCascadingErrors),
|
forceVersionProfile, isForwardCompatible, (EShMessages)(EShMsgOnlyPreprocessor | EShMsgCascadingErrors),
|
||||||
&ppShader, includer);
|
&ppShader, includer);
|
||||||
|
|
||||||
std::string log = shader.getInfoLog();
|
std::string log = shader.getInfoLog();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user