diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-07-09 06:43:34 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-07-09 06:43:34 +0000 |
commit | 2cc4bcd8508ae53860fe85c6489f2b231fa8439a (patch) | |
tree | c3898f87509e31f613213fc00dad1423e0462653 | |
parent | 1374537c2af65d9ec610637a1a6a5efb9ffacf40 (diff) | |
parent | c9b597b947d1f223bfb4c72e40da0f50e009891c (diff) | |
download | goldfish-opengl-2cc4bcd8508ae53860fe85c6489f2b231fa8439a.tar.gz |
Merge "Fix invalid glGetIntegerv queries mangling return values"
-rwxr-xr-x | system/GLESv2_enc/GL2Encoder.cpp | 22 | ||||
-rw-r--r-- | system/GLESv2_enc/GL2Encoder.h | 8 | ||||
-rw-r--r-- | system/egl/egl.cpp | 9 |
3 files changed, 38 insertions, 1 deletions
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp index 3c37a821..11be3c7f 100755 --- a/system/GLESv2_enc/GL2Encoder.cpp +++ b/system/GLESv2_enc/GL2Encoder.cpp @@ -634,6 +634,28 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr) case GL_MAX_DEPTH_TEXTURE_SAMPLES: *ptr = 4; break; + // Checks for version-incompatible enums. + // Not allowed in vanilla ES 2.0. + case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: + case GL_MAX_UNIFORM_BUFFER_BINDINGS: + SET_ERROR_IF(ctx->majorVersion() < 3, GL_INVALID_ENUM); + ctx->m_glGetIntegerv_enc(self, param, ptr); + break; + case GL_MAX_COLOR_ATTACHMENTS: + case GL_MAX_DRAW_BUFFERS: + SET_ERROR_IF(ctx->majorVersion() < 3 && + !ctx->hasExtension("GL_EXT_draw_buffers"), GL_INVALID_ENUM); + ctx->m_glGetIntegerv_enc(self, param, ptr); + break; + // Not allowed in ES 3.0. + case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS: + case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: + case GL_MAX_VERTEX_ATTRIB_BINDINGS: + SET_ERROR_IF(ctx->majorVersion() < 3 || + (ctx->majorVersion() == 3 && + ctx->minorVersion() == 0), GL_INVALID_ENUM); + ctx->m_glGetIntegerv_enc(self, param, ptr); + break; default: if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) { ctx->m_glGetIntegerv_enc(self, param, ptr); diff --git a/system/GLESv2_enc/GL2Encoder.h b/system/GLESv2_enc/GL2Encoder.h index 11162ee6..730651fa 100644 --- a/system/GLESv2_enc/GL2Encoder.h +++ b/system/GLESv2_enc/GL2Encoder.h @@ -30,6 +30,14 @@ public: void setClientState(GLClientState *state) { m_state = state; } + void setVersion(int major, int minor, + int deviceMajor, int deviceMinor) { + m_currMajorVersion = major; + m_currMinorVersion = minor; + m_deviceMajorVersion = deviceMajor; + m_deviceMinorVersion = deviceMinor; + ALOGD("%s: maj min %d %d\n", __FUNCTION__, major, minor); + } void setClientStateMakeCurrent(GLClientState *state, int majorVersion, int minorVersion, diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp index 66a8a45e..185fbc94 100644 --- a/system/egl/egl.cpp +++ b/system/egl/egl.cpp @@ -1561,6 +1561,13 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC ClientAPIExts::initClientFuncs(s_display.gles2_iface(), 1); } if (contextState->needsInitFromCaps()) { + // Need to set the version first if + // querying caps, or validation will trip incorrectly. + hostCon->gl2Encoder()->setVersion( + context->majorVersion, + context->minorVersion, + context->deviceMajorVersion, + context->deviceMinorVersion); // Get caps for indexed buffers from host. // Some need a current context. int max_transform_feedback_separate_attribs = 0; @@ -1598,7 +1605,7 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC max_draw_buffers); } - // set the client state and share group + // update the client state, share group, and version if (context->majorVersion > 1) { hostCon->gl2Encoder()->setClientStateMakeCurrent( contextState, |