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() ...@@ -357,9 +357,11 @@ void TCompiler::clearResults()
infoSink.obj.erase(); infoSink.obj.erase();
infoSink.debug.erase(); infoSink.debug.erase();
attribs.clear(); attributes.clear();
outputVariables.clear();
uniforms.clear(); uniforms.clear();
varyings.clear(); varyings.clear();
interfaceBlocks.clear();
builtInFunctionEmulator.Cleanup(); builtInFunctionEmulator.Cleanup();
...@@ -483,7 +485,7 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root) ...@@ -483,7 +485,7 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
void TCompiler::collectVariables(TIntermNode* root) void TCompiler::collectVariables(TIntermNode* root)
{ {
CollectVariables collect(&attribs, &uniforms, &varyings, hashFunction); CollectVariables collect(&attributes, &uniforms, &varyings, hashFunction);
root->traverse(&collect); root->traverse(&collect);
} }
......
...@@ -67,9 +67,12 @@ class TCompiler : public TShHandleBase ...@@ -67,9 +67,12 @@ class TCompiler : public TShHandleBase
// Get results of the last compilation. // Get results of the last compilation.
int getShaderVersion() const { return shaderVersion; } int getShaderVersion() const { return shaderVersion; }
TInfoSink& getInfoSink() { return infoSink; } 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::Uniform> &getUniforms() const { return uniforms; }
const std::vector<sh::Varying> &getVaryings() const { return varyings; } const std::vector<sh::Varying> &getVaryings() const { return varyings; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
ShHashFunction64 getHashFunction() const { return hashFunction; } ShHashFunction64 getHashFunction() const { return hashFunction; }
NameMap& getNameMap() { return nameMap; } NameMap& getNameMap() { return nameMap; }
...@@ -130,6 +133,12 @@ class TCompiler : public TShHandleBase ...@@ -130,6 +133,12 @@ class TCompiler : public TShHandleBase
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const; ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() 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: private:
sh::GLenum shaderType; sh::GLenum shaderType;
ShShaderSpec shaderSpec; ShShaderSpec shaderSpec;
...@@ -156,9 +165,6 @@ class TCompiler : public TShHandleBase ...@@ -156,9 +165,6 @@ class TCompiler : public TShHandleBase
// Results of compilation. // Results of compilation.
int shaderVersion; int shaderVersion;
TInfoSink infoSink; // Output sink. 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. // name hashing.
ShHashFunction64 hashFunction; ShHashFunction64 hashFunction;
......
...@@ -62,7 +62,7 @@ static const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShader ...@@ -62,7 +62,7 @@ static const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShader
switch (varType) switch (varType)
{ {
case SH_ACTIVE_ATTRIBUTES: case SH_ACTIVE_ATTRIBUTES:
return ReturnVariable(compiler->getAttribs(), index); return ReturnVariable(compiler->getAttributes(), index);
case SH_ACTIVE_UNIFORMS: case SH_ACTIVE_UNIFORMS:
return ReturnVariable(compiler->getUniforms(), index); return ReturnVariable(compiler->getUniforms(), index);
case SH_VARYINGS: case SH_VARYINGS:
...@@ -257,7 +257,7 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params) ...@@ -257,7 +257,7 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec()); *params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
break; break;
case SH_ACTIVE_ATTRIBUTES: case SH_ACTIVE_ATTRIBUTES:
*params = compiler->getAttribs().size(); *params = compiler->getAttributes().size();
break; break;
case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec()); *params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
......
...@@ -21,9 +21,9 @@ void TranslatorHLSL::translate(TIntermNode *root) ...@@ -21,9 +21,9 @@ void TranslatorHLSL::translate(TIntermNode *root)
outputHLSL.output(); outputHLSL.output();
mActiveUniforms = outputHLSL.getUniforms(); attributes = outputHLSL.getAttributes();
mActiveInterfaceBlocks = outputHLSL.getInterfaceBlocks(); outputVariables = outputHLSL.getOutputVariables();
mActiveOutputVariables = outputHLSL.getOutputVariables(); uniforms = outputHLSL.getUniforms();
mActiveAttributes = outputHLSL.getAttributes(); varyings = outputHLSL.getVaryings();
mActiveVaryings = outputHLSL.getVaryings(); interfaceBlocks = outputHLSL.getInterfaceBlocks();
} }
...@@ -10,25 +10,14 @@ ...@@ -10,25 +10,14 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "common/shadervars.h" #include "common/shadervars.h"
class TranslatorHLSL : public TCompiler { class TranslatorHLSL : public TCompiler
public: {
public:
TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output); TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; } 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); 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_ #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