coregl_fastpath: Fix issue occurs in vertex array Enable/Disabe 15/85215/3
authorZhaowei Yuan <zhaowei.yuan@samsung.com>
Tue, 23 Aug 2016 19:30:15 +0000 (03:30 +0800)
committerGwan-gyeong Mun <kk.moon@samsung.com>
Fri, 26 Aug 2016 11:54:16 +0000 (04:54 -0700)
Whether an vertex array is bounded or not, value of
state gl_vertex_array_enabled should be always
updated once fastpath_glEnableVertexAttribArray or
fastpath_glDisableVertexAttribArray is called, if not,
it will cause state confusion

Once an vertex array is unbounded or an new vertex
array is bounded, value of state gl_vertex_array_enabled
should be cleared

Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
Change-Id: I7d686cc603dfb74e305c64687eaea36be6f1aea1

src/modules/fastpath/coregl_fastpath_gl.c

index fff59f9..1f397c6 100644 (file)
@@ -3361,10 +3361,8 @@ fastpath_glEnableVertexAttribArray(GLuint index)
 
        if CURR_STATE_COMPARE(gl_vertex_array_enabled, index, GL_TRUE) {
                IF_GL_SUCCESS(_orig_fastpath_glEnableVertexAttribArray(index)) {
-                       if (current_ctx->gl_vertex_array_binding[0] == 0) {
-                               current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
-                               CURR_STATE_UPDATE(gl_vertex_array_enabled, index, GL_TRUE)
-                       }
+                       current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
+                       CURR_STATE_UPDATE(gl_vertex_array_enabled, index, GL_TRUE)
                }
        }
 
@@ -3383,10 +3381,8 @@ fastpath_glDisableVertexAttribArray(GLuint index)
 
        if CURR_STATE_COMPARE(gl_vertex_array_enabled, index, GL_FALSE) {
                IF_GL_SUCCESS(_orig_fastpath_glDisableVertexAttribArray(index)) {
-                       if (current_ctx->gl_vertex_array_binding[0] == 0) {
-                               current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
-                               CURR_STATE_UPDATE(gl_vertex_array_enabled, index, GL_FALSE)
-                       }
+                       current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
+                       CURR_STATE_UPDATE(gl_vertex_array_enabled, index, GL_FALSE)
                }
        }
 
@@ -3396,7 +3392,6 @@ finish:
        _COREGL_FASTPATH_FUNC_END();
 }
 
-
 void
 fastpath_glFrontFace(GLenum mode)
 {
@@ -4693,6 +4688,7 @@ void
 fastpath_glBindVertexArray(GLuint array)
 {
        GLuint real_obj;
+       int i;
 
        DEFINE_FASTPAH_GL_FUNC();
        _COREGL_FASTPATH_FUNC_BEGIN();
@@ -4703,10 +4699,20 @@ fastpath_glBindVertexArray(GLuint array)
                goto finish;
        }
 
-       if (CURR_STATE_COMPARE(gl_vertex_array_binding, 0, real_obj)) {
+       if(real_obj == 0) {
+               IF_GL_SUCCESS(_orig_fastpath_glBindVertexArray(real_obj)) {
+                       current_ctx->_misc_flag3 &= ~(_MISC_FLAG3_BIT_gl_vertex_array_binding);
+                       CURR_STATE_CLEAR(gl_vertex_array_binding, 0)
+                       for(i = 0; i < current_ctx->gl_vertex_attribs_num[0]; i++)
+                               CURR_STATE_CLEAR(gl_vertex_array_enabled, i)
+               }
+       }
+       else if (CURR_STATE_COMPARE(gl_vertex_array_binding, 0, real_obj)) {
                IF_GL_SUCCESS(_orig_fastpath_glBindVertexArray(real_obj)) {
                        current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_vertex_array_binding;
                        CURR_STATE_UPDATE(gl_vertex_array_binding, 0, real_obj)
+                       for(i = 0; i < current_ctx->gl_vertex_attribs_num[0]; i++)
+                               CURR_STATE_CLEAR(gl_vertex_array_enabled, i)
                }
        }
        goto finish;
@@ -8207,11 +8213,11 @@ finish:
        _COREGL_FASTPATH_FUNC_END();
 }
 
-
 void
 fastpath_glBindVertexArrayOES(GLuint array)
 {
        GLuint real_obj;
+       int i;
 
        DEFINE_FASTPAH_GL_FUNC();
        _COREGL_FASTPATH_FUNC_BEGIN();
@@ -8221,10 +8227,21 @@ fastpath_glBindVertexArrayOES(GLuint array)
                _set_gl_error(GL_INVALID_OPERATION);
                goto finish;
        }
-       if (CURR_STATE_COMPARE(gl_vertex_array_binding, 0, real_obj)) {
+
+       if(real_obj == 0) {
+               IF_GL_SUCCESS(_orig_fastpath_glBindVertexArrayOES(real_obj)) {
+                       current_ctx->_misc_flag3 &= ~(_MISC_FLAG3_BIT_gl_vertex_array_binding);
+                       CURR_STATE_CLEAR(gl_vertex_array_binding, 0)
+                       for(i = 0; i < current_ctx->gl_vertex_attribs_num[0]; i++)
+                               CURR_STATE_CLEAR(gl_vertex_array_enabled, i)
+               }
+       }
+       else if (CURR_STATE_COMPARE(gl_vertex_array_binding, 0, real_obj)) {
                IF_GL_SUCCESS(_orig_fastpath_glBindVertexArrayOES(real_obj)) {
                        current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_vertex_array_binding;
                        CURR_STATE_UPDATE(gl_vertex_array_binding, 0, real_obj)
+                       for(i = 0; i < current_ctx->gl_vertex_attribs_num[0]; i++)
+                               CURR_STATE_CLEAR(gl_vertex_array_enabled, i)
                }
        }
        goto finish;
@@ -8233,7 +8250,6 @@ finish:
        _COREGL_FASTPATH_FUNC_END();
 }
 
-
 GLboolean
 fastpath_glIsVertexArrayOES(GLuint array)
 {