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/dx11proto@2050 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp
index c8c79e7..804d332 100644
--- a/src/compiler/Compiler.cpp
+++ b/src/compiler/Compiler.cpp
@@ -244,7 +244,7 @@
TBuiltIns builtIns;
compileResources = resources;
- builtIns.initialize(shaderType, shaderSpec, resources);
+ builtIns.initialize(shaderType, shaderSpec, resources, extensionBehavior);
return InitializeSymbolTable(builtIns.getBuiltInStrings(),
shaderType, shaderSpec, resources, infoSink, symbolTable);
}
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,
diff --git a/src/compiler/Initialize.h b/src/compiler/Initialize.h
index 8b0adc6..c76a05a 100644
--- a/src/compiler/Initialize.h
+++ b/src/compiler/Initialize.h
@@ -18,7 +18,8 @@
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
void initialize(ShShaderType type, ShShaderSpec spec,
- const ShBuiltInResources& resources);
+ const ShBuiltInResources& resources,
+ const TExtensionBehavior& extensionBehavior);
const TBuiltInStrings& getBuiltInStrings() { return builtInStrings; }
protected: