Allow tests to pass with a ES3+ context.
Setting gl_MaxDrawBuffers ref value to GL_MAX_DRAW_BUFFERS for ES3 context.
Reduce code duplication where the same check exists in other tests.
Components: OpenGL ES
VK-GL-CTS issue: 2011
Affected tests:
dEQP-GLES2.functional.shaders.builtin_variable.max_draw_buffers_vertex
dEQP-GLES2.functional.shaders.builtin_variable.max_draw_buffers_fragment
dEQP-GLES2.functional.negative_api.buffer.framebuffer_texture2d
dEQP-GLES2.functional.texture.mipmap.cube.*
Change-Id: I6c5e522940256c98b54e5533f29fdafeac60a256
(cherry picked from commit 96d4f7bafa35a9567eef5c4d7658a316837b8a0b)
diff --git a/framework/opengl/gluContextInfo.cpp b/framework/opengl/gluContextInfo.cpp
index 27d5583..a253a2e 100644
--- a/framework/opengl/gluContextInfo.cpp
+++ b/framework/opengl/gluContextInfo.cpp
@@ -247,6 +247,21 @@
return std::find(extensions.begin(), extensions.end(), name) != extensions.end();
}
+bool ContextInfo::isES3Compatible() const
+{
+ // Detect compatible GLES context by querying GL_MAJOR_VERSION.
+ // This query does not exist on GLES2 so succeeding query implies GLES3+ context.
+ bool isES3Compatible = false;
+ glw::GLint majorVersion = 0;
+ const glw::Functions& gl = m_context.getFunctions();
+ gl.getError();
+ gl.getIntegerv(GL_MAJOR_VERSION, &majorVersion);
+ if (gl.getError() == GL_NO_ERROR)
+ isES3Compatible = true;
+
+ return isES3Compatible;
+}
+
ContextInfo* ContextInfo::create (const RenderContext& context)
{
// ES2 uses special variant that checks support for various shader features
diff --git a/framework/opengl/gluContextInfo.hpp b/framework/opengl/gluContextInfo.hpp
index 9bb9088..1e775f2 100644
--- a/framework/opengl/gluContextInfo.hpp
+++ b/framework/opengl/gluContextInfo.hpp
@@ -92,6 +92,8 @@
const std::vector<std::string>& getExtensions (void) const { return m_extensions; }
bool isExtensionSupported (const char* extName) const;
+ bool isES3Compatible() const;
+
static ContextInfo* create (const RenderContext& context);
protected:
diff --git a/modules/gles2/functional/es2fNegativeBufferApiTests.cpp b/modules/gles2/functional/es2fNegativeBufferApiTests.cpp
index 043903a..467c38b 100644
--- a/modules/gles2/functional/es2fNegativeBufferApiTests.cpp
+++ b/modules/gles2/functional/es2fNegativeBufferApiTests.cpp
@@ -340,15 +340,8 @@
expectError(GL_INVALID_ENUM);
m_log << TestLog::EndSection;
- // Detect compatible GLES context by querying GL_MAJOR_VERSION.
- // This query does not exist on GLES2 so succeeding query implies GLES3+ context.
- bool isES3Compatible = false;
- glw::GLint majorVersion = 0;
- glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
- if (glGetError() == GL_NO_ERROR)
- isES3Compatible = true;
-
- if (!(m_context.getContextInfo().isExtensionSupported("GL_OES_fbo_render_mipmap") || isES3Compatible))
+ if (!(m_context.getContextInfo().isExtensionSupported("GL_OES_fbo_render_mipmap") ||
+ m_context.getContextInfo().isES3Compatible()))
{
m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is not 0.");
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 3);
diff --git a/modules/gles2/functional/es2fShaderBuiltinVarTests.cpp b/modules/gles2/functional/es2fShaderBuiltinVarTests.cpp
index 4299491..09176f2 100644
--- a/modules/gles2/functional/es2fShaderBuiltinVarTests.cpp
+++ b/modules/gles2/functional/es2fShaderBuiltinVarTests.cpp
@@ -87,7 +87,8 @@
if (m_varName == "gl_MaxDrawBuffers")
{
if (m_ctxInfo.isExtensionSupported("GL_EXT_draw_buffers") ||
- m_ctxInfo.isExtensionSupported("GL_NV_draw_buffers"))
+ m_ctxInfo.isExtensionSupported("GL_NV_draw_buffers") ||
+ m_ctxInfo.isES3Compatible())
return m_ctxInfo.getInt(GL_MAX_DRAW_BUFFERS);
else
return 1;
diff --git a/modules/gles2/functional/es2fTextureMipmapTests.cpp b/modules/gles2/functional/es2fTextureMipmapTests.cpp
index 56ca396..6ba4c5f 100644
--- a/modules/gles2/functional/es2fTextureMipmapTests.cpp
+++ b/modules/gles2/functional/es2fTextureMipmapTests.cpp
@@ -600,13 +600,7 @@
if (viewport.width < defViewportWidth/2 || viewport.height < defViewportHeight/2)
throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
- // Detect compatible GLES context by querying GL_MAJOR_VERSION.
- // This query does not exist on GLES2 so succeeding query implies GLES3+ context.
- bool isES3Compatible = false;
- glw::GLint majorVersion = 0;
- gl.getIntegerv(GL_MAJOR_VERSION, &majorVersion);
- if (gl.getError() == GL_NO_ERROR)
- isES3Compatible = true;
+ bool isES3Compatible = m_renderCtxInfo.isES3Compatible();
// Upload texture data.
m_texture->upload();