OSDN Git Service

Don't validate glTexSubImage2D bounds for native buffer target
authorLingfeng Yang <lfy@google.com>
Tue, 21 Mar 2017 21:49:58 +0000 (14:49 -0700)
committerLingfeng Yang <lfy@google.com>
Tue, 21 Mar 2017 23:40:43 +0000 (16:40 -0700)
bug: 36372213

We validate glTexSubImage2D having enough width/height/depth to work
correctly, by tracking glTexImage2D / glTexStorage2D calls,
but this breaks down once we put EGL images in the mix.

Previously we skipped validation for EGL_GL_TEXTURE_2D targets, but
it looks like for O and up, we also need to skip this validation for
EGL_NATIVE_BUFFER_ANDROID targets.

Change-Id: I68e6049a00e7f0927fc4097a36564b88aea1ff00

system/GLESv2/gl2.cpp

index 05d5db0..b75f899 100644 (file)
@@ -57,6 +57,7 @@ void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES img)
     DBG("glEGLImageTargetTexture2DOES v2 target=%#x img=%p\n", target, img);
 
     EGLImage_t *image = (EGLImage_t*)img;
+    GLeglImageOES hostImage = reinterpret_cast<GLeglImageOES>((intptr_t)image->host_egl_image);
 
     if (image->target == EGL_NATIVE_BUFFER_ANDROID) {
         //TODO: check error - we don't have a way to set gl error
@@ -74,13 +75,13 @@ void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES img)
         DEFINE_AND_VALIDATE_HOST_CONNECTION();
 
         ctx->override2DTextureTarget(target);
+        ctx->associateEGLImage(target, hostImage);
         rcEnc->rcBindTexture(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle);
         ctx->restore2DTextureTarget(target);
     }
     else if (image->target == EGL_GL_TEXTURE_2D_KHR) {
         GET_CONTEXT;
         ctx->override2DTextureTarget(target);
-        GLeglImageOES hostImage = reinterpret_cast<GLeglImageOES>((intptr_t)image->host_egl_image);
         ctx->associateEGLImage(target, hostImage);
         ctx->m_glEGLImageTargetTexture2DOES_enc(self, target, hostImage);
         ctx->restore2DTextureTarget(target);