coregl_fastpath: remove gl_color_writemask_for_glColorMask 55/106755/1
authorxing.huang <xing.huang@samsung.com>
Fri, 23 Dec 2016 01:15:39 +0000 (09:15 +0800)
committerxing.huang <xing.huang@samsung.com>
Fri, 23 Dec 2016 01:25:08 +0000 (09:25 +0800)
1.glColorMask and glColorMaski should share the same state.
2.add GL_CLOR_WRITEMASK_NUM to define the size of gl_color_writemask

Signed-off-by: xing.huang <xing.huang@samsung.com>
Change-Id: I534fb2a8094495571596e033efb287a75ecde486

src/modules/fastpath/coregl_fastpath.c
src/modules/fastpath/coregl_fastpath.h
src/modules/fastpath/coregl_fastpath_gl.c
src/modules/fastpath/coregl_fastpath_state.h
src/modules/tracepath/coregl_tracepath.c

index d6b6818..cab9955 100644 (file)
@@ -2148,21 +2148,18 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
        flag = oldctx->_clear_flag2 | newctx->_clear_flag2;
        if (flag) {
                if STATES_COMPARE(gl_color_writemask,
-                                                 4 * newctx->gl_color_writemask_num[0] * sizeof(GLboolean)) {
-                       for (i = 0; i < newctx->gl_color_writemask_num[0]; i++) {
-                               CHECK_GL_ERROR(_orig_fastpath_glColorMaski(i,
-                                                          (newctx->gl_color_writemask + i)[0],
-                                                          (newctx->gl_color_writemask + i)[1],
-                                                          (newctx->gl_color_writemask + i)[2],
-                                                          (newctx->gl_color_writemask + i)[3]))
+                                                 4 * GL_CLOR_WRITEMASK_NUM * sizeof(GLboolean)) {
+                       for (i = 0; i < GL_CLOR_WRITEMASK_NUM; i++) {
+                               if(NULL != _orig_fastpath_glColorMaski)
+                               {
+                                       CHECK_GL_ERROR(_orig_fastpath_glColorMaski(i,
+                                                                  (newctx->gl_color_writemask + i)[0],
+                                                                  (newctx->gl_color_writemask + i)[1],
+                                                                  (newctx->gl_color_writemask + i)[2],
+                                                                  (newctx->gl_color_writemask + i)[3]))
+                               }
                        }
                }
-               if STATES_COMPARE(gl_color_writemask_for_glColorMask, 4 * sizeof(GLboolean)) {
-                       CHECK_GL_ERROR(_orig_fastpath_glColorMask(newctx->gl_color_writemask_for_glColorMask[0],
-                                                  newctx->gl_color_writemask_for_glColorMask[1],
-                                                  newctx->gl_color_writemask_for_glColorMask[2],
-                                                  newctx->gl_color_writemask_for_glColorMask[3]))
-               }
                if STATES_COMPARE(gl_depth_range, 2 * sizeof(GLclampf)) {
                        CHECK_GL_ERROR(_orig_fastpath_glDepthRangef(newctx->gl_depth_range[0],
                                                   newctx->gl_depth_range[1]))
index 19322ab..bb7a837 100644 (file)
@@ -276,8 +276,6 @@ typedef struct _GLGlueContext {
 #define _CLEAR_FLAG2_BIT_gl_depth_func          FLAG_BIT_3
 #define _CLEAR_FLAG2_BIT_gl_depth_writemask     FLAG_BIT_4
 #define _CLEAR_FLAG2_BIT_gl_cull_face_mode      FLAG_BIT_5
-#define _CLEAR_FLAG2_BIT_gl_color_writemask_for_glColorMask     FLAG_BIT_6
-
 
        unsigned char           _tex_flag1;
 #define _TEX_FLAG1_BIT_gl_active_texture         FLAG_BIT_0
index bf04acf..9c9f6c2 100644 (file)
@@ -3154,17 +3154,27 @@ fastpath_glColorMask(GLboolean red, GLboolean green, GLboolean blue,
        DEFINE_FASTPAH_GL_FUNC();
        _COREGL_FASTPATH_FUNC_BEGIN();
        INIT_FASTPATH_GL_FUNC();
+       GLint index;
+       GLboolean changed = GL_FALSE;
 
-       if (CURR_STATE_COMPARE(gl_color_writemask_for_glColorMask, 0, red) ||
-                       CURR_STATE_COMPARE(gl_color_writemask_for_glColorMask, 1, green) ||
-                       CURR_STATE_COMPARE(gl_color_writemask_for_glColorMask, 2, blue) ||
-                       CURR_STATE_COMPARE(gl_color_writemask_for_glColorMask, 3, alpha)) {
+       for (index = 0; index < GL_CLOR_WRITEMASK_NUM; index++) {
+               if (CURR_STATE_COMPARE(gl_color_writemask, 0 + 4 * index, red) ||
+                               CURR_STATE_COMPARE(gl_color_writemask, 1 + 4 * index, green) ||
+                               CURR_STATE_COMPARE(gl_color_writemask, 2 + 4 * index, blue) ||
+                               CURR_STATE_COMPARE(gl_color_writemask, 3 + 4 * index, alpha))
+                       changed = GL_TRUE;
+
+       }
+
+       if (changed) {
                IF_GL_SUCCESS(_orig_fastpath_glColorMask(red, green, blue, alpha)) {
-                       current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_color_writemask_for_glColorMask;
-                       CURR_STATE_UPDATE(gl_color_writemask_for_glColorMask, 0, red)
-                       CURR_STATE_UPDATE(gl_color_writemask_for_glColorMask, 1, green)
-                       CURR_STATE_UPDATE(gl_color_writemask_for_glColorMask, 2, blue)
-                       CURR_STATE_UPDATE(gl_color_writemask_for_glColorMask, 3, alpha)
+                       current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_color_writemask;
+                       for (index = 0; index < GL_CLOR_WRITEMASK_NUM; index++) {
+                               CURR_STATE_UPDATE(gl_color_writemask, 0 + 4 * index, red)
+                               CURR_STATE_UPDATE(gl_color_writemask, 1 + 4 * index, green)
+                               CURR_STATE_UPDATE(gl_color_writemask, 2 + 4 * index, blue)
+                               CURR_STATE_UPDATE(gl_color_writemask, 3 + 4 * index, alpha)
+                       }
                }
        }
        goto finish;
index 855fd32..5634860 100644 (file)
@@ -12,6 +12,9 @@
 #define _COREGL_END_API_DEFINED_INSIDE
 #endif
 
+/*this size can be get by glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS)
+  but in r4p0, it dose not support GL_MAX_COLOR_ATTACHMENTS */
+#define GL_CLOR_WRITEMASK_NUM 4
 
 #define SET_1(v1)               value[0] = v1;
 #define SET_2(v1, v2)           value[0] = v1; value[1] = v2;
@@ -62,11 +65,6 @@ GLUE_STATE(GLuint, gl_atomic_counter_buffer_binding_num, 1, 1,
                                                          (GLint *)value); /* DEFAULT NOT EFFECT */,
                   _sym_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, (GLint *)value);)
 
-GLUE_STATE(GLuint, gl_color_writemask_num, 1, 1,
-                  _sym_glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS,
-                                                         (GLint *)value); /* DEFAULT NOT EFFECT */,
-                  _sym_glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, (GLint *)value);)
-
 GLUE_STATE(GLuint, gl_array_buffer_binding, 1, 1, SET_1(0),
                   _sym_glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint *)value);)
 GLUE_STATE(GLuint, gl_copy_read_buffer_binding, 1, 1, SET_1(0),
@@ -294,14 +292,10 @@ GLUE_STATE(GLclampf, gl_color_clear_value, 4, 4, SET_4(0.0f, 0.0f, 0.0f, 0.0f),
                   _sym_glGetFloatv(GL_COLOR_CLEAR_VALUE, (GLfloat *)value);)
 
 GLUE_STATE(GLboolean, gl_color_writemask,
-                  4 * INITIAL_CTX->gl_color_writemask_num[0],
-                  4 * INITIAL_CTX->gl_color_writemask_num[0],
-                  SET_N(4 * INITIAL_CTX->gl_color_writemask_num[0], 1, SET_1(GL_TRUE)),
+                  4 * GL_CLOR_WRITEMASK_NUM,
+                  4 * GL_CLOR_WRITEMASK_NUM,
+                  SET_N(4 * GL_CLOR_WRITEMASK_NUM, 1, SET_1(GL_TRUE)),
                   _sym_glGetBooleanv(GL_COLOR_WRITEMASK, (GLboolean *)value);)
-
-GLUE_STATE(GLboolean, gl_color_writemask_for_glColorMask, 4, 4, SET_4(GL_TRUE, GL_TRUE, GL_TRUE,
-                  GL_TRUE), _sym_glGetBooleanv(GL_COLOR_WRITEMASK, (GLboolean *)value);)
-
 GLUE_STATE(GLclampf, gl_depth_range, 2, 2, SET_2(0.0f, 1.0f),
                   _sym_glGetFloatv(GL_DEPTH_RANGE, (GLfloat *)value);)
 GLUE_STATE(GLclampf, gl_depth_clear_value, 1, 1, SET_1(1.0f),
index 7863cd2..c619d5e 100644 (file)
@@ -72,7 +72,6 @@ typedef struct _GLGlueFakeContext {
        GLuint gl_uniform_buffer_binding_num[1];
        GLuint gl_shader_storage_buffer_binding_num[1];
        GLuint gl_atomic_counter_buffer_binding_num[1];
-       GLuint gl_color_writemask_num[1];
 } GLGlueFakeContext;
 
 GLGlueFakeContext initial_fake_ctx_real;