Fix output variable gl_FragData array size issue.
If the GL_EXT_draw_buffers extension isn't explicitly enabled in the shader,
then gl_FragData is an array of size 1, not of size max_draw_buffers.
BUG=angleproject:1441
TEST=webgl2_conformance with --use-gl=angle
Change-Id: I2ead1457462bf1f396fda1f47022df6b54612e17
Reviewed-on: https://chromium-review.googlesource.com/362781
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index 6b9c940..5cc2b84 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -70,7 +70,8 @@
std::vector<sh::Varying> *varyings,
std::vector<sh::InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction,
- const TSymbolTable &symbolTable)
+ const TSymbolTable &symbolTable,
+ const TExtensionBehavior &extensionBehavior)
: TIntermTraverser(true, false, false),
mAttribs(attribs),
mOutputVariables(outputVariables),
@@ -93,7 +94,8 @@
mSecondaryFragColorEXTAdded(false),
mSecondaryFragDataEXTAdded(false),
mHashFunction(hashFunction),
- mSymbolTable(symbolTable)
+ mSymbolTable(symbolTable),
+ mExtensionBehavior(extensionBehavior)
{
}
@@ -349,10 +351,17 @@
info.name = kName;
info.mappedName = kName;
info.type = GL_FLOAT_VEC4;
- info.arraySize = static_cast<const TVariable *>(
- mSymbolTable.findBuiltIn("gl_MaxDrawBuffers", 100))
- ->getConstPointer()
- ->getIConst();
+ if (::IsExtensionEnabled(mExtensionBehavior, "GL_EXT_draw_buffers"))
+ {
+ info.arraySize = static_cast<const TVariable *>(
+ mSymbolTable.findBuiltIn("gl_MaxDrawBuffers", 100))
+ ->getConstPointer()
+ ->getIConst();
+ }
+ else
+ {
+ info.arraySize = 1;
+ }
info.precision = GL_MEDIUM_FLOAT; // Defined by spec.
info.staticUse = true;
mOutputVariables->push_back(info);