Commit df7d7c9e by Jiawei-Shao Committed by Commit Bot

Split varyings into input and output varyings in compiler

This patch intends to split all vector<Varying> into two vectors to store input and output varyings separately in the compiler. This patch is a base of implementing the built-ins, inputs and outputs of a geometry shader to ANGLE GLSL compiler. Unlike the vertex shaders (their outputs are varyings) and fragment shaders (their inputs are varyings), the inputs and outputs of geometry shaders are all varyings, so we need two vector<Varying> to store them correctly. BUG=angleproject:1941 Change-Id: I9e8cc16045d5e29e9a80a09dc31b33a7ae39b345 Reviewed-on: https://chromium-review.googlesource.com/593347 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b0761934
...@@ -536,6 +536,8 @@ const std::map<std::string, std::string> *GetNameHashingMap(const ShHandle handl ...@@ -536,6 +536,8 @@ const std::map<std::string, std::string> *GetNameHashingMap(const ShHandle handl
// handle: Specifies the compiler // handle: Specifies the compiler
const std::vector<sh::Uniform> *GetUniforms(const ShHandle handle); const std::vector<sh::Uniform> *GetUniforms(const ShHandle handle);
const std::vector<sh::Varying> *GetVaryings(const ShHandle handle); const std::vector<sh::Varying> *GetVaryings(const ShHandle handle);
const std::vector<sh::Varying> *GetInputVaryings(const ShHandle handle);
const std::vector<sh::Varying> *GetOutputVaryings(const ShHandle handle);
const std::vector<sh::Attribute> *GetAttributes(const ShHandle handle); const std::vector<sh::Attribute> *GetAttributes(const ShHandle handle);
const std::vector<sh::OutputVariable> *GetOutputVariables(const ShHandle handle); const std::vector<sh::OutputVariable> *GetOutputVariables(const ShHandle handle);
const std::vector<sh::InterfaceBlock> *GetInterfaceBlocks(const ShHandle handle); const std::vector<sh::InterfaceBlock> *GetInterfaceBlocks(const ShHandle handle);
......
...@@ -578,10 +578,11 @@ void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVari ...@@ -578,10 +578,11 @@ void PrintVariable(const std::string &prefix, size_t index, const sh::ShaderVari
static void PrintActiveVariables(ShHandle compiler) static void PrintActiveVariables(ShHandle compiler)
{ {
const std::vector<sh::Uniform> *uniforms = sh::GetUniforms(compiler); const std::vector<sh::Uniform> *uniforms = sh::GetUniforms(compiler);
const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler); const std::vector<sh::Varying> *inputVaryings = sh::GetInputVaryings(compiler);
const std::vector<sh::Varying> *outputVaryings = sh::GetOutputVaryings(compiler);
const std::vector<sh::Attribute> *attributes = sh::GetAttributes(compiler); const std::vector<sh::Attribute> *attributes = sh::GetAttributes(compiler);
const std::vector<sh::OutputVariable> *outputs = sh::GetOutputVariables(compiler); const std::vector<sh::OutputVariable> *outputs = sh::GetOutputVariables(compiler);
for (size_t varCategory = 0; varCategory < 4; ++varCategory) for (size_t varCategory = 0; varCategory < 5; ++varCategory)
{ {
size_t numVars = 0; size_t numVars = 0;
std::string varCategoryName; std::string varCategoryName;
...@@ -592,11 +593,16 @@ static void PrintActiveVariables(ShHandle compiler) ...@@ -592,11 +593,16 @@ static void PrintActiveVariables(ShHandle compiler)
} }
else if (varCategory == 1) else if (varCategory == 1)
{ {
numVars = varyings->size(); numVars = inputVaryings->size();
varCategoryName = "varying"; varCategoryName = "input varying";
} }
else if (varCategory == 2) else if (varCategory == 2)
{ {
numVars = outputVaryings->size();
varCategoryName = "output varying";
}
else if (varCategory == 3)
{
numVars = attributes->size(); numVars = attributes->size();
varCategoryName = "attribute"; varCategoryName = "attribute";
} }
...@@ -612,8 +618,10 @@ static void PrintActiveVariables(ShHandle compiler) ...@@ -612,8 +618,10 @@ static void PrintActiveVariables(ShHandle compiler)
if (varCategory == 0) if (varCategory == 0)
var = &((*uniforms)[i]); var = &((*uniforms)[i]);
else if (varCategory == 1) else if (varCategory == 1)
var = &((*varyings)[i]); var = &((*inputVaryings)[i]);
else if (varCategory == 2) else if (varCategory == 2)
var = &((*outputVaryings)[i]);
else if (varCategory == 3)
var = &((*attributes)[i]); var = &((*attributes)[i]);
else else
var = &((*outputs)[i]); var = &((*outputs)[i]);
......
...@@ -473,9 +473,9 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -473,9 +473,9 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
if (success && shouldCollectVariables(compileOptions)) if (success && shouldCollectVariables(compileOptions))
{ {
ASSERT(!variablesCollected); ASSERT(!variablesCollected);
CollectVariables(root, &attributes, &outputVariables, &uniforms, &varyings, CollectVariables(root, &attributes, &outputVariables, &uniforms, &inputVaryings,
&interfaceBlocks, hashFunction, &symbolTable, shaderVersion, &outputVaryings, &interfaceBlocks, hashFunction, &symbolTable,
extensionBehavior); shaderVersion, extensionBehavior);
variablesCollected = true; variablesCollected = true;
if (compileOptions & SH_USE_UNUSED_STANDARD_SHARED_BLOCKS) if (compileOptions & SH_USE_UNUSED_STANDARD_SHARED_BLOCKS)
{ {
...@@ -760,7 +760,8 @@ void TCompiler::clearResults() ...@@ -760,7 +760,8 @@ void TCompiler::clearResults()
attributes.clear(); attributes.clear();
outputVariables.clear(); outputVariables.clear();
uniforms.clear(); uniforms.clear();
varyings.clear(); inputVaryings.clear();
outputVaryings.clear();
interfaceBlocks.clear(); interfaceBlocks.clear();
variablesCollected = false; variablesCollected = false;
mGLPositionInitialized = false; mGLPositionInitialized = false;
...@@ -999,7 +1000,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root) ...@@ -999,7 +1000,7 @@ void TCompiler::initializeOutputVariables(TIntermBlock *root)
InitVariableList list; InitVariableList list;
if (shaderType == GL_VERTEX_SHADER) if (shaderType == GL_VERTEX_SHADER)
{ {
for (auto var : varyings) for (auto var : outputVaryings)
{ {
list.push_back(var); list.push_back(var);
if (var.name == "gl_Position") if (var.name == "gl_Position")
...@@ -1063,9 +1064,16 @@ void TCompiler::writePragma(ShCompileOptions compileOptions) ...@@ -1063,9 +1064,16 @@ void TCompiler::writePragma(ShCompileOptions compileOptions)
bool TCompiler::isVaryingDefined(const char *varyingName) bool TCompiler::isVaryingDefined(const char *varyingName)
{ {
ASSERT(variablesCollected); ASSERT(variablesCollected);
for (size_t ii = 0; ii < varyings.size(); ++ii) for (size_t ii = 0; ii < inputVaryings.size(); ++ii)
{ {
if (varyings[ii].name == varyingName) if (inputVaryings[ii].name == varyingName)
{
return true;
}
}
for (size_t ii = 0; ii < outputVaryings.size(); ++ii)
{
if (outputVaryings[ii].name == varyingName)
{ {
return true; return true;
} }
......
...@@ -110,7 +110,8 @@ class TCompiler : public TShHandleBase ...@@ -110,7 +110,8 @@ class TCompiler : public TShHandleBase
const std::vector<sh::Attribute> &getAttributes() const { return attributes; } const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
const std::vector<sh::OutputVariable> &getOutputVariables() const { return outputVariables; } const std::vector<sh::OutputVariable> &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> &getInputVaryings() const { return inputVaryings; }
const std::vector<sh::Varying> &getOutputVaryings() const { return outputVaryings; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; } const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
ShHashFunction64 getHashFunction() const { return hashFunction; } ShHashFunction64 getHashFunction() const { return hashFunction; }
...@@ -184,7 +185,8 @@ class TCompiler : public TShHandleBase ...@@ -184,7 +185,8 @@ class TCompiler : public TShHandleBase
std::vector<sh::Attribute> attributes; std::vector<sh::Attribute> attributes;
std::vector<sh::OutputVariable> outputVariables; std::vector<sh::OutputVariable> outputVariables;
std::vector<sh::Uniform> uniforms; std::vector<sh::Uniform> uniforms;
std::vector<sh::Varying> varyings; std::vector<sh::Varying> inputVaryings;
std::vector<sh::Varying> outputVaryings;
std::vector<sh::InterfaceBlock> interfaceBlocks; std::vector<sh::InterfaceBlock> interfaceBlocks;
private: private:
......
...@@ -45,7 +45,20 @@ const std::vector<Uniform> *GetVariableList(const TCompiler *compiler) ...@@ -45,7 +45,20 @@ const std::vector<Uniform> *GetVariableList(const TCompiler *compiler)
template <> template <>
const std::vector<Varying> *GetVariableList(const TCompiler *compiler) const std::vector<Varying> *GetVariableList(const TCompiler *compiler)
{ {
return &compiler->getVaryings(); switch (compiler->getShaderType())
{
case GL_VERTEX_SHADER:
return &compiler->getOutputVaryings();
case GL_FRAGMENT_SHADER:
return &compiler->getInputVaryings();
case GL_COMPUTE_SHADER:
ASSERT(compiler->getOutputVaryings().empty() && compiler->getInputVaryings().empty());
return &compiler->getOutputVaryings();
// Since geometry shaders have both input and output varyings, we shouldn't call GetVaryings
// on a geometry shader.
default:
return nullptr;
}
} }
template <> template <>
...@@ -66,8 +79,7 @@ const std::vector<InterfaceBlock> *GetVariableList(const TCompiler *compiler) ...@@ -66,8 +79,7 @@ const std::vector<InterfaceBlock> *GetVariableList(const TCompiler *compiler)
return &compiler->getInterfaceBlocks(); return &compiler->getInterfaceBlocks();
} }
template <typename VarT> TCompiler *GetCompilerFromHandle(ShHandle handle)
const std::vector<VarT> *GetShaderVariables(const ShHandle handle)
{ {
if (!handle) if (!handle)
{ {
...@@ -75,7 +87,13 @@ const std::vector<VarT> *GetShaderVariables(const ShHandle handle) ...@@ -75,7 +87,13 @@ const std::vector<VarT> *GetShaderVariables(const ShHandle handle)
} }
TShHandleBase *base = static_cast<TShHandleBase *>(handle); TShHandleBase *base = static_cast<TShHandleBase *>(handle);
TCompiler *compiler = base->getAsCompiler(); return base->getAsCompiler();
}
template <typename VarT>
const std::vector<VarT> *GetShaderVariables(const ShHandle handle)
{
TCompiler *compiler = GetCompilerFromHandle(handle);
if (!compiler) if (!compiler)
{ {
return nullptr; return nullptr;
...@@ -84,14 +102,6 @@ const std::vector<VarT> *GetShaderVariables(const ShHandle handle) ...@@ -84,14 +102,6 @@ const std::vector<VarT> *GetShaderVariables(const ShHandle handle)
return GetVariableList<VarT>(compiler); return GetVariableList<VarT>(compiler);
} }
TCompiler *GetCompilerFromHandle(ShHandle handle)
{
if (!handle)
return nullptr;
TShHandleBase *base = static_cast<TShHandleBase *>(handle);
return base->getAsCompiler();
}
#ifdef ANGLE_ENABLE_HLSL #ifdef ANGLE_ENABLE_HLSL
TranslatorHLSL *GetTranslatorHLSLFromHandle(ShHandle handle) TranslatorHLSL *GetTranslatorHLSLFromHandle(ShHandle handle)
{ {
...@@ -355,6 +365,26 @@ const std::vector<Uniform> *GetUniforms(const ShHandle handle) ...@@ -355,6 +365,26 @@ const std::vector<Uniform> *GetUniforms(const ShHandle handle)
return GetShaderVariables<Uniform>(handle); return GetShaderVariables<Uniform>(handle);
} }
const std::vector<sh::Varying> *GetInputVaryings(const ShHandle handle)
{
TCompiler *compiler = GetCompilerFromHandle(handle);
if (compiler == nullptr)
{
return nullptr;
}
return &compiler->getInputVaryings();
}
const std::vector<sh::Varying> *GetOutputVaryings(const ShHandle handle)
{
TCompiler *compiler = GetCompilerFromHandle(handle);
if (compiler == nullptr)
{
return nullptr;
}
return &compiler->getOutputVaryings();
}
const std::vector<Varying> *GetVaryings(const ShHandle handle) const std::vector<Varying> *GetVaryings(const ShHandle handle)
{ {
return GetShaderVariables<Varying>(handle); return GetShaderVariables<Varying>(handle);
......
...@@ -92,7 +92,8 @@ class CollectVariablesTraverser : public TIntermTraverser ...@@ -92,7 +92,8 @@ class CollectVariablesTraverser : public TIntermTraverser
CollectVariablesTraverser(std::vector<Attribute> *attribs, CollectVariablesTraverser(std::vector<Attribute> *attribs,
std::vector<OutputVariable> *outputVariables, std::vector<OutputVariable> *outputVariables,
std::vector<Uniform> *uniforms, std::vector<Uniform> *uniforms,
std::vector<Varying> *varyings, std::vector<Varying> *inputVaryings,
std::vector<Varying> *outputVaryings,
std::vector<InterfaceBlock> *interfaceBlocks, std::vector<InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
...@@ -116,14 +117,17 @@ class CollectVariablesTraverser : public TIntermTraverser ...@@ -116,14 +117,17 @@ class CollectVariablesTraverser : public TIntermTraverser
void setBuiltInInfoFromSymbolTable(const char *name, ShaderVariable *info); void setBuiltInInfoFromSymbolTable(const char *name, ShaderVariable *info);
void recordBuiltInVaryingUsed(const char *name, bool *addedFlag); void recordBuiltInVaryingUsed(const char *name,
bool *addedFlag,
std::vector<Varying> *varyings);
void recordBuiltInFragmentOutputUsed(const char *name, bool *addedFlag); void recordBuiltInFragmentOutputUsed(const char *name, bool *addedFlag);
void recordBuiltInAttributeUsed(const char *name, bool *addedFlag); void recordBuiltInAttributeUsed(const char *name, bool *addedFlag);
std::vector<Attribute> *mAttribs; std::vector<Attribute> *mAttribs;
std::vector<OutputVariable> *mOutputVariables; std::vector<OutputVariable> *mOutputVariables;
std::vector<Uniform> *mUniforms; std::vector<Uniform> *mUniforms;
std::vector<Varying> *mVaryings; std::vector<Varying> *mInputVaryings;
std::vector<Varying> *mOutputVaryings;
std::vector<InterfaceBlock> *mInterfaceBlocks; std::vector<InterfaceBlock> *mInterfaceBlocks;
std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields; std::map<std::string, InterfaceBlockField *> mInterfaceBlockFields;
...@@ -155,7 +159,8 @@ CollectVariablesTraverser::CollectVariablesTraverser( ...@@ -155,7 +159,8 @@ CollectVariablesTraverser::CollectVariablesTraverser(
std::vector<sh::Attribute> *attribs, std::vector<sh::Attribute> *attribs,
std::vector<sh::OutputVariable> *outputVariables, std::vector<sh::OutputVariable> *outputVariables,
std::vector<sh::Uniform> *uniforms, std::vector<sh::Uniform> *uniforms,
std::vector<sh::Varying> *varyings, std::vector<sh::Varying> *inputVaryings,
std::vector<sh::Varying> *outputVaryings,
std::vector<sh::InterfaceBlock> *interfaceBlocks, std::vector<sh::InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
...@@ -165,7 +170,8 @@ CollectVariablesTraverser::CollectVariablesTraverser( ...@@ -165,7 +170,8 @@ CollectVariablesTraverser::CollectVariablesTraverser(
mAttribs(attribs), mAttribs(attribs),
mOutputVariables(outputVariables), mOutputVariables(outputVariables),
mUniforms(uniforms), mUniforms(uniforms),
mVaryings(varyings), mInputVaryings(inputVaryings),
mOutputVaryings(outputVaryings),
mInterfaceBlocks(interfaceBlocks), mInterfaceBlocks(interfaceBlocks),
mDepthRangeAdded(false), mDepthRangeAdded(false),
mPointCoordAdded(false), mPointCoordAdded(false),
...@@ -203,15 +209,18 @@ void CollectVariablesTraverser::setBuiltInInfoFromSymbolTable(const char *name, ...@@ -203,15 +209,18 @@ void CollectVariablesTraverser::setBuiltInInfoFromSymbolTable(const char *name,
info->precision = GLVariablePrecision(type); info->precision = GLVariablePrecision(type);
} }
void CollectVariablesTraverser::recordBuiltInVaryingUsed(const char *name, bool *addedFlag) void CollectVariablesTraverser::recordBuiltInVaryingUsed(const char *name,
bool *addedFlag,
std::vector<Varying> *varyings)
{ {
ASSERT(varyings);
if (!(*addedFlag)) if (!(*addedFlag))
{ {
Varying info; Varying info;
setBuiltInInfoFromSymbolTable(name, &info); setBuiltInInfoFromSymbolTable(name, &info);
info.staticUse = true; info.staticUse = true;
info.isInvariant = mSymbolTable->isVaryingInvariant(name); info.isInvariant = mSymbolTable->isVaryingInvariant(name);
mVaryings->push_back(info); varyings->push_back(info);
(*addedFlag) = true; (*addedFlag) = true;
} }
} }
...@@ -259,9 +268,13 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -259,9 +268,13 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
ShaderVariable *var = nullptr; ShaderVariable *var = nullptr;
const TString &symbolName = symbol->getName().getString(); const TString &symbolName = symbol->getName().getString();
if (IsVarying(symbol->getQualifier())) if (IsVaryingIn(symbol->getQualifier()))
{ {
var = FindVariable(symbolName, mVaryings); var = FindVariable(symbolName, mInputVaryings);
}
else if (IsVaryingOut(symbol->getQualifier()))
{
var = FindVariable(symbolName, mOutputVaryings);
} }
else if (symbol->getType().getBasicType() == EbtInterfaceBlock) else if (symbol->getType().getBasicType() == EbtInterfaceBlock)
{ {
...@@ -351,13 +364,13 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -351,13 +364,13 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
} }
break; break;
case EvqFragCoord: case EvqFragCoord:
recordBuiltInVaryingUsed("gl_FragCoord", &mFragCoordAdded); recordBuiltInVaryingUsed("gl_FragCoord", &mFragCoordAdded, mInputVaryings);
return; return;
case EvqFrontFacing: case EvqFrontFacing:
recordBuiltInVaryingUsed("gl_FrontFacing", &mFrontFacingAdded); recordBuiltInVaryingUsed("gl_FrontFacing", &mFrontFacingAdded, mInputVaryings);
return; return;
case EvqPointCoord: case EvqPointCoord:
recordBuiltInVaryingUsed("gl_PointCoord", &mPointCoordAdded); recordBuiltInVaryingUsed("gl_PointCoord", &mPointCoordAdded, mInputVaryings);
return; return;
case EvqInstanceID: case EvqInstanceID:
// Whenever the SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW option is set, // Whenever the SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW option is set,
...@@ -384,13 +397,13 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -384,13 +397,13 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
recordBuiltInAttributeUsed("gl_VertexID", &mVertexIDAdded); recordBuiltInAttributeUsed("gl_VertexID", &mVertexIDAdded);
return; return;
case EvqPosition: case EvqPosition:
recordBuiltInVaryingUsed("gl_Position", &mPositionAdded); recordBuiltInVaryingUsed("gl_Position", &mPositionAdded, mOutputVaryings);
return; return;
case EvqPointSize: case EvqPointSize:
recordBuiltInVaryingUsed("gl_PointSize", &mPointSizeAdded); recordBuiltInVaryingUsed("gl_PointSize", &mPointSizeAdded, mOutputVaryings);
return; return;
case EvqLastFragData: case EvqLastFragData:
recordBuiltInVaryingUsed("gl_LastFragData", &mLastFragDataAdded); recordBuiltInVaryingUsed("gl_LastFragData", &mLastFragDataAdded, mInputVaryings);
return; return;
case EvqFragColor: case EvqFragColor:
recordBuiltInFragmentOutputUsed("gl_FragColor", &mFragColorAdded); recordBuiltInFragmentOutputUsed("gl_FragColor", &mFragColorAdded);
...@@ -615,7 +628,15 @@ bool CollectVariablesTraverser::visitDeclaration(Visit, TIntermDeclaration *node ...@@ -615,7 +628,15 @@ bool CollectVariablesTraverser::visitDeclaration(Visit, TIntermDeclaration *node
mUniforms->push_back(recordUniform(variable)); mUniforms->push_back(recordUniform(variable));
break; break;
default: default:
mVaryings->push_back(recordVarying(variable)); if (IsVaryingIn(qualifier))
{
mInputVaryings->push_back(recordVarying(variable));
}
else
{
ASSERT(IsVaryingOut(qualifier));
mOutputVaryings->push_back(recordVarying(variable));
}
break; break;
} }
} }
...@@ -660,16 +681,17 @@ void CollectVariables(TIntermBlock *root, ...@@ -660,16 +681,17 @@ void CollectVariables(TIntermBlock *root,
std::vector<Attribute> *attributes, std::vector<Attribute> *attributes,
std::vector<OutputVariable> *outputVariables, std::vector<OutputVariable> *outputVariables,
std::vector<Uniform> *uniforms, std::vector<Uniform> *uniforms,
std::vector<Varying> *varyings, std::vector<Varying> *inputVaryings,
std::vector<Varying> *outputVaryings,
std::vector<InterfaceBlock> *interfaceBlocks, std::vector<InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
int shaderVersion, int shaderVersion,
const TExtensionBehavior &extensionBehavior) const TExtensionBehavior &extensionBehavior)
{ {
CollectVariablesTraverser collect(attributes, outputVariables, uniforms, varyings, CollectVariablesTraverser collect(attributes, outputVariables, uniforms, inputVaryings,
interfaceBlocks, hashFunction, symbolTable, shaderVersion, outputVaryings, interfaceBlocks, hashFunction, symbolTable,
extensionBehavior); shaderVersion, extensionBehavior);
root->traverse(&collect); root->traverse(&collect);
} }
......
...@@ -21,7 +21,8 @@ void CollectVariables(TIntermBlock *root, ...@@ -21,7 +21,8 @@ void CollectVariables(TIntermBlock *root,
std::vector<Attribute> *attributes, std::vector<Attribute> *attributes,
std::vector<OutputVariable> *outputVariables, std::vector<OutputVariable> *outputVariables,
std::vector<Uniform> *uniforms, std::vector<Uniform> *uniforms,
std::vector<Varying> *varyings, std::vector<Varying> *inputVaryings,
std::vector<Varying> *outputVaryings,
std::vector<InterfaceBlock> *interfaceBlocks, std::vector<InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
......
...@@ -421,7 +421,7 @@ TEST_F(CollectVertexVariablesTest, VaryingInterpolation) ...@@ -421,7 +421,7 @@ TEST_F(CollectVertexVariablesTest, VaryingInterpolation)
compile(shaderString); compile(shaderString);
const std::vector<Varying> &varyings = mTranslator->getVaryings(); const std::vector<Varying> &varyings = mTranslator->getOutputVaryings();
ASSERT_EQ(2u, varyings.size()); ASSERT_EQ(2u, varyings.size());
const Varying *varying = &varyings[0]; const Varying *varying = &varyings[0];
...@@ -825,7 +825,7 @@ TEST_F(CollectVertexVariablesTest, ViewID_OVR) ...@@ -825,7 +825,7 @@ TEST_F(CollectVertexVariablesTest, ViewID_OVR)
SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER); SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER);
// The internal ViewID_OVR varying is not exposed through the ShaderVars interface. // The internal ViewID_OVR varying is not exposed through the ShaderVars interface.
const auto &varyings = mTranslator->getVaryings(); const auto &varyings = mTranslator->getOutputVaryings();
ASSERT_EQ(1u, varyings.size()); ASSERT_EQ(1u, varyings.size());
const Varying *varying = &varyings[0]; const Varying *varying = &varyings[0];
EXPECT_EQ("gl_Position", varying->name); EXPECT_EQ("gl_Position", varying->name);
......
...@@ -315,14 +315,14 @@ TEST(ShaderVariableTest, InvariantLeakAcrossShaders) ...@@ -315,14 +315,14 @@ TEST(ShaderVariableTest, InvariantLeakAcrossShaders)
}; };
EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetOutputVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
EXPECT_TRUE(varying.isInvariant); EXPECT_TRUE(varying.isInvariant);
} }
EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
varyings = sh::GetVaryings(compiler); varyings = sh::GetOutputVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
...@@ -357,14 +357,14 @@ TEST(ShaderVariableTest, GlobalInvariantLeakAcrossShaders) ...@@ -357,14 +357,14 @@ TEST(ShaderVariableTest, GlobalInvariantLeakAcrossShaders)
}; };
EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetOutputVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
EXPECT_TRUE(varying.isInvariant); EXPECT_TRUE(varying.isInvariant);
} }
EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
varyings = sh::GetVaryings(compiler); varyings = sh::GetOutputVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "v_varying") if (varying.name == "v_varying")
...@@ -405,14 +405,14 @@ TEST(ShaderVariableTest, BuiltinInvariantVarying) ...@@ -405,14 +405,14 @@ TEST(ShaderVariableTest, BuiltinInvariantVarying)
}; };
EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program1, 1, SH_VARIABLES));
const std::vector<sh::Varying> *varyings = sh::GetVaryings(compiler); const std::vector<sh::Varying> *varyings = sh::GetOutputVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "gl_Position") if (varying.name == "gl_Position")
EXPECT_TRUE(varying.isInvariant); EXPECT_TRUE(varying.isInvariant);
} }
EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES)); EXPECT_TRUE(sh::Compile(compiler, program2, 1, SH_VARIABLES));
varyings = sh::GetVaryings(compiler); varyings = sh::GetOutputVaryings(compiler);
for (const sh::Varying &varying : *varyings) for (const sh::Varying &varying : *varyings)
{ {
if (varying.name == "gl_Position") if (varying.name == "gl_Position")
......
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