Commit 34d2007f by Olli Etuaho Committed by Commit Bot

Fix exposing internal shader interface variables

Don't expose internal variables in the shader translator interface. This affects the ViewID_OVR varying needed for instanced multiview, which is so far the only variable of this kind. This fixes the translator trying to add initialization for internal variables in initializeOutputVariables. Since they are variables added by ANGLE, they should never need extra initialization. BUG=angleproject:2112 TEST=angle_unittests Change-Id: I93ee2956c8180053806ce450d93f162f78a45d8f Reviewed-on: https://chromium-review.googlesource.com/579050Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 5dae57b0
...@@ -249,8 +249,15 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const char *name, boo ...@@ -249,8 +249,15 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const char *name, boo
void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
{ {
ASSERT(symbol != nullptr); ASSERT(symbol != nullptr);
if (symbol->getName().isInternal())
{
// Internal variables are not collected.
return;
}
ShaderVariable *var = nullptr; ShaderVariable *var = nullptr;
const TString &symbolName = symbol->getSymbol(); const TString &symbolName = symbol->getName().getString();
if (IsVarying(symbol->getQualifier())) if (IsVarying(symbol->getQualifier()))
{ {
...@@ -577,6 +584,12 @@ bool CollectVariablesTraverser::visitDeclaration(Visit, TIntermDeclaration *node ...@@ -577,6 +584,12 @@ bool CollectVariablesTraverser::visitDeclaration(Visit, TIntermDeclaration *node
// uniforms, varyings, outputs and interface blocks cannot be initialized in a shader, we // uniforms, varyings, outputs and interface blocks cannot be initialized in a shader, we
// must have only TIntermSymbol nodes in the sequence in the cases we are interested in. // must have only TIntermSymbol nodes in the sequence in the cases we are interested in.
const TIntermSymbol &variable = *variableNode->getAsSymbolNode(); const TIntermSymbol &variable = *variableNode->getAsSymbolNode();
if (variable.getName().isInternal())
{
// Internal variables are not collected.
continue;
}
if (typedNode.getBasicType() == EbtInterfaceBlock) if (typedNode.getBasicType() == EbtInterfaceBlock)
{ {
// TODO(jiajia.qin@intel.com): In order not to affect the old set of mInterfaceBlocks, // TODO(jiajia.qin@intel.com): In order not to affect the old set of mInterfaceBlocks,
......
...@@ -107,12 +107,14 @@ class CollectVariablesTest : public testing::Test ...@@ -107,12 +107,14 @@ class CollectVariablesTest : public testing::Test
*outResult = &outputVariable; *outResult = &outputVariable;
} }
void compile(const std::string &shaderString) void compile(const std::string &shaderString, ShCompileOptions compileOptions)
{ {
const char *shaderStrings[] = {shaderString.c_str()}; const char *shaderStrings[] = {shaderString.c_str()};
ASSERT_TRUE(mTranslator->compile(shaderStrings, 1, SH_VARIABLES)); ASSERT_TRUE(mTranslator->compile(shaderStrings, 1, SH_VARIABLES | compileOptions));
} }
void compile(const std::string &shaderString) { compile(shaderString, 0u); }
::GLenum mShaderType; ::GLenum mShaderType;
std::unique_ptr<TranslatorGLSL> mTranslator; std::unique_ptr<TranslatorGLSL> mTranslator;
}; };
...@@ -800,3 +802,31 @@ TEST_F(CollectFragmentVariablesTest, EmptyDeclarator) ...@@ -800,3 +802,31 @@ TEST_F(CollectFragmentVariablesTest, EmptyDeclarator)
EXPECT_GLENUM_EQ(GL_FLOAT, uniformB.type); EXPECT_GLENUM_EQ(GL_FLOAT, uniformB.type);
EXPECT_EQ("uB", uniformB.name); EXPECT_EQ("uB", uniformB.name);
} }
// Test collecting variables from an instanced multiview shader that has an internal ViewID_OVR
// varying.
TEST_F(CollectVertexVariablesTest, ViewID_OVR)
{
const std::string &shaderString =
"#version 300 es\n"
"#extension GL_OVR_multiview : require\n"
"precision mediump float;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(0.0);\n"
"}\n";
ShBuiltInResources resources = mTranslator->getResources();
resources.OVR_multiview = 1;
resources.MaxViewsOVR = 4;
initTranslator(resources);
compile(shaderString, SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW |
SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER);
// The internal ViewID_OVR varying is not exposed through the ShaderVars interface.
const auto &varyings = mTranslator->getVaryings();
ASSERT_EQ(1u, varyings.size());
const Varying *varying = &varyings[0];
EXPECT_EQ("gl_Position", varying->name);
}
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