OSDN Git Service

GL2Encoder: Do not forward GLES API version queries
authorYu Ning <yu.ning@intel.com>
Tue, 31 May 2016 08:40:54 +0000 (16:40 +0800)
committerYahan Zhou <yahan@google.com>
Thu, 1 Dec 2016 01:33:08 +0000 (17:33 -0800)
Original author: Chenglangjie Yang <chenglangjie.yang@intel.com>

GLESv3 adds two additional glGetIntegerv() parameters for returning
GLES API version number: GL_MAJOR_VERSION and GL_MINOR_VERSION. They
are not supported by GLESv2, though. Compare:

(v3) https://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
(v2) https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml

dEQP actually uses this API to determine if the device being tested
supports GLESv3. If GL2Encoder just forwards such queries to the
host, the result will be the desktop GL API version implemented by
the host GPU driver, which is almost always >= 3.0. This can mislead
dEQP into treating the emulated device as GLESv3-compatible, and
cause various GLESv2 tests to fail.

When applied to AOSP master, this patch fixes various dEQP-GLES2
failures in the following packages:

 dEQP-GLES2.functional.fbo.completeness.renderable.*
 dEQP-GLES2.functional.negative_api.*
 dEQP-GLES2.functional.draw.random
 dEQP-GLES2.functional.rasterization.primitives

When applied to Partner m-emu-dev, it causes a few regressions in
dEQP-GLES2 (actually false negatives), which will be addressed by
two other patches.

Change-Id: I801144aeee922d90af4c7dda6af68dcc0a40fb6d
Signed-off-by: Chenglangjie Yang <chenglangjie.yang@intel.com>
[Revised code and commit message]
Signed-off-by: Yu Ning <yu.ning@intel.com>
system/GLESv2_enc/GL2Encoder.cpp

index 544c8cc..075523b 100755 (executable)
@@ -33,12 +33,16 @@ static GLubyte *gRendererString= (GLubyte *) "Android HW-GLES 2.0";
 static GLubyte *gVersionString= (GLubyte *) "OpenGL ES 2.0";
 static GLubyte *gExtensionsString= (GLubyte *) "GL_OES_EGL_image_external ";
 
-#define SET_ERROR_IF(condition,err) if((condition)) {                            \
+#define SET_ERROR(err) {                            \
         ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
         ctx->setError(err);                                    \
         return;                                                  \
     }
 
+#define SET_ERROR_IF(condition,err) if((condition)) {                            \
+        SET_ERROR(err)                                                           \
+    }
+
 
 #define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {                \
         ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
@@ -305,6 +309,12 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
     GLClientState* state = ctx->m_state;
 
     switch (param) {
+    case GL_MAJOR_VERSION:
+    case GL_MINOR_VERSION:
+        // These two parameters are not supported by GLESv2
+        // TODO: Set *ptr appropriately when GLESv3 support is ready
+        SET_ERROR(GL_INVALID_ENUM);
+
     case GL_NUM_SHADER_BINARY_FORMATS:
         *ptr = 0;
         break;