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
5 changed files with 28 additions and 22 deletions
|
|
@ -57,7 +57,6 @@ static_assert(sizeof(glslang_resource_t) == sizeof(TBuiltInResource), "");
|
|||
typedef struct glslang_shader_s {
|
||||
glslang::TShader* shader;
|
||||
std::string preprocessedGLSL;
|
||||
int glslVersion;
|
||||
} glslang_shader_t;
|
||||
|
||||
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)
|
||||
{
|
||||
shader->glslVersion = version;
|
||||
shader->shader->setOverrideVersion(version);
|
||||
}
|
||||
|
||||
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,
|
||||
c_shader_profile(input->default_profile),
|
||||
input->force_default_version_and_profile != 0,
|
||||
shader->glslVersion,
|
||||
input->forward_compatible != 0,
|
||||
(EShMessages)c_shader_messages(input->messages),
|
||||
&shader->preprocessedGLSL,
|
||||
|
|
@ -411,7 +409,6 @@ GLSLANG_EXPORT int glslang_shader_parse(glslang_shader_t* shader, const glslang_
|
|||
return shader->shader->parse(
|
||||
reinterpret_cast<const TBuiltInResource*>(input->resource),
|
||||
input->default_version,
|
||||
shader->glslVersion,
|
||||
input->forward_compatible != 0,
|
||||
(EShMessages)c_shader_messages(input->messages)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1483,7 +1483,6 @@ int ShCompile(
|
|||
const TBuiltInResource* resources,
|
||||
int /*debugOptions*/,
|
||||
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
|
||||
EShMessages messages // warnings/errors/AST; things to print out
|
||||
)
|
||||
|
|
@ -1505,7 +1504,7 @@ int ShCompile(
|
|||
TIntermediate intermediate(compiler->getLanguage());
|
||||
TShader::ForbidIncluder includer;
|
||||
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr,
|
||||
"", optLevel, resources, defaultVersion, ENoProfile, false, overrideVersion,
|
||||
"", optLevel, resources, defaultVersion, ENoProfile, false, 0,
|
||||
forwardCompatible, messages, intermediate, includer);
|
||||
|
||||
//
|
||||
|
|
@ -1766,7 +1765,7 @@ public:
|
|||
};
|
||||
|
||||
TShader::TShader(EShLanguage s)
|
||||
: stage(s), lengths(nullptr), stringNames(nullptr), preamble("")
|
||||
: stage(s), lengths(nullptr), stringNames(nullptr), preamble(""), overrideVersion(0)
|
||||
{
|
||||
pool = new TPoolAllocator;
|
||||
infoSink = new TInfoSink;
|
||||
|
|
@ -1835,6 +1834,11 @@ void TShader::setUniqueId(unsigned long long id)
|
|||
intermediate->setUniqueId(id);
|
||||
}
|
||||
|
||||
void TShader::setOverrideVersion(int version)
|
||||
{
|
||||
overrideVersion = version;
|
||||
}
|
||||
|
||||
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
|
||||
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
|
||||
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
|
||||
|
|
@ -1904,7 +1908,7 @@ void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlatt
|
|||
//
|
||||
// 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)
|
||||
{
|
||||
if (! InitThread())
|
||||
|
|
@ -1929,7 +1933,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
|
|||
// is not an officially supported or fully working path.
|
||||
bool TShader::preprocess(const TBuiltInResource* builtInResources,
|
||||
int defaultVersion, EProfile defaultProfile,
|
||||
bool forceDefaultVersionAndProfile, int overrideVersion,
|
||||
bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, EShMessages message,
|
||||
std::string* output_string,
|
||||
Includer& includer)
|
||||
|
|
|
|||
|
|
@ -334,7 +334,6 @@ GLSLANG_EXPORT int ShCompile(
|
|||
const TBuiltInResource *resources,
|
||||
int debugOptions,
|
||||
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
|
||||
EShMessages messages = EShMsgDefault // warnings and errors
|
||||
);
|
||||
|
|
@ -471,6 +470,7 @@ public:
|
|||
GLSLANG_EXPORT void setSourceEntryPoint(const char* sourceEntryPointName);
|
||||
GLSLANG_EXPORT void addProcesses(const std::vector<std::string>&);
|
||||
GLSLANG_EXPORT void setUniqueId(unsigned long long id);
|
||||
GLSLANG_EXPORT void setOverrideVersion(int version);
|
||||
|
||||
// IO resolver binding data: see comments in ShaderLang.cpp
|
||||
GLSLANG_EXPORT void setShiftBinding(TResourceType res, unsigned int base);
|
||||
|
|
@ -648,33 +648,33 @@ public:
|
|||
|
||||
GLSLANG_EXPORT bool parse(
|
||||
const TBuiltInResource*, int defaultVersion, EProfile defaultProfile,
|
||||
bool forceDefaultVersionAndProfile, int overrideVersion, bool forwardCompatible,
|
||||
bool forceDefaultVersionAndProfile, bool forwardCompatible,
|
||||
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)
|
||||
{
|
||||
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.
|
||||
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)
|
||||
{
|
||||
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
|
||||
// is not an officially supported or fully working path.
|
||||
GLSLANG_EXPORT bool preprocess(
|
||||
const TBuiltInResource* builtInResources, int defaultVersion,
|
||||
EProfile defaultProfile, bool forceDefaultVersionAndProfile, int overrideVersion,
|
||||
EProfile defaultProfile, bool forceDefaultVersionAndProfile,
|
||||
bool forwardCompatible, EShMessages message, std::string* outputString,
|
||||
Includer& includer);
|
||||
|
||||
|
|
@ -707,6 +707,9 @@ protected:
|
|||
// a function in the source string can be renamed FROM this TO the name given in setEntryPoint.
|
||||
std::string sourceEntryPointName;
|
||||
|
||||
// overrides #version in shader source or default version if #version isn't present
|
||||
int overrideVersion;
|
||||
|
||||
TEnvironment environment;
|
||||
|
||||
friend class TProgram;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue