Commit 5d287f50 by Jamie Madill Committed by Shannon Woods

Only allow zero indexes for gl_FragData when the draw buffers extension is disabled.

TRAC #23509 Signed-off-by: Shannon Woods Signed-off-by: Nicolas Capens Authored-by: Jamie Madill
parent 75fb4752
...@@ -964,6 +964,19 @@ bool TParseContext::supportsExtension(const char* extension) ...@@ -964,6 +964,19 @@ bool TParseContext::supportsExtension(const char* extension)
return (iter != extbehavior.end()); return (iter != extbehavior.end());
} }
bool TParseContext::isExtensionEnabled(const char* extension) const
{
const TExtensionBehavior& extbehavior = extensionBehavior();
auto iter = extbehavior.find(extension);
if (iter == extbehavior.end())
{
return false;
}
return (iter->second == EBhEnable || iter->second == EBhRequire);
}
void TParseContext::handleExtensionDirective(const TSourceLoc& loc, const char* extName, const char* behavior) void TParseContext::handleExtensionDirective(const TSourceLoc& loc, const char* extName, const char* behavior)
{ {
pp::SourceLocation srcLoc; pp::SourceLocation srcLoc;
...@@ -2100,6 +2113,12 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co ...@@ -2100,6 +2113,12 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co
recover(); recover();
index = baseExpression->getType().getArraySize() - 1; index = baseExpression->getType().getArraySize() - 1;
} }
else if (baseExpression->getQualifier() == EvqFragData && index > 0 && !isExtensionEnabled("GL_EXT_draw_buffers"))
{
error(location, "", "[", "array indexes for gl_FragData must be zero when GL_EXT_draw_buffers is disabled");
recover();
index = 0;
}
} }
else if ((baseExpression->isVector() || baseExpression->isMatrix()) && baseExpression->getType().getNominalSize() <= index) else if ((baseExpression->isVector() || baseExpression->isMatrix()) && baseExpression->getType().getNominalSize() <= index)
{ {
......
...@@ -111,6 +111,7 @@ struct TParseContext { ...@@ -111,6 +111,7 @@ struct TParseContext {
const TPragma& pragma() const { return directiveHandler.pragma(); } const TPragma& pragma() const { return directiveHandler.pragma(); }
const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); } const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); }
bool supportsExtension(const char* extension); bool supportsExtension(const char* extension);
bool isExtensionEnabled(const char* extension) const;
void handleExtensionDirective(const TSourceLoc& loc, const char* extName, const char* behavior); void handleExtensionDirective(const TSourceLoc& loc, const char* extName, const char* behavior);
void handlePragmaDirective(const TSourceLoc& loc, const char* name, const char* value); void handlePragmaDirective(const TSourceLoc& loc, const char* name, const char* value);
......
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