Commit ed27c729 by Jamie Madill

Consolidate shader variable storage in Compiler.

The Compiler base class now stores all the shader variables and interface block information, instead of duplicating the information in the HLSL translator. BUG=angle:466 Change-Id: Ia69079fde64fbd6b0cbfc66defd5e37d99ee3e6e Reviewed-on: https://chromium-review.googlesource.com/206020Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarNicolas Capens <capn@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a718c1e0
......@@ -357,9 +357,11 @@ void TCompiler::clearResults()
infoSink.obj.erase();
infoSink.debug.erase();
attribs.clear();
attributes.clear();
outputVariables.clear();
uniforms.clear();
varyings.clear();
interfaceBlocks.clear();
builtInFunctionEmulator.Cleanup();
......@@ -483,7 +485,7 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
void TCompiler::collectVariables(TIntermNode* root)
{
CollectVariables collect(&attribs, &uniforms, &varyings, hashFunction);
CollectVariables collect(&attributes, &uniforms, &varyings, hashFunction);
root->traverse(&collect);
}
......
......@@ -67,9 +67,12 @@ class TCompiler : public TShHandleBase
// Get results of the last compilation.
int getShaderVersion() const { return shaderVersion; }
TInfoSink& getInfoSink() { return infoSink; }
const std::vector<sh::Attribute> &getAttribs() const { return attribs; }
const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; }
const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
const std::vector<sh::Varying> &getVaryings() const { return varyings; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
ShHashFunction64 getHashFunction() const { return hashFunction; }
NameMap& getNameMap() { return nameMap; }
......@@ -130,6 +133,12 @@ class TCompiler : public TShHandleBase
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
std::vector<sh::Attribute> attributes;
std::vector<sh::Attribute> outputVariables;
std::vector<sh::Uniform> uniforms;
std::vector<sh::Varying> varyings;
std::vector<sh::InterfaceBlock> interfaceBlocks;
private:
sh::GLenum shaderType;
ShShaderSpec shaderSpec;
......@@ -156,9 +165,6 @@ class TCompiler : public TShHandleBase
// Results of compilation.
int shaderVersion;
TInfoSink infoSink; // Output sink.
std::vector<sh::Attribute> attribs; // Active attributes in the compiled shader.
std::vector<sh::Uniform> uniforms; // Active uniforms in the compiled shader.
std::vector<sh::Varying> varyings; // Varyings in the compiled shader.
// name hashing.
ShHashFunction64 hashFunction;
......
......@@ -62,7 +62,7 @@ static const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShader
switch (varType)
{
case SH_ACTIVE_ATTRIBUTES:
return ReturnVariable(compiler->getAttribs(), index);
return ReturnVariable(compiler->getAttributes(), index);
case SH_ACTIVE_UNIFORMS:
return ReturnVariable(compiler->getUniforms(), index);
case SH_VARYINGS:
......@@ -257,7 +257,7 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
break;
case SH_ACTIVE_ATTRIBUTES:
*params = compiler->getAttribs().size();
*params = compiler->getAttributes().size();
break;
case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
......
......@@ -10,7 +10,7 @@
#include "compiler/translator/OutputHLSL.h"
TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
: TCompiler(type, spec, output)
: TCompiler(type, spec, output)
{
}
......@@ -21,9 +21,9 @@ void TranslatorHLSL::translate(TIntermNode *root)
outputHLSL.output();
mActiveUniforms = outputHLSL.getUniforms();
mActiveInterfaceBlocks = outputHLSL.getInterfaceBlocks();
mActiveOutputVariables = outputHLSL.getOutputVariables();
mActiveAttributes = outputHLSL.getAttributes();
mActiveVaryings = outputHLSL.getVaryings();
attributes = outputHLSL.getAttributes();
outputVariables = outputHLSL.getOutputVariables();
uniforms = outputHLSL.getUniforms();
varyings = outputHLSL.getVaryings();
interfaceBlocks = outputHLSL.getInterfaceBlocks();
}
......@@ -10,25 +10,14 @@
#include "compiler/translator/Compiler.h"
#include "common/shadervars.h"
class TranslatorHLSL : public TCompiler {
public:
class TranslatorHLSL : public TCompiler
{
public:
TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
const std::vector<sh::Uniform> &getUniforms() { return mActiveUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<sh::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
const std::vector<sh::Attribute> &getAttributes() { return mActiveAttributes; }
const std::vector<sh::Varying> &getVaryings() { return mActiveVaryings; }
protected:
protected:
virtual void translate(TIntermNode* root);
std::vector<sh::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
};
#endif // COMPILER_TRANSLATORHLSL_H_
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