Work around non-compliant behavior for Google Maps.
Bug 18703920
Change-Id: Ifde19f323e4025e2fd2ce24056e38073e373feb3
Reviewed-on: https://swiftshader-review.googlesource.com/2300
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index 6206522..fe2744c 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -2580,6 +2580,26 @@
es2::Context *context = es2::getContext();
+ if(!context)
+ {
+ ERR("glGetIntegerv() called without current context."); // Not strictly an error, but probably unintended or attempting to rely on non-compliant behavior
+
+ // This is not spec compliant! When there is no current GL context, functions should
+ // have no side effects. Google Maps queries these values before creating a context,
+ // so we need this as a bug-compatible workaround.
+ switch(pname)
+ {
+ case GL_MAX_TEXTURE_SIZE: *params = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE; return;
+ case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = es2::MAX_VERTEX_TEXTURE_IMAGE_UNITS; return;
+ case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = es2::MAX_COMBINED_TEXTURE_IMAGE_UNITS; return;
+ case GL_STENCIL_BITS: *params = 8; return;
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ params[0] = (GLint)es2::ALIASED_LINE_WIDTH_RANGE_MIN;
+ params[1] = (GLint)es2::ALIASED_LINE_WIDTH_RANGE_MAX;
+ return;
+ }
+ }
+
if(context)
{
if(!(context->getIntegerv(pname, params)))