Commit 1df16022 by Corentin Wallez Committed by Commit Bot

TranslatorGLSL: collect variables when flattening pramga invariant all

BUG=chromium:659472 Change-Id: Icfeada9f09fff5d28eb3f4fafb2c94d57598af1f Reviewed-on: https://chromium-review.googlesource.com/403849 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 698e36ed
......@@ -879,6 +879,16 @@ void TCompiler::collectVariables(TIntermNode* root)
}
}
bool TCompiler::shouldCollectVariables(ShCompileOptions compileOptions)
{
return (compileOptions & SH_VARIABLES) != 0;
}
bool TCompiler::wereVariablesCollected() const
{
return variablesCollected;
}
bool TCompiler::enforcePackingRestrictions()
{
VariablePacker packer;
......
......@@ -123,8 +123,6 @@ class TCompiler : public TShHandleBase
// Returns true if the given shader does not exceed the minimum
// functionality mandated in GLSL 1.0 spec Appendix A.
bool validateLimitations(TIntermNode* root);
// Collect info for all attribs, uniforms, varyings.
void collectVariables(TIntermNode* root);
// Add emulated functions to the built-in function emulator.
virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
ShCompileOptions compileOptions){};
......@@ -160,20 +158,16 @@ class TCompiler : public TShHandleBase
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
virtual bool shouldCollectVariables(ShCompileOptions compileOptions)
{
return (compileOptions & SH_VARIABLES) != 0;
}
virtual bool shouldFlattenPragmaStdglInvariantAll() = 0;
virtual bool shouldCollectVariables(ShCompileOptions compileOptions);
bool wereVariablesCollected() const;
std::vector<sh::Attribute> attributes;
std::vector<sh::OutputVariable> outputVariables;
std::vector<sh::Uniform> uniforms;
std::vector<sh::ShaderVariable> expandedUniforms;
std::vector<sh::Varying> varyings;
std::vector<sh::InterfaceBlock> interfaceBlocks;
bool variablesCollected;
private:
// Creates the function call DAG for further analysis, returning false if there is a recursion
......@@ -184,6 +178,11 @@ class TCompiler : public TShHandleBase
void initSamplerDefaultPrecision(TBasicType samplerType);
// Collect info for all attribs, uniforms, varyings.
void collectVariables(TIntermNode *root);
bool variablesCollected;
// Removes unused function declarations and prototypes from the AST
class UnusedPredicate;
bool pruneUnusedFunctions(TIntermBlock *root);
......
......@@ -57,7 +57,7 @@ void TranslatorGLSL::translate(TIntermNode *root, ShCompileOptions compileOption
// variables that are actually used, to avoid affecting the behavior of the shader.
if ((compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) && getPragma().stdgl.invariantAll)
{
collectVariables(root);
ASSERT(wereVariablesCollected());
switch (getShaderType())
{
......@@ -203,6 +203,12 @@ bool TranslatorGLSL::shouldFlattenPragmaStdglInvariantAll()
return IsGLSL130OrNewer(getOutputType());
}
bool TranslatorGLSL::shouldCollectVariables(ShCompileOptions compileOptions)
{
return (compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) ||
TCompiler::shouldCollectVariables(compileOptions);
}
void TranslatorGLSL::writeVersion(TIntermNode *root)
{
TVersionGLSL versionGLSL(getShaderType(), getPragma(), getOutputType());
......
......@@ -20,6 +20,7 @@ class TranslatorGLSL : public TCompiler
void translate(TIntermNode *root, ShCompileOptions compileOptions) override;
bool shouldFlattenPragmaStdglInvariantAll() override;
bool shouldCollectVariables(ShCompileOptions compileOptions) override;
private:
void writeVersion(TIntermNode *root);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment