Commit f178d0bd by Zhenyao Mo Committed by Commit Bot

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/362781Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
parent c051372a
......@@ -790,13 +790,8 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
void TCompiler::collectVariables(TIntermNode* root)
{
sh::CollectVariables collect(&attributes,
&outputVariables,
&uniforms,
&varyings,
&interfaceBlocks,
hashFunction,
symbolTable);
sh::CollectVariables collect(&attributes, &outputVariables, &uniforms, &varyings,
&interfaceBlocks, hashFunction, symbolTable, extensionBehavior);
root->traverse(&collect);
// This is for enforcePackingRestriction().
......
......@@ -70,7 +70,8 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
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 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
mSecondaryFragColorEXTAdded(false),
mSecondaryFragDataEXTAdded(false),
mHashFunction(hashFunction),
mSymbolTable(symbolTable)
mSymbolTable(symbolTable),
mExtensionBehavior(extensionBehavior)
{
}
......@@ -349,10 +351,17 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
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);
......
......@@ -9,6 +9,7 @@
#include <GLSLANG/ShaderLang.h>
#include "compiler/translator/ExtensionBehavior.h"
#include "compiler/translator/IntermNode.h"
class TSymbolTable;
......@@ -26,7 +27,8 @@ class CollectVariables : public TIntermTraverser
std::vector<Varying> *varyings,
std::vector<InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction,
const TSymbolTable &symbolTable);
const TSymbolTable &symbolTable,
const TExtensionBehavior &extensionBehavior);
void visitSymbol(TIntermSymbol *symbol) override;
bool visitAggregate(Visit, TIntermAggregate *node) override;
......@@ -67,6 +69,7 @@ class CollectVariables : public TIntermTraverser
ShHashFunction64 mHashFunction;
const TSymbolTable &mSymbolTable;
const TExtensionBehavior &mExtensionBehavior;
};
void ExpandVariable(const ShaderVariable &variable,
......
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