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) ...@@ -790,13 +790,8 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
void TCompiler::collectVariables(TIntermNode* root) void TCompiler::collectVariables(TIntermNode* root)
{ {
sh::CollectVariables collect(&attributes, sh::CollectVariables collect(&attributes, &outputVariables, &uniforms, &varyings,
&outputVariables, &interfaceBlocks, hashFunction, symbolTable, extensionBehavior);
&uniforms,
&varyings,
&interfaceBlocks,
hashFunction,
symbolTable);
root->traverse(&collect); root->traverse(&collect);
// This is for enforcePackingRestriction(). // This is for enforcePackingRestriction().
......
...@@ -70,7 +70,8 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs, ...@@ -70,7 +70,8 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
std::vector<sh::Varying> *varyings, std::vector<sh::Varying> *varyings,
std::vector<sh::InterfaceBlock> *interfaceBlocks, std::vector<sh::InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
const TSymbolTable &symbolTable) const TSymbolTable &symbolTable,
const TExtensionBehavior &extensionBehavior)
: TIntermTraverser(true, false, false), : TIntermTraverser(true, false, false),
mAttribs(attribs), mAttribs(attribs),
mOutputVariables(outputVariables), mOutputVariables(outputVariables),
...@@ -93,7 +94,8 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs, ...@@ -93,7 +94,8 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
mSecondaryFragColorEXTAdded(false), mSecondaryFragColorEXTAdded(false),
mSecondaryFragDataEXTAdded(false), mSecondaryFragDataEXTAdded(false),
mHashFunction(hashFunction), mHashFunction(hashFunction),
mSymbolTable(symbolTable) mSymbolTable(symbolTable),
mExtensionBehavior(extensionBehavior)
{ {
} }
...@@ -349,10 +351,17 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol) ...@@ -349,10 +351,17 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
info.name = kName; info.name = kName;
info.mappedName = kName; info.mappedName = kName;
info.type = GL_FLOAT_VEC4; info.type = GL_FLOAT_VEC4;
info.arraySize = static_cast<const TVariable *>( if (::IsExtensionEnabled(mExtensionBehavior, "GL_EXT_draw_buffers"))
mSymbolTable.findBuiltIn("gl_MaxDrawBuffers", 100)) {
->getConstPointer() info.arraySize = static_cast<const TVariable *>(
->getIConst(); mSymbolTable.findBuiltIn("gl_MaxDrawBuffers", 100))
->getConstPointer()
->getIConst();
}
else
{
info.arraySize = 1;
}
info.precision = GL_MEDIUM_FLOAT; // Defined by spec. info.precision = GL_MEDIUM_FLOAT; // Defined by spec.
info.staticUse = true; info.staticUse = true;
mOutputVariables->push_back(info); mOutputVariables->push_back(info);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <GLSLANG/ShaderLang.h> #include <GLSLANG/ShaderLang.h>
#include "compiler/translator/ExtensionBehavior.h"
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
class TSymbolTable; class TSymbolTable;
...@@ -26,7 +27,8 @@ class CollectVariables : public TIntermTraverser ...@@ -26,7 +27,8 @@ class CollectVariables : public TIntermTraverser
std::vector<Varying> *varyings, std::vector<Varying> *varyings,
std::vector<InterfaceBlock> *interfaceBlocks, std::vector<InterfaceBlock> *interfaceBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
const TSymbolTable &symbolTable); const TSymbolTable &symbolTable,
const TExtensionBehavior &extensionBehavior);
void visitSymbol(TIntermSymbol *symbol) override; void visitSymbol(TIntermSymbol *symbol) override;
bool visitAggregate(Visit, TIntermAggregate *node) override; bool visitAggregate(Visit, TIntermAggregate *node) override;
...@@ -67,6 +69,7 @@ class CollectVariables : public TIntermTraverser ...@@ -67,6 +69,7 @@ class CollectVariables : public TIntermTraverser
ShHashFunction64 mHashFunction; ShHashFunction64 mHashFunction;
const TSymbolTable &mSymbolTable; const TSymbolTable &mSymbolTable;
const TExtensionBehavior &mExtensionBehavior;
}; };
void ExpandVariable(const ShaderVariable &variable, 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