Report gl_MaxDrawBuffers as 1 when the MRT extension is disabled, and the implementation value otherwise.
TRAC #22888
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Author: Jamie Madill
git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2155 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Initialize.cpp b/src/compiler/Initialize.cpp
index 97b46f8..3b71b72 100644
--- a/src/compiler/Initialize.cpp
+++ b/src/compiler/Initialize.cpp
@@ -475,7 +475,7 @@
// Implementation dependent built-in constants.
//
//============================================================================
-static TString BuiltInConstants(ShShaderSpec spec, const ShBuiltInResources &resources)
+static TString BuiltInConstants(ShShaderSpec spec, const ShBuiltInResources &resources, const TExtensionBehavior& extensionBehavior)
{
TStringStream s;
@@ -489,13 +489,20 @@
s << "const int gl_MaxFragmentUniformVectors = " << resources.MaxFragmentUniformVectors << ";";
if (spec != SH_CSS_SHADERS_SPEC)
- s << "const int gl_MaxDrawBuffers = " << resources.MaxDrawBuffers << ";";
+ {
+ TExtensionBehavior::const_iterator iter = extensionBehavior.find("GL_EXT_draw_buffers");
+ const bool usingMRTExtension = (iter != extensionBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire));
+ const int maxDrawBuffers = (usingMRTExtension ? resources.MaxDrawBuffers : 1);
+
+ s << "const int gl_MaxDrawBuffers = " << maxDrawBuffers << ";";
+ }
return s.str();
}
void TBuiltIns::initialize(ShShaderType type, ShShaderSpec spec,
- const ShBuiltInResources& resources)
+ const ShBuiltInResources& resources,
+ const TExtensionBehavior& extensionBehavior)
{
switch (type) {
case SH_FRAGMENT_SHADER:
@@ -515,7 +522,7 @@
default: assert(false && "Language not supported");
}
- builtInStrings.push_back(BuiltInConstants(spec, resources));
+ builtInStrings.push_back(BuiltInConstants(spec, resources, extensionBehavior));
}
void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,