Don't actually call glGetShaderPrecisionFormat unless running either on a GLES2 implementation or unit tests. Calling it on some Mac OS OpenGL drivers causes a GL_INVALID_OPERATION which breaks either the WebGL implementation or applications later.
This should have been caught by the GPU bots.
Tested with WebGL conformance tests, the shiny-teapot demo, and gpu_unittests.
BUG=192533
Review URL: https://codereview.chromium.org/12544023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188216 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index c9fd9ff..0d6ba07 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -107,10 +107,18 @@
break;
}
- if (gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) {
+ // TODO(kbr): fix this to not require testing for the mock. Tests
+ // should be able to change what GetGLImplementation returns in
+ // order to test all code paths.
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL ||
+ (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
+ gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn)) {
// This function is sometimes defined even though it's really just
// a stub, so we need to set range and precision as if it weren't
// defined before calling it.
+ // On Mac OS with some GPUs, calling this generates a
+ // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2
+ // platforms.
glGetShaderPrecisionFormat(shader_type, precision_type,
range, precision);
}