From a9e31dec2d59c11edac1effd3569adb2ce558173 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Mon, 8 Aug 2016 01:54:28 +0800 Subject: [PATCH 01/16] coregl_fastpath_egl: Check type before retrieving object Object type of argument buffer maybe either TEXTURE or RENDERBUFFER, check it Signed-off-by: Zhaowei Yuan Change-Id: I5468ef8105d29a6c655b064f2b2406dc9b1655e6 --- src/modules/fastpath/coregl_fastpath_egl.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_egl.c b/src/modules/fastpath/coregl_fastpath_egl.c index 2cce314..ed3bcbc 100644 --- a/src/modules/fastpath/coregl_fastpath_egl.c +++ b/src/modules/fastpath/coregl_fastpath_egl.c @@ -1345,6 +1345,16 @@ fastpath_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, void *ret = NULL; EGLContext real_ctx = EGL_NO_CONTEXT; EGLClientBuffer real_obj; + GL_Object_Type type = 0; + + if((EGLint)buffer & GL_OBJECT_TYPE_TEXTURE) + type = GL_OBJECT_TYPE_TEXTURE; + else if((EGLint)buffer & GL_OBJECT_TYPE_RENDERBUFFER) + type = GL_OBJECT_TYPE_RENDERBUFFER; + else { + COREGL_ERR("\E[40;31;1m fastpath_eglCreateImageKHR buffer type error \E[0m\n"); + goto finish; + } _COREGL_FASTPATH_FUNC_BEGIN(); @@ -1373,8 +1383,7 @@ fastpath_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, real_obj = NULL; } else { real_obj = (EGLClientBuffer)(uintptr_t)fastpath_ostate_get_object(&gctx->ostate, - GL_OBJECT_TYPE_TEXTURE, - (GLuint)(uintptr_t)buffer); + type, (GLuint)(uintptr_t)buffer); } break; default: @@ -1449,6 +1458,7 @@ fastpath_eglGetProcAddress(const char *procname) #include "../../headers/sym_gl1.h" #include "../../headers/sym_gl2.h" #include "../../headers/sym_gl_common.h" + #undef _COREGL_EXT_SYMBOL_FASTPATH_PASS #undef _COREGL_EXT_SYMBOL_FASTPATH_BLOCK -- 2.7.4 From f6913aafe166caa089b37106fa13476e0e4ee036 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Mon, 8 Aug 2016 03:20:04 +0800 Subject: [PATCH 02/16] coregl_fastpath: Add process of some missed state 1. Redefine macro STATE_COMPARE 2. Add handling for state array in function fastpath_make_context_current() Signed-off-by: Zhaowei Yuan Change-Id: I2e3a4b098acfbad02265e3115da38bb0006a31e4 --- src/modules/fastpath/coregl_fastpath.c | 225 ++++++++++++++++++--------- src/modules/fastpath/coregl_fastpath.h | 7 + src/modules/fastpath/coregl_fastpath_state.h | 79 ++++++++++ 3 files changed, 237 insertions(+), 74 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath.c b/src/modules/fastpath/coregl_fastpath.c index 6c44ab9..d7283a0 100644 --- a/src/modules/fastpath/coregl_fastpath.c +++ b/src/modules/fastpath/coregl_fastpath.c @@ -1712,10 +1712,10 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } #define STATE_COMPARE(state) \ - if ((oldctx->state) != (newctx->state)) + ((oldctx->state) != (newctx->state)) #define STATES_COMPARE(state_ptr, bytes) \ - if ((memcmp((oldctx->state_ptr), (newctx->state_ptr), (bytes))) != 0) + ((memcmp((oldctx->state_ptr), (newctx->state_ptr), (bytes))) != 0) #ifdef COREGL_USE_MODULE_TRACEPATH @@ -1754,7 +1754,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER, 0)) } - STATE_COMPARE(gl_vertex_array_divisor[i]) { + if STATE_COMPARE(gl_vertex_array_divisor[i]) { CHECK_GL_ERROR(_orig_fastpath_glVertexAttribDivisor(i, newctx->gl_vertex_array_divisor[i])) } @@ -1807,12 +1807,12 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _bind_flag1 flag = oldctx->_bind_flag1 | newctx->_bind_flag1; if (flag) { - STATE_COMPARE(gl_array_buffer_binding[0]) { + if STATE_COMPARE(gl_array_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ARRAY_BUFFER, newctx->gl_array_buffer_binding[0])) } - STATE_COMPARE(gl_element_array_buffer_binding[0]) { - STATE_COMPARE(gl_vertex_array_binding[0]) { + if STATE_COMPARE(gl_element_array_buffer_binding[0]) { + if STATE_COMPARE(gl_vertex_array_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindVertexArray( newctx->gl_vertex_array_binding[0])) } @@ -1821,7 +1821,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } if (newctx->gl_framebuffer_binding_read_used == 1) { - STATE_COMPARE(gl_framebuffer_binding_read[0]) { + if STATE_COMPARE(gl_framebuffer_binding_read[0]) { if (driver_gl_version >= 2) CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_READ_FRAMEBUFFER, newctx->gl_framebuffer_binding_read[0])) @@ -1829,7 +1829,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) CHECK_GL_ERROR(_orig_fastpath_glBindFramebufferOES(GL_READ_FRAMEBUFFER, newctx->gl_framebuffer_binding_read[0])) } - STATE_COMPARE(gl_framebuffer_binding_draw[0]) { + if STATE_COMPARE(gl_framebuffer_binding_draw[0]) { if (driver_gl_version >= 2) CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, newctx->gl_framebuffer_binding_draw[0])) @@ -1838,7 +1838,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) newctx->gl_framebuffer_binding_draw[0])) } } else { - STATE_COMPARE(gl_framebuffer_binding[0]) { + if STATE_COMPARE(gl_framebuffer_binding[0]) { if (driver_gl_version >= 2) CHECK_GL_ERROR(_orig_fastpath_glBindFramebuffer(GL_FRAMEBUFFER, newctx->gl_framebuffer_binding[0])) @@ -1847,7 +1847,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) newctx->gl_framebuffer_binding[0])) } } - STATE_COMPARE(gl_renderbuffer_binding[0]) { + if STATE_COMPARE(gl_renderbuffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindRenderbuffer(GL_RENDERBUFFER, newctx->gl_renderbuffer_binding[0])) } @@ -1857,55 +1857,127 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _bind_flag2 flag = oldctx->_bind_flag2 | newctx->_bind_flag2; if (flag) { - STATE_COMPARE(gl_copy_read_buffer_binding[0]) { + if STATE_COMPARE(gl_copy_read_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_COPY_READ_BUFFER, newctx->gl_copy_read_buffer_binding[0])) } - STATE_COMPARE(gl_copy_write_buffer_binding[0]) { + if STATE_COMPARE(gl_copy_write_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_COPY_WRITE_BUFFER, newctx->gl_copy_write_buffer_binding[0])) } - STATE_COMPARE(gl_pixel_pack_buffer_binding[0]) { + if STATE_COMPARE(gl_pixel_pack_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_PIXEL_PACK_BUFFER, newctx->gl_pixel_pack_buffer_binding[0])) } - STATE_COMPARE(gl_pixel_unpack_buffer_binding[0]) { + if STATE_COMPARE(gl_pixel_unpack_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, newctx->gl_pixel_unpack_buffer_binding[0])) } - STATE_COMPARE(gl_transform_feedback_buffer_binding[0]) { + if STATE_COMPARE(gl_transform_feedback_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, newctx->gl_transform_feedback_buffer_binding[0])) } - STATE_COMPARE(gl_uniform_buffer_binding[0]) { + if STATE_COMPARE(gl_uniform_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_UNIFORM_BUFFER, newctx->gl_uniform_buffer_binding[0])) } + /* handle states set in fastpath_glBindBufferBase() */ + for(i = 0; i < newctx->gl_transform_feedback_buffer_binding_num[0]; i++) { + if STATE_COMPARE(gl_transform_feedback_buffer_binding_array[i]) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, i, + newctx->gl_transform_feedback_buffer_binding_array[i])) + } + } + for(i = 0; i < newctx->gl_uniform_buffer_binding_num[0]; i++) { + if STATE_COMPARE(gl_uniform_buffer_binding_array[i]) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferBase(GL_UNIFORM_BUFFER, i, + newctx->gl_uniform_buffer_binding_array[i])) + } + } } flag = oldctx->_bind_flag3 | newctx->_bind_flag3; if (flag) { - STATE_COMPARE(gl_shader_storage_buffer_binding[0]) { + if STATE_COMPARE(gl_shader_storage_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_SHADER_STORAGE_BUFFER, newctx->gl_shader_storage_buffer_binding[0])) } - STATE_COMPARE(gl_atomic_counter_buffer_binding[0]) { + if STATE_COMPARE(gl_atomic_counter_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, newctx->gl_atomic_counter_buffer_binding[0])) } - STATE_COMPARE(gl_draw_indirect_buffer_binding[0]) { + if STATE_COMPARE(gl_draw_indirect_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_DRAW_INDIRECT_BUFFER, newctx->gl_draw_indirect_buffer_binding[0])) } - STATE_COMPARE(gl_dispatch_indirect_buffer_binding[0]) { + if STATE_COMPARE(gl_dispatch_indirect_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, newctx->gl_dispatch_indirect_buffer_binding[0])) } - STATE_COMPARE(gl_texture_buffer_binding[0]) { + if STATE_COMPARE(gl_texture_buffer_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindBuffer(GL_TEXTURE_BUFFER, newctx->gl_texture_buffer_binding[0])) } + /* handle states set in fastpath_glBindBufferBase() */ + for(i = 0; i < newctx->gl_shader_storage_buffer_binding_num[0]; i++) { + if STATE_COMPARE(gl_shader_storage_buffer_binding_array[i]) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferBase(GL_SHADER_STORAGE_BUFFER, i, + newctx->gl_shader_storage_buffer_binding_array[i])) + } + } + for(i = 0; i < newctx->gl_atomic_counter_buffer_binding_num[0]; i++) { + if STATE_COMPARE(gl_atomic_counter_buffer_binding_array[i]) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, + newctx->gl_atomic_counter_buffer_binding_array[i])) + } + } } + + flag = oldctx->_bind_flag4 | newctx->_bind_flag4; + if(flag) { + /* handle states set in fastpath_BindBufferRrange() */ + for(i = 0; i < newctx->gl_transform_feedback_buffer_binding_num[0]; i++) { + if (STATE_COMPARE(gl_transform_feedback_buffer_range_binding_array[i]) || + STATE_COMPARE(gl_transform_feedback_buffer_range_binding_array_offset[i]) || + STATE_COMPARE(gl_transform_feedback_buffer_range_binding_array_size[i])) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, + newctx->gl_transform_feedback_buffer_range_binding_array[i], + newctx->gl_transform_feedback_buffer_range_binding_array_offset[i], + newctx->gl_transform_feedback_buffer_range_binding_array_size[i])) + } + } + for(i = 0; i < newctx->gl_uniform_buffer_binding_num[0]; i++) { + if (STATE_COMPARE(gl_uniform_buffer_range_binding_array[i]) || + STATE_COMPARE(gl_uniform_buffer_range_binding_array_offset[i]) || + STATE_COMPARE(gl_uniform_buffer_range_binding_array_size[i])) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferRange(GL_UNIFORM_BUFFER, i, + newctx->gl_uniform_buffer_range_binding_array[i], + newctx->gl_uniform_buffer_range_binding_array_offset[i], + newctx->gl_uniform_buffer_range_binding_array_size[i])) + } + } + for(i = 0; i < newctx->gl_shader_storage_buffer_binding_num[0]; i++) { + if (STATE_COMPARE(gl_shader_storage_buffer_range_binding_array[i]) || + STATE_COMPARE(gl_shader_storage_buffer_range_binding_array_offset[i]) || + STATE_COMPARE(gl_shader_storage_buffer_range_binding_array_size[i])) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferRange(GL_SHADER_STORAGE_BUFFER, i, + newctx->gl_shader_storage_buffer_range_binding_array[i], + newctx->gl_shader_storage_buffer_range_binding_array_offset[i], + newctx->gl_shader_storage_buffer_range_binding_array_size[i])) + } + } + for(i = 0; i < newctx->gl_atomic_counter_buffer_binding_num[0]; i++) { + if (STATE_COMPARE(gl_atomic_counter_buffer_range_binding_array[i]) || + STATE_COMPARE(gl_atomic_counter_buffer_range_binding_array_offset[i]) || + STATE_COMPARE(gl_atomic_counter_buffer_range_binding_array_size[i])) { + CHECK_GL_ERROR(_orig_fastpath_glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, i, + newctx->gl_atomic_counter_buffer_range_binding_array[i], + newctx->gl_atomic_counter_buffer_range_binding_array_offset[i], + newctx->gl_atomic_counter_buffer_range_binding_array_size[i])) + } + } + } + #ifdef COREGL_USE_MODULE_TRACEPATH tracepath_api_trace_end("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0); @@ -1924,25 +1996,25 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) flag = oldctx->_enable_flag1 | newctx->_enable_flag1; if (flag) { - STATE_COMPARE(gl_blend[0]) { + if STATE_COMPARE(gl_blend[0]) { if (newctx->gl_blend[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_BLEND)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_BLEND)) } - STATE_COMPARE(gl_cull_face[0]) { + if STATE_COMPARE(gl_cull_face[0]) { if (newctx->gl_cull_face[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_CULL_FACE)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_CULL_FACE)) } - STATE_COMPARE(gl_depth_test[0]) { + if STATE_COMPARE(gl_depth_test[0]) { if (newctx->gl_depth_test[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_DEPTH_TEST)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_DEPTH_TEST)) } - STATE_COMPARE(gl_dither[0]) { + if STATE_COMPARE(gl_dither[0]) { if (newctx->gl_dither[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_DITHER)) } else @@ -1953,43 +2025,43 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _enable_flag2 flag = oldctx->_enable_flag2 | newctx->_enable_flag2; if (flag) { - STATE_COMPARE(gl_polygon_offset_fill[0]) { + if STATE_COMPARE(gl_polygon_offset_fill[0]) { if (newctx->gl_polygon_offset_fill[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_POLYGON_OFFSET_FILL)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_POLYGON_OFFSET_FILL)) } - STATE_COMPARE(gl_sample_alpha_to_coverage[0]) { + if STATE_COMPARE(gl_sample_alpha_to_coverage[0]) { if (newctx->gl_sample_alpha_to_coverage[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE)) } - STATE_COMPARE(gl_sample_coverage[0]) { + if STATE_COMPARE(gl_sample_coverage[0]) { if (newctx->gl_sample_coverage[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_COVERAGE)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_COVERAGE)) } - STATE_COMPARE(gl_scissor_test[0]) { + if STATE_COMPARE(gl_scissor_test[0]) { if (newctx->gl_scissor_test[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SCISSOR_TEST)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SCISSOR_TEST)) } - STATE_COMPARE(gl_stencil_test[0]) { + if STATE_COMPARE(gl_stencil_test[0]) { if (newctx->gl_stencil_test[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_STENCIL_TEST)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_STENCIL_TEST)) } - STATE_COMPARE(gl_sample_shading_oes[0]) { + if STATE_COMPARE(gl_sample_shading_oes[0]) { if (newctx->gl_sample_shading_oes[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_SHADING_OES)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_SHADING_OES)) } - STATE_COMPARE(gl_sample_mask[0]) { + if STATE_COMPARE(gl_sample_mask[0]) { if (newctx->gl_sample_mask[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_SAMPLE_MASK)) } else @@ -2000,19 +2072,19 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _enable_flag3 flag = oldctx->_enable_flag3 | newctx->_enable_flag3; if (flag) { - STATE_COMPARE(gl_primitive_restart_fixed_index[0]) { + if STATE_COMPARE(gl_primitive_restart_fixed_index[0]) { if (newctx->gl_primitive_restart_fixed_index[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX)) } - STATE_COMPARE(gl_rasterizer_discard[0]) { + if STATE_COMPARE(gl_rasterizer_discard[0]) { if (newctx->gl_rasterizer_discard[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_RASTERIZER_DISCARD)) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_RASTERIZER_DISCARD)) } - STATE_COMPARE(gl_blend_advanced_coherent_khr[0]) { + if STATE_COMPARE(gl_blend_advanced_coherent_khr[0]) { if (newctx->gl_blend_advanced_coherent_khr[0]) { CHECK_GL_ERROR(_orig_fastpath_glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)) } else @@ -2037,17 +2109,17 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) flag = oldctx->_clear_flag1 | newctx->_clear_flag1; if (flag) { // Viewport. - STATES_COMPARE(gl_viewport, 4 * sizeof(GLint)) { + if STATES_COMPARE(gl_viewport, 4 * sizeof(GLint)) { CHECK_GL_ERROR(_orig_fastpath_glViewport(newctx->gl_viewport[0], newctx->gl_viewport[1], newctx->gl_viewport[2], newctx->gl_viewport[3])) } - STATE_COMPARE(gl_current_program[0]) { + if STATE_COMPARE(gl_current_program[0]) { CHECK_GL_ERROR(_orig_fastpath_glUseProgram(newctx->gl_current_program[0])) } - STATES_COMPARE(gl_color_clear_value, 4 * sizeof(GLclampf)) { + if STATES_COMPARE(gl_color_clear_value, 4 * sizeof(GLclampf)) { CHECK_GL_ERROR(_orig_fastpath_glClearColor(newctx->gl_color_clear_value[0], newctx->gl_color_clear_value[1], newctx->gl_color_clear_value[2], @@ -2059,26 +2131,26 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _clear_flag2 flag = oldctx->_clear_flag2 | newctx->_clear_flag2; if (flag) { - STATES_COMPARE(gl_color_writemask, 4 * sizeof(GLboolean)) { + if STATES_COMPARE(gl_color_writemask, 4 * sizeof(GLboolean)) { CHECK_GL_ERROR(_orig_fastpath_glColorMask(newctx->gl_color_writemask[0], newctx->gl_color_writemask[1], newctx->gl_color_writemask[2], newctx->gl_color_writemask[3])) } - STATES_COMPARE(gl_depth_range, 2 * sizeof(GLclampf)) { + 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])) } - STATE_COMPARE(gl_depth_clear_value[0]) { + if STATE_COMPARE(gl_depth_clear_value[0]) { CHECK_GL_ERROR(_orig_fastpath_glClearDepthf(newctx->gl_depth_clear_value[0])) } - STATE_COMPARE(gl_depth_func[0]) { + if STATE_COMPARE(gl_depth_func[0]) { CHECK_GL_ERROR(_orig_fastpath_glDepthFunc(newctx->gl_depth_func[0])) } - STATE_COMPARE(gl_depth_writemask[0]) { + if STATE_COMPARE(gl_depth_writemask[0]) { CHECK_GL_ERROR(_orig_fastpath_glDepthMask(newctx->gl_depth_writemask[0])) } - STATE_COMPARE(gl_cull_face_mode[0]) { + if STATE_COMPARE(gl_cull_face_mode[0]) { CHECK_GL_ERROR(_orig_fastpath_glCullFace(newctx->gl_cull_face_mode[0])) } @@ -2102,27 +2174,27 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) if (flag) { for (i = 0; i < oldctx->gl_tex_units_num[0]; i++) { - STATE_COMPARE(gl_tex_2d_state[i]) { + if STATE_COMPARE(gl_tex_2d_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D, newctx->gl_tex_2d_state[i])) } - STATE_COMPARE(gl_tex_3d_state[i]) { + if STATE_COMPARE(gl_tex_3d_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_3D, newctx->gl_tex_3d_state[i])) } - STATE_COMPARE(gl_tex_2d_array_state[i]) { + if STATE_COMPARE(gl_tex_2d_array_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D_ARRAY, newctx->gl_tex_2d_array_state[i])) } - STATE_COMPARE(gl_tex_cube_state[i]) { + if STATE_COMPARE(gl_tex_cube_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_CUBE_MAP, newctx->gl_tex_cube_state[i])) } - STATE_COMPARE(gl_tex_external_oes_state[i]) { + if STATE_COMPARE(gl_tex_external_oes_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_EXTERNAL_OES, newctx->gl_tex_external_oes_state[i])) @@ -2132,7 +2204,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // Restore active texture CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(newctx->gl_active_texture[0])) - STATE_COMPARE(gl_generate_mipmap_hint[0]) { + if STATE_COMPARE(gl_generate_mipmap_hint[0]) { CHECK_GL_ERROR(_orig_fastpath_glHint(GL_GENERATE_MIPMAP_HINT, newctx->gl_generate_mipmap_hint[0])) } @@ -2141,17 +2213,22 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) flag = oldctx->_tex_flag2 | newctx->_tex_flag2; if (flag) { for (i = 0; i < oldctx->gl_tex_units_num[0]; i++) { - STATE_COMPARE(gl_tex_buffer_ext_state[i]) { + if STATE_COMPARE(gl_tex_buffer_ext_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_BUFFER_EXT, newctx->gl_tex_buffer_ext_state[i])) } - STATE_COMPARE(gl_tex_2d_multisample_state[i]) { + if STATE_COMPARE(gl_tex_2d_multisample_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, newctx->gl_tex_2d_multisample_state[i])) } - STATE_COMPARE(gl_tex_2d_multisample_array_oes_state[i]) { + if STATE_COMPARE(gl_tex_cube_map_array_ext_state[i]) { + CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) + CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY_EXT, + newctx->gl_tex_cube_map_array_ext_state[i])) + } + if STATE_COMPARE(gl_tex_2d_multisample_array_oes_state[i]) { CHECK_GL_ERROR(_orig_fastpath_glActiveTexture(GL_TEXTURE0 + i)) CHECK_GL_ERROR(_orig_fastpath_glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, newctx->gl_tex_2d_multisample_array_oes_state[i])) @@ -2172,7 +2249,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) flag = oldctx->_blend_flag | newctx->_blend_flag; if (flag) { - STATES_COMPARE(gl_blend_color, 4 * sizeof(GLclampf)) { + if STATES_COMPARE(gl_blend_color, 4 * sizeof(GLclampf)) { CHECK_GL_ERROR(_orig_fastpath_glBlendColor(newctx->gl_blend_color[0], newctx->gl_blend_color[1], newctx->gl_blend_color[2], @@ -2218,7 +2295,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) newctx->gl_stencil_pass_depth_pass[0])) } - STATE_COMPARE(gl_stencil_writemask[0]) { + if STATE_COMPARE(gl_stencil_writemask[0]) { CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_FRONT, newctx->gl_stencil_writemask[0])) } @@ -2248,11 +2325,11 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) newctx->gl_stencil_back_pass_depth_pass[0])) } - STATE_COMPARE(gl_stencil_back_writemask[0]) { + if STATE_COMPARE(gl_stencil_back_writemask[0]) { CHECK_GL_ERROR(_orig_fastpath_glStencilMaskSeparate(GL_BACK, newctx->gl_stencil_back_writemask[0])) } - STATE_COMPARE(gl_stencil_clear_value[0]) { + if STATE_COMPARE(gl_stencil_clear_value[0]) { CHECK_GL_ERROR(_orig_fastpath_glClearStencil(newctx->gl_stencil_clear_value[0])) } } @@ -2261,19 +2338,19 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _pixel_flag1 flag = oldctx->_pixel_flag1 | newctx->_pixel_flag1; if (flag) { - STATE_COMPARE(gl_pack_row_length[0]) { + if STATE_COMPARE(gl_pack_row_length[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ROW_LENGTH, newctx->gl_pack_row_length[0])) } - STATE_COMPARE(gl_pack_skip_rows[0]) { + if STATE_COMPARE(gl_pack_skip_rows[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_ROWS, newctx->gl_pack_skip_rows[0])) } - STATE_COMPARE(gl_pack_skip_pixels[0]) { + if STATE_COMPARE(gl_pack_skip_pixels[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_SKIP_PIXELS, newctx->gl_pack_skip_pixels[0])) } - STATE_COMPARE(gl_pack_alignment[0]) { + if STATE_COMPARE(gl_pack_alignment[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_PACK_ALIGNMENT, newctx->gl_pack_alignment[0])) } @@ -2282,27 +2359,27 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _pixel_flag2 flag = oldctx->_pixel_flag2 | newctx->_pixel_flag2; if (flag) { - STATE_COMPARE(gl_unpack_row_length[0]) { + if STATE_COMPARE(gl_unpack_row_length[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ROW_LENGTH, newctx->gl_unpack_row_length[0])) } - STATE_COMPARE(gl_unpack_skip_rows[0]) { + if STATE_COMPARE(gl_unpack_skip_rows[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_ROWS, newctx->gl_unpack_skip_rows[0])) } - STATE_COMPARE(gl_unpack_skip_pixels[0]) { + if STATE_COMPARE(gl_unpack_skip_pixels[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_PIXELS, newctx->gl_unpack_skip_pixels[0])) } - STATE_COMPARE(gl_unpack_alignment[0]) { + if STATE_COMPARE(gl_unpack_alignment[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ALIGNMENT, newctx->gl_unpack_alignment[0])) } - STATE_COMPARE(gl_unpack_image_height[0]) { + if STATE_COMPARE(gl_unpack_image_height[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, newctx->gl_unpack_image_height[0])) } - STATE_COMPARE(gl_unpack_skip_images[0]) { + if STATE_COMPARE(gl_unpack_skip_images[0]) { CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_SKIP_IMAGES, newctx->gl_unpack_skip_images[0])) } @@ -2312,10 +2389,10 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _misc_flag1 flag = oldctx->_misc_flag1 | newctx->_misc_flag1; if (flag) { - STATE_COMPARE(gl_front_face[0]) { + if STATE_COMPARE(gl_front_face[0]) { CHECK_GL_ERROR(_orig_fastpath_glFrontFace(newctx->gl_front_face[0])) } - STATE_COMPARE(gl_line_width[0]) { + if STATE_COMPARE(gl_line_width[0]) { CHECK_GL_ERROR(_orig_fastpath_glLineWidth(newctx->gl_line_width[0])) } if ((oldctx->gl_polygon_offset_factor[0] != newctx->gl_polygon_offset_factor[0]) @@ -2333,7 +2410,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) newctx->gl_sample_coverage_value[0], newctx->gl_sample_coverage_invert[0])) } - STATE_COMPARE(gl_fragment_shader_derivative_hint[0]) { + if STATE_COMPARE(gl_fragment_shader_derivative_hint[0]) { CHECK_GL_ERROR(_orig_fastpath_glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES, newctx->gl_fragment_shader_derivative_hint[0])) } @@ -2342,7 +2419,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _misc_flag2 flag = oldctx->_misc_flag2 | newctx->_misc_flag2; if (flag) { - STATES_COMPARE(gl_scissor_box, 4 * sizeof(GLint)) { + if STATES_COMPARE(gl_scissor_box, 4 * sizeof(GLint)) { CHECK_GL_ERROR(_orig_fastpath_glScissor(newctx->gl_scissor_box[0], newctx->gl_scissor_box[1], newctx->gl_scissor_box[2], @@ -2353,10 +2430,10 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // _misc_flag3 flag = oldctx->_misc_flag3 | newctx->_misc_flag3; if (flag) { - STATE_COMPARE(gl_read_buffer[0]) { + if STATE_COMPARE(gl_read_buffer[0]) { CHECK_GL_ERROR(_orig_fastpath_glReadBuffer(newctx->gl_read_buffer[0])) } - STATES_COMPARE(gl_draw_buffers, 16 * sizeof(GLenum)) { + if STATES_COMPARE(gl_draw_buffers, 16 * sizeof(GLenum)) { int drawBuffSize = 16; /* If the context has only default framebuffer, then size of glDrawBuffers can only be 1 */ if (fastpath_ostate_has_object_type(&newctx->ostate, @@ -2372,7 +2449,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) oldctx->gl_transform_feedback_paused[0] == GL_FALSE) { CHECK_GL_ERROR(_orig_fastpath_glPauseTransformFeedback()) } - STATE_COMPARE(gl_transform_feedback_binding[0]) { + if STATE_COMPARE(gl_transform_feedback_binding[0]) { CHECK_GL_ERROR(_orig_fastpath_glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, newctx->gl_transform_feedback_binding[0])) } diff --git a/src/modules/fastpath/coregl_fastpath.h b/src/modules/fastpath/coregl_fastpath.h index 9f9a4a5..bb7a837 100644 --- a/src/modules/fastpath/coregl_fastpath.h +++ b/src/modules/fastpath/coregl_fastpath.h @@ -238,6 +238,12 @@ typedef struct _GLGlueContext { #define _BIND_FLAG3_BIT_gl_dispatch_indirect_buffer_binding FLAG_BIT_3 #define _BIND_FLAG3_BIT_gl_texture_buffer_binding FLAG_BIT_4 + unsigned char _bind_flag4; +#define _BIND_FLAG4_BIT_gl_transform_feedback_buffer_range_binding FLAG_BIT_0 +#define _BIND_FLAG4_BIT_gl_uniform_buffer_range_binding FLAG_BIT_1 +#define _BIND_FLAG4_BIT_gl_shader_storage_buffer_range_binding FLAG_BIT_2 +#define _BIND_FLAG4_BIT_gl_atomic_counter_buffer_range_binding FLAG_BIT_3 + unsigned char _enable_flag1; #define _ENABLE_FLAG1_BIT_gl_blend FLAG_BIT_0 #define _ENABLE_FLAG1_BIT_gl_cull_face FLAG_BIT_1 @@ -285,6 +291,7 @@ typedef struct _GLGlueContext { #define _TEX_FLAG2_BIT_gl_tex_buffer_ext_state FLAG_BIT_0 #define _TEX_FLAG2_BIT_gl_tex_2d_multisample_state FLAG_BIT_1 #define _TEX_FLAG2_BIT_gl_tex_2d_multisample_array_oes_state FLAG_BIT_2 +#define _TEX_FLAG2_BIT_gl_tex_cube_map_array_ext_state FLAG_BIT_3 unsigned char _blend_flag; #define _BLEND_FLAG_BIT_gl_blend_color FLAG_BIT_0 diff --git a/src/modules/fastpath/coregl_fastpath_state.h b/src/modules/fastpath/coregl_fastpath_state.h index a06007c..58a207b 100644 --- a/src/modules/fastpath/coregl_fastpath_state.h +++ b/src/modules/fastpath/coregl_fastpath_state.h @@ -154,6 +154,81 @@ GLUE_STATE(GLsizeiptr, gl_atomic_counter_buffer_binding_array_size, INITIAL_CTX->gl_atomic_counter_buffer_binding_num[0], MAX_ATOMIC_COUNTER_BUFFER_BINDING, _state_get_atomic_counter_buffer_bindings_size(value); /* DEFAULT NOT EFFECT */, _state_get_atomic_counter_buffer_bindings_size(value);) + +GLUE_STATE(GLuint, gl_uniform_buffer_range_binding_array, + INITIAL_CTX->gl_uniform_buffer_binding_num[0], MAX_UNIFORM_BUFFER_BINDINGS, + _state_get_uniform_buffer_bindings(value); /* DEFAULT NOT EFFECT */, + _state_get_uniform_buffer_bindings(value);) + +GLUE_STATE(GLintptr, gl_uniform_buffer_range_binding_array_offset, + INITIAL_CTX->gl_uniform_buffer_binding_num[0], MAX_UNIFORM_BUFFER_BINDINGS, + _state_get_uniform_buffer_bindings_offset(value); /* DEFAULT NOT EFFECT */, + _state_get_uniform_buffer_bindings_offset(value);) + +GLUE_STATE(GLsizeiptr, gl_uniform_buffer_range_binding_array_size, + INITIAL_CTX->gl_uniform_buffer_binding_num[0], MAX_UNIFORM_BUFFER_BINDINGS, + _state_get_uniform_buffer_bindings_size(value); /* DEFAULT NOT EFFECT */, + _state_get_uniform_buffer_bindings_size(value);) + +GLUE_STATE(GLuint, gl_transform_feedback_buffer_range_binding_array, + INITIAL_CTX->gl_transform_feedback_buffer_binding_num[0], + MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, + _state_get_transform_feedback_buffer_bindings(value); /* DEFAULT NOT EFFECT */, + _state_get_transform_feedback_buffer_bindings(value);) + +GLUE_STATE(GLintptr, gl_transform_feedback_buffer_range_binding_array_offset, + INITIAL_CTX->gl_transform_feedback_buffer_binding_num[0], + MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, + _state_get_transform_feedback_buffer_bindings_offset( + value); /* DEFAULT NOT EFFECT */, + _state_get_transform_feedback_buffer_bindings_offset(value);) + +GLUE_STATE(GLsizeiptr, gl_transform_feedback_buffer_range_binding_array_size, + INITIAL_CTX->gl_transform_feedback_buffer_binding_num[0], + MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, + _state_get_transform_feedback_buffer_bindings_size( + value); /* DEFAULT NOT EFFECT */, + _state_get_transform_feedback_buffer_bindings_size(value);) + +GLUE_STATE(GLuint, gl_shader_storage_buffer_range_binding_array, + INITIAL_CTX->gl_shader_storage_buffer_binding_num[0], + MAX_SHADER_STORAGE_BUFFER_BINDINGS, + _state_get_shader_storage_buffer_bindings(value); /* DEFAULT NOT EFFECT */, + _state_get_shader_storage_buffer_bindings(value);) + +GLUE_STATE(GLintptr, gl_shader_storage_buffer_range_binding_array_offset, + INITIAL_CTX->gl_shader_storage_buffer_binding_num[0], + MAX_SHADER_STORAGE_BUFFER_BINDINGS, + _state_get_shader_storage_buffer_bindings_offset( + value); /* DEFAULT NOT EFFECT */, + _state_get_shader_storage_buffer_bindings_offset(value);) + +GLUE_STATE(GLsizeiptr, gl_shader_storage_buffer_range_binding_array_size, + INITIAL_CTX->gl_shader_storage_buffer_binding_num[0], + MAX_SHADER_STORAGE_BUFFER_BINDINGS, + _state_get_shader_storage_buffer_bindings_size( + value); /* DEFAULT NOT EFFECT */, + _state_get_shader_storage_buffer_bindings_size(value);) + +GLUE_STATE(GLuint, gl_atomic_counter_buffer_range_binding_array, + INITIAL_CTX->gl_atomic_counter_buffer_binding_num[0], + MAX_ATOMIC_COUNTER_BUFFER_BINDING, + _state_get_atomic_counter_buffer_bindings(value); /* DEFAULT NOT EFFECT */, + _state_get_atomic_counter_buffer_bindings(value);) + +GLUE_STATE(GLintptr, gl_atomic_counter_buffer_range_binding_array_offset, + INITIAL_CTX->gl_atomic_counter_buffer_binding_num[0], + MAX_ATOMIC_COUNTER_BUFFER_BINDING, + _state_get_atomic_counter_buffer_bindings_offset( + value); /* DEFAULT NOT EFFECT */, + _state_get_atomic_counter_buffer_bindings_offset(value);) + +GLUE_STATE(GLsizeiptr, gl_atomic_counter_buffer_range_binding_array_size, + INITIAL_CTX->gl_atomic_counter_buffer_binding_num[0], + MAX_ATOMIC_COUNTER_BUFFER_BINDING, + _state_get_atomic_counter_buffer_bindings_size( + value); /* DEFAULT NOT EFFECT */, + _state_get_atomic_counter_buffer_bindings_size(value);) _COREGL_END_API(COREGL_GLAPI_3) GLUE_STATE(GLuint, gl_framebuffer_binding, 1, 1, SET_1(0), @@ -246,6 +321,10 @@ GLUE_STATE(GLuint, gl_tex_2d_multisample_state, INITIAL_CTX->gl_tex_units_num[0] MAX_TEXTURE_UNITS, SET_N(INITIAL_CTX->gl_tex_units_num[0], 1, SET_1(0)), _state_get_texture_states(GL_TEXTURE_2D_MULTISAMPLE, (GLint *)value);) +GLUE_STATE(GLuint, gl_tex_cube_map_array_ext_state, INITIAL_CTX->gl_tex_units_num[0], + MAX_TEXTURE_UNITS, + SET_N(INITIAL_CTX->gl_tex_units_num[0], 1, SET_1(0)), + _state_get_texture_states(GL_TEXTURE_CUBE_MAP_ARRAY_EXT, (GLint *)value);) GLUE_STATE(GLuint, gl_tex_2d_multisample_array_oes_state, INITIAL_CTX->gl_tex_units_num[0], MAX_TEXTURE_UNITS, SET_N(INITIAL_CTX->gl_tex_units_num[0], 1, SET_1(0)), -- 2.7.4 From d6eef6416f460a88b0491b9af4531c7ba2c786f3 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Tue, 9 Aug 2016 03:09:02 +0800 Subject: [PATCH 03/16] coregl_fastpath: Remove support for unnecessary interface This patch removes some interfaces which are not supposed to go through fast path Signed-off-by: Zhaowei Yuan Change-Id: If7865ad9aee404ebaaaf7dc04e92d3f7123cf017 --- src/modules/fastpath/coregl_fastpath.c | 20 +- src/modules/fastpath/coregl_fastpath_gl.c | 326 ------------------------------ 2 files changed, 2 insertions(+), 344 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath.c b/src/modules/fastpath/coregl_fastpath.c index d7283a0..8294945 100644 --- a/src/modules/fastpath/coregl_fastpath.c +++ b/src/modules/fastpath/coregl_fastpath.c @@ -361,7 +361,6 @@ fastpath_apply_overrides_gl(int enable) if (driver_gl_version >= COREGL_GLAPI_1) { COREGL_OVERRIDE(fastpath_, glClientActiveTexture); COREGL_OVERRIDE(fastpath_, glSampleCoveragex); - COREGL_OVERRIDE(fastpath_, glVertexPointer); } COREGL_OVERRIDE(fastpath_, glGetError); @@ -369,7 +368,6 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glGetIntegerv); COREGL_OVERRIDE(fastpath_, glGetFloatv); - COREGL_OVERRIDE(fastpath_, glGetBooleanv); COREGL_OVERRIDE(fastpath_, glActiveTexture); COREGL_OVERRIDE(fastpath_, glGenTextures); @@ -495,16 +493,10 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glBindFramebufferOES); COREGL_OVERRIDE(fastpath_, glBindRenderbufferOES); - COREGL_OVERRIDE(fastpath_, glClearBufferfi); - COREGL_OVERRIDE(fastpath_, glClearBufferfv); - COREGL_OVERRIDE(fastpath_, glClearBufferiv); - COREGL_OVERRIDE(fastpath_, glClearBufferuiv); COREGL_OVERRIDE(fastpath_, glDeleteFramebuffersOES); COREGL_OVERRIDE(fastpath_, glDeleteRenderbuffersOES); COREGL_OVERRIDE(fastpath_, glDepthRangefOES); COREGL_OVERRIDE(fastpath_, glDepthRangexOES); - COREGL_OVERRIDE(fastpath_, glFramebufferParameteri); - COREGL_OVERRIDE(fastpath_, glGetFramebufferParameteriv); COREGL_OVERRIDE(fastpath_, glFramebufferRenderbufferOES); COREGL_OVERRIDE(fastpath_, glFramebufferTexture2DOES); COREGL_OVERRIDE(fastpath_, glGenFramebuffersOES); @@ -532,8 +524,8 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glDeleteVertexArraysOES); COREGL_OVERRIDE(fastpath_, glGenVertexArraysOES); COREGL_OVERRIDE(fastpath_, glIsVertexArrayOES); - COREGL_OVERRIDE(fastpath_, glClearDepthfOES ); - COREGL_OVERRIDE(fastpath_, glClearDepthxOES ); + COREGL_OVERRIDE(fastpath_, glClearDepthfOES); + COREGL_OVERRIDE(fastpath_, glClearDepthxOES); /* Start overriding GLES 3.0 */ if (driver_gl_version >= COREGL_GLAPI_3) { COREGL_OVERRIDE(fastpath_, glReadBuffer); @@ -648,18 +640,10 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glProgramUniformMatrix4x3fv); COREGL_OVERRIDE(fastpath_, glBindImageTexture); COREGL_OVERRIDE(fastpath_, glGetBooleani_v); - COREGL_OVERRIDE(fastpath_, glMemoryBarrier); - COREGL_OVERRIDE(fastpath_, glMemoryBarrierByRegion); - COREGL_OVERRIDE(fastpath_, glTexStorage2DMultisample); COREGL_OVERRIDE(fastpath_, glGetMultisamplefv); - COREGL_OVERRIDE(fastpath_, glSampleMaski); COREGL_OVERRIDE(fastpath_, glGetTexLevelParameteriv); COREGL_OVERRIDE(fastpath_, glGetTexLevelParameterfv); COREGL_OVERRIDE(fastpath_, glBindVertexBuffer); - COREGL_OVERRIDE(fastpath_, glVertexAttribFormat); - COREGL_OVERRIDE(fastpath_, glVertexAttribIFormat); - COREGL_OVERRIDE(fastpath_, glVertexAttribBinding); - COREGL_OVERRIDE(fastpath_, glVertexBindingDivisor); } if(driver_gl_version >= COREGL_GLAPI_32) { diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index 313bfea..9b85cda 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -394,21 +394,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -void -fastpath_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glVertexPointer(size, type, stride, pointer); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - GLenum fastpath_glGetError(void) { @@ -4068,22 +4053,6 @@ finish: } void -fastpath_glGetBooleanv(GLenum pname, GLboolean *params) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - IF_GL_SUCCESS(_orig_fastpath_glGetBooleanv(pname, params)) { - _modify_get_value(pname, params, GL_BOOL, GL_FALSE); - } - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void fastpath_glGetFloatv(GLenum pname, GLfloat *params) { DEFINE_FASTPAH_GL_FUNC(); @@ -7072,54 +7041,6 @@ finish: } void -fastpath_glMemoryBarrier (GLbitfield barriers) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glMemoryBarrier(barriers); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glMemoryBarrierByRegion (GLbitfield barriers) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glMemoryBarrierByRegion(barriers); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glTexStorage2DMultisample (GLenum target, GLsizei samples, - GLenum internalformat, GLsizei width, GLsizei height, - GLboolean fixedsamplelocations) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glTexStorage2DMultisample (target, samples, internalformat, - width, height, fixedsamplelocations); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void fastpath_glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val) { DEFINE_FASTPAH_GL_FUNC(); @@ -7135,21 +7056,6 @@ finish: } void -fastpath_glSampleMaski (GLuint maskNumber, GLbitfield mask) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glSampleMaski(maskNumber, mask); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void fastpath_glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params) { @@ -7198,68 +7104,6 @@ finish: } void -fastpath_glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, - GLboolean normalized, GLuint relativeoffset) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glVertexAttribFormat (attribindex, size, type, normalized, - relativeoffset); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, - GLuint relativeoffset) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glVertexAttribIFormat (attribindex, size, type, relativeoffset); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glVertexAttribBinding (GLuint attribindex, GLuint bindingindex) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glVertexAttribBinding (attribindex, bindingindex); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glVertexBindingDivisor(GLuint bindingindex, GLuint divisor) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glVertexBindingDivisor (bindingindex, divisor); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} -void fastpath_glBindFramebufferOES(GLenum target, GLuint framebuffer) { GLuint real_obj; @@ -7372,92 +7216,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - -void -fastpath_glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, - GLint stencil) -{ - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - goto finish; - } - - _orig_fastpath_glClearBufferfi(real_obj, drawbuffer, depth, stencil); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glClearBufferfv(GLenum buffer, GLint drawbuffer, GLfloat const *value) -{ - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - goto finish; - } - - _orig_fastpath_glClearBufferfv(buffer, drawbuffer, value); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glClearBufferiv(GLenum buffer, GLint drawbuffer, GLint const *value) -{ - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - goto finish; - } - - _orig_fastpath_glClearBufferiv(buffer, drawbuffer, value); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glClearBufferuiv(GLenum buffer, GLint drawbuffer, GLuint const *value) -{ - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - goto finish; - } - - _orig_fastpath_glClearBufferuiv(buffer, drawbuffer, value); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - void fastpath_glDeleteFramebuffersOES(GLsizei n, const GLuint *framebuffers) { @@ -7641,90 +7399,6 @@ finish: } void -fastpath_glFramebufferParameteri(GLenum target, GLenum pname, GLint param) -{ - GLint real_obj = 0, fa_type = 0; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - switch (pname) { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - param = 0; - _orig_fastpath_glFramebufferParameteri(target, pname, real_obj); - _orig_fastpath_glFramebufferParameteri(target, - GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, fa_type); - switch (fa_type) { - case GL_TEXTURE: - if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)¶m) != 1) { - param = 0; - goto finish; - } - break; - case GL_RENDERBUFFER: - if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj, - (GLuint *)¶m) != 1) { - param = 0; - goto finish; - } - break; - } - break; - default: - _orig_fastpath_glFramebufferParameteri(target, pname, param); - break; - } - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void -fastpath_glGetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GLint real_obj = 0, fa_type = 0;; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - switch (pname) { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - params[0] = 0; - _orig_fastpath_glGetFramebufferParameteriv(target, pname, &real_obj); - _orig_fastpath_glGetFramebufferParameteriv(target, - GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &fa_type); - switch (fa_type) { - case GL_TEXTURE: - if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)params) != 1) { - params[0] = 0; - goto finish; - } - break; - case GL_RENDERBUFFER: - if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj, - (GLuint *)params) != 1) { - params[0] = 0; - goto finish; - } - break; - } - break; - default: - _orig_fastpath_glGetFramebufferParameteriv(target, pname, params); - break; - } - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - -void fastpath_glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { -- 2.7.4 From c72fb5fcda839c983ab14f1ec2c4ac54b9da1994 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Tue, 9 Aug 2016 03:21:09 +0800 Subject: [PATCH 04/16] coregl_fastpath: Add support for some extensions This patch adds fast path support for extensions and add missed override process of some interfaces Signed-off-by: Zhaowei Yuan Change-Id: Ie6a700c80048ea37310c2214063f71f6370ab85a --- src/headers/sym_gl2.h | 28 ++- src/headers/sym_gl_common.h | 17 +- src/modules/fastpath/coregl_fastpath.c | 20 ++ src/modules/fastpath/coregl_fastpath_gl.c | 307 ++++++++++++++++++++++++++++ src/modules/tracepath/coregl_tracepath_gl.c | 285 ++++++++++++++++++++++++++ 5 files changed, 653 insertions(+), 4 deletions(-) diff --git a/src/headers/sym_gl2.h b/src/headers/sym_gl2.h index 669f6b7..d4d1621 100644 --- a/src/headers/sym_gl2.h +++ b/src/headers/sym_gl2.h @@ -181,6 +181,30 @@ _COREGL_EXT_SYMBOL(void, glFramebufferRenderbufferOES, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)) _COREGL_EXT_SYMBOL(void, glFramebufferTexture2DOES, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)) +_COREGL_EXT_SYMBOL(void, glFramebufferTextureOES, (GLenum target, GLenum attachment, GLuint texture, GLint level)) +_COREGL_EXT_SYMBOL(void, glTexBufferRangeOES, (GLenum target, GLenum internalformat, GLuint buffer,GLintptr offset, GLsizeiptr size)) +_COREGL_EXT_SYMBOL(void, glSamplerParameterIuivOES, (GLuint sampler, GLenum pname, GLuint const *params)) +_COREGL_EXT_SYMBOL(void, glSamplerParameterIivOES, (GLuint sampler, GLenum pname, GLint const *params)) +_COREGL_EXT_SYMBOL(void, glGetSamplerParameterIuivOES,(GLuint sampler, GLenum pname, GLuint *params)) +_COREGL_EXT_SYMBOL(void, glGetSamplerParameterIivOES,(GLuint sampler, GLenum pname, GLint *params)) +_COREGL_EXT_SYMBOL(void, glGetTexParameterIuivOES,(GLenum target, GLenum pname, GLuint *params)) +_COREGL_EXT_SYMBOL(void, glGetTexParameterIivOES,(GLenum target, GLenum pname, GLint *params)) +_COREGL_EXT_SYMBOL(void, glPatchParameteriOES,(GLenum pname, GLint value)) +_COREGL_EXT_SYMBOL(void, glTexParameterIivOES,(GLenum target, GLenum pname, GLint const *params)) +_COREGL_EXT_SYMBOL(void, glTexParameterIuivOES,(GLenum target, GLenum pname, GLuint const *params)) +_COREGL_EXT_SYMBOL(void, glGetSamplerParameterIivEXT,(GLuint sampler, GLenum pname, GLint *params)) +_COREGL_EXT_SYMBOL(void, glGetSamplerParameterIuivEXT,(GLuint sampler, GLenum pname, GLuint *params)) +_COREGL_EXT_SYMBOL(void, glSamplerParameterIivEXT, (GLuint sampler, GLenum pname, GLint const *params)) +_COREGL_EXT_SYMBOL(void, glFramebufferTextureEXT, (GLenum target, GLenum attachment, GLuint texture, GLint level)) +_COREGL_EXT_SYMBOL(void, glTexBufferRangeEXT, (GLenum target, GLenum internalformat, GLuint buffer,GLintptr offset, GLsizeiptr size)) +_COREGL_EXT_SYMBOL(void, glSamplerParameterIuivEXT, (GLuint sampler, GLenum pname, GLuint const *params)) +_COREGL_EXT_SYMBOL(void, glGetTexParameterIuivEXT,(GLenum target, GLenum pname, GLuint *params)) +_COREGL_EXT_SYMBOL(void, glGetTexParameterIivEXT,(GLenum target, GLenum pname, GLint *params)) +_COREGL_EXT_SYMBOL(void, glPatchParameteriEXT,(GLenum pname, GLint value)) +_COREGL_EXT_SYMBOL(void, glTexParameterIivEXT,(GLenum target, GLenum pname, GLint const *params)) +_COREGL_EXT_SYMBOL(void, glTexParameterIuivEXT,(GLenum target, GLenum pname, GLuint const *params)) + + _COREGL_EXT_SYMBOL(void, glGenFramebuffersOES, (GLsizei n, GLuint *framebuffers)) _COREGL_EXT_SYMBOL(void, glGenRenderbuffersOES, (GLsizei n, @@ -303,6 +327,8 @@ _COREGL_EXT_SYMBOL(void, glTexStorage3DMultisampleOES, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations)) _COREGL_EXT_SYMBOL(void, glTranslatexOES, (GLfixed x, GLfixed y, GLfixed z)) +_COREGL_EXT_SYMBOL(void, glTexBufferOES, (GLenum target, GLenum internalformat, GLuint buffer)) +_COREGL_EXT_SYMBOL(void, glTexBufferEXT, (GLenum target, GLenum internalformat, GLuint buffer)) _COREGL_END_API(COREGL_GLAPI_2) /* OpenGL ES 3.0 */ @@ -810,7 +836,6 @@ _COREGL_EXT_SYMBOL(void, glCompressedTexSubImage3DOES, (GLenum target, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data)) - /* _COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_ANGLE_framebuffer_blit", 1.1, -1) _COREGL_EXT_SYMBOL(void, glBlitFramebufferANGLE, (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)) @@ -937,7 +962,6 @@ _COREGL_EXT_SYMBOL_FASTPATH_PASS(glGetSamplerParameterIivOES) _COREGL_EXT_SYMBOL_FASTPATH_PASS(glGetSamplerParameterIuivOES) _COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_texture_buffer", 2.0, -1) -_COREGL_EXT_SYMBOL_FASTPATH_PASS(glTexBufferOES) _COREGL_EXT_SYMBOL_FASTPATH_PASS(glTexBufferRangeOES) _COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_NV_internalformat_sample_query", 2.0, -1) diff --git a/src/headers/sym_gl_common.h b/src/headers/sym_gl_common.h index 7d86d56..9a3ba29 100644 --- a/src/headers/sym_gl_common.h +++ b/src/headers/sym_gl_common.h @@ -137,8 +137,7 @@ _COREGL_EXT_SYMBOL(void, glMultiDrawArraysEXT, (GLenum mode, const GLint *first, _COREGL_EXT_SYMBOL(void, glMultiDrawElementsEXT, (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount)) -_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_EXT_multisampled_render_to_texture", - 2.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_EXT_multisampled_render_to_texture",2.0, -1) _COREGL_EXT_SYMBOL(void, glRenderbufferStorageMultisampleEXT, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)) _COREGL_EXT_SYMBOL(void, glFramebufferTexture2DMultisampleEXT, (GLenum target, @@ -185,6 +184,20 @@ _COREGL_EXT_SYMBOL_FASTPATH_BLOCK(glExtIsProgramBinaryQCOM) _COREGL_EXT_SYMBOL_FASTPATH_BLOCK(glExtGetProgramBinarySourceQCOM) _COREGL_END_API(COREGL_GLAPI_1_2_COMMON) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_texture_storage_multisample_2d_array", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_sample_variables", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_shader_multisample_interpolation", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_KHR_blend_equation_advanced", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_KHR_blend_equation_advanced_coherent", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_shader_image_atomic", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_gpu_shader5", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_EXT_gpu_shader5", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_OES_texture_cube_map_array", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_EXT_texture_cube_map_array", 1.0, -1) +_COREGL_FASTPATH_SUPPORTED_EXTENSION("GL_EXT_draw_elements_base_vertex", 1.0, -1) +_COREGL_EXT_SYMBOL_FASTPATH_PASS(glDrawElementsBaseVertexEXT) +_COREGL_EXT_SYMBOL_FASTPATH_PASS(glDrawElementsInstancedBaseVertexEXT) +_COREGL_EXT_SYMBOL_FASTPATH_PASS(glDrawRangeElementsBaseVertexEXT) #ifdef _COREGL_EXT_SYMBOL_NOT_DEFINED #undef _COREGL_EXT_SYMBOL_NOT_DEFINED diff --git a/src/modules/fastpath/coregl_fastpath.c b/src/modules/fastpath/coregl_fastpath.c index 8294945..5206bf4 100644 --- a/src/modules/fastpath/coregl_fastpath.c +++ b/src/modules/fastpath/coregl_fastpath.c @@ -526,6 +526,21 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glIsVertexArrayOES); COREGL_OVERRIDE(fastpath_, glClearDepthfOES); COREGL_OVERRIDE(fastpath_, glClearDepthxOES); + COREGL_OVERRIDE(fastpath_, glGetVertexAttribiv); + COREGL_OVERRIDE(fastpath_, glTexBufferOES); + COREGL_OVERRIDE(fastpath_, glFramebufferTextureEXT); + COREGL_OVERRIDE(fastpath_, glFramebufferTextureOES); + COREGL_OVERRIDE(fastpath_, glTexBufferRangeOES); + COREGL_OVERRIDE(fastpath_, glSamplerParameterIuivOES); + COREGL_OVERRIDE(fastpath_, glSamplerParameterIivOES); + COREGL_OVERRIDE(fastpath_, glGetSamplerParameterIuivOES); + COREGL_OVERRIDE(fastpath_, glGetSamplerParameterIivOES); + COREGL_OVERRIDE(fastpath_, glGetSamplerParameterIivEXT); + COREGL_OVERRIDE(fastpath_, glGetSamplerParameterIuivEXT); + COREGL_OVERRIDE(fastpath_, glSamplerParameterIivEXT); + COREGL_OVERRIDE(fastpath_, glSamplerParameterIuivEXT); + COREGL_OVERRIDE(fastpath_, glTexBufferRangeEXT); + COREGL_OVERRIDE(fastpath_, glTexBufferEXT); /* Start overriding GLES 3.0 */ if (driver_gl_version >= COREGL_GLAPI_3) { COREGL_OVERRIDE(fastpath_, glReadBuffer); @@ -547,6 +562,11 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glGetIntegeri_v); COREGL_OVERRIDE(fastpath_, glBindTransformFeedback); + COREGL_OVERRIDE(fastpath_, glBeginTransformFeedback); + COREGL_OVERRIDE(fastpath_, glEndTransformFeedback); + COREGL_OVERRIDE(fastpath_, glPauseTransformFeedback); + COREGL_OVERRIDE(fastpath_, glResumeTransformFeedback); + COREGL_OVERRIDE(fastpath_, glIsTransformFeedback); COREGL_OVERRIDE(fastpath_, glDeleteTransformFeedbacks); COREGL_OVERRIDE(fastpath_, glGenTransformFeedbacks); COREGL_OVERRIDE(fastpath_, glIsTransformFeedback); diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index 9b85cda..b5a2aed 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -5145,6 +5145,20 @@ finish: _COREGL_FASTPATH_FUNC_END(); } +void +fastpath_glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) +{ + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + IF_GL_SUCCESS(_orig_fastpath_glGetVertexAttribiv(index, pname, params)) { + _modify_get_value(pname, params, GL_INT, GL_FALSE); + } + +finish: + _COREGL_FASTPATH_FUNC_END(); +} void fastpath_glGetUniformuiv(GLuint program, GLint location, GLuint *params) @@ -8287,6 +8301,26 @@ finish: } void +fastpath_glTexBufferOES(GLenum target, GLenum internalformat, GLuint buffer) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glTexBufferOES(target, internalformat, real_obj); + +finish: + _COREGL_FASTPATH_FUNC_END(); +} + +void fastpath_glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) { GLuint real_obj; @@ -8468,3 +8502,276 @@ fastpath_glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, finish: _COREGL_FASTPATH_FUNC_END(); } + +void +fastpath_glFramebufferTextureOES(GLenum target, GLenum attachment, GLuint texture, GLint level) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + + _orig_fastpath_glFramebufferTextureOES(target, attachment, real_obj, level); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glTexBufferRangeOES(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glTexBufferRangeOES(target, internalformat, real_obj, offset, size); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glGetSamplerParameterIivOES(GLuint sampler, GLenum pname, GLint *params) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glGetSamplerParameterIivOES(real_obj, pname, params); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glSamplerParameterIivOES(GLuint sampler, GLenum pname, const GLint *param) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glSamplerParameterIivOES(real_obj, pname, param); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} + +void +fastpath_glGetSamplerParameterIuivOES(GLuint sampler, GLenum pname, GLuint *params) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glGetSamplerParameterIuivOES(real_obj, pname, params); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glSamplerParameterIuivOES(GLuint sampler, GLenum pname, const GLuint *param) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glSamplerParameterIuivOES(real_obj, pname, param); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glGetSamplerParameterIivEXT(GLuint sampler, GLenum pname, GLint *params) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_ENUM); + goto finish; + } + + _orig_fastpath_glGetSamplerParameterIivEXT(real_obj, pname, params); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glGetSamplerParameterIuivEXT(GLuint sampler, GLenum pname, GLuint *params) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_ENUM); + goto finish; + } + + _orig_fastpath_glGetSamplerParameterIuivEXT(real_obj, pname, params); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glSamplerParameterIivEXT(GLuint sampler, GLenum pname, const GLint *param) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_ENUM); + goto finish; + } + + _orig_fastpath_glSamplerParameterIivEXT(real_obj, pname, param); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glFramebufferTextureEXT(GLenum target, GLenum attachment, GLuint texture, GLint level) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + + _orig_fastpath_glFramebufferTextureEXT(target, attachment, real_obj, level); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glTexBufferRangeEXT(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_ENUM); + goto finish; + } + + _orig_fastpath_glTexBufferRangeEXT(target, internalformat, real_obj, offset, size); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glSamplerParameterIuivEXT(GLuint sampler, GLenum pname, const GLuint *param) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_ENUM); + goto finish; + } + + _orig_fastpath_glSamplerParameterIuivEXT(real_obj, pname, param); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} +void +fastpath_glTexBufferEXT(GLenum target, GLenum internalformat, GLuint buffer) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_ENUM); + goto finish; + } + + _orig_fastpath_glTexBufferEXT(target, internalformat, real_obj); + +finish: + _COREGL_FASTPATH_FUNC_END(); +} diff --git a/src/modules/tracepath/coregl_tracepath_gl.c b/src/modules/tracepath/coregl_tracepath_gl.c index ca32ad8..639f24b 100644 --- a/src/modules/tracepath/coregl_tracepath_gl.c +++ b/src/modules/tracepath/coregl_tracepath_gl.c @@ -2340,6 +2340,18 @@ finish: } void +tracepath_glTexBufferOES(GLenum target, GLenum internalformat, GLuint buffer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexBufferOES(target, internalformat, buffer); + + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void tracepath_glGetVertexAttribPointerv(GLuint index, GLenum pname, void **pointer) { _COREGL_TRACEPATH_FUNC_BEGIN(); @@ -8784,3 +8796,276 @@ tracepath_glTexStorage3DMultisample(GLenum target, GLsizei samples, GLenum inter finish: _COREGL_TRACEPATH_FUNC_END(); } + +void +tracepath_glFramebufferTextureOES(GLenum target, GLenum attachment, GLuint texture, GLint level) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + +#ifdef COREGL_TRACEPATH_TRACE_SURFACE_INFO + tracepath_fbdump_update(0); +#endif + + _orig_tracepath_glFramebufferTextureOES(target, attachment,texture, level); + +#ifdef COREGL_TRACEPATH_TRACE_SURFACE_INFO + tracepath_fbdump_update(1); +#endif + + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexBufferRangeOES(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexBufferRangeOES(target, internalformat, buffer, offset, size); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glSamplerParameterIuivOES(GLuint sampler, GLenum pname, const GLuint *param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glSamplerParameterIuivOES(sampler, pname, param); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glSamplerParameterIivOES(GLuint sampler, GLenum pname, const GLint *param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glSamplerParameterIivOES(sampler, pname, param); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetSamplerParameterIuivOES(GLuint sampler, GLenum pname, GLuint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetSamplerParameterIuivOES(sampler, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetSamplerParameterIivOES(GLuint sampler, GLenum pname, GLint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetSamplerParameterIivOES(sampler, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetTexParameterIuivOES(GLenum target, GLenum pname, GLuint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetTexParameterIuivOES(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameterIivOES(GLenum target, GLenum pname, const GLint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameterIivOES(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glPatchParameteriOES(GLenum pname, GLint value) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glPatchParameteriOES(pname, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameterIuivOES(GLenum target, GLenum pname, const GLuint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameterIuivOES(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetTexParameterIivOES(GLenum target, GLenum pname, GLint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetTexParameterIivOES(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetSamplerParameterIivEXT(GLuint sampler, GLenum pname, GLint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetSamplerParameterIivEXT(sampler, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetSamplerParameterIuivEXT(GLuint sampler, GLenum pname, GLuint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetSamplerParameterIuivEXT(sampler, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glSamplerParameterIivEXT(GLuint sampler, GLenum pname, const GLint *param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glSamplerParameterIivEXT(sampler, pname, param); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glFramebufferTextureEXT(GLenum target, GLenum attachment, GLuint texture, GLint level) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + +#ifdef COREGL_TRACEPATH_TRACE_SURFACE_INFO + tracepath_fbdump_update(0); +#endif + + _orig_tracepath_glFramebufferTextureEXT(target, attachment,texture, level); + +#ifdef COREGL_TRACEPATH_TRACE_SURFACE_INFO + tracepath_fbdump_update(1); +#endif + + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexBufferRangeEXT(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexBufferRangeEXT(target, internalformat, buffer, offset, size); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glSamplerParameterIuivEXT(GLuint sampler, GLenum pname, const GLuint *param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glSamplerParameterIuivEXT(sampler, pname, param); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetTexParameterIuivEXT(GLenum target, GLenum pname, GLuint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetTexParameterIuivEXT(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetTexParameterIivEXT(GLenum target, GLenum pname, GLint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetTexParameterIivEXT(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glPatchParameteriEXT(GLenum pname, GLint value) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glPatchParameteriEXT(pname, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameterIivEXT(GLenum target, GLenum pname, const GLint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameterIivEXT(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameterIuivEXT(GLenum target, GLenum pname, const GLuint *params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameterIuivEXT(target, pname, params); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} +void +tracepath_glTexBufferEXT(GLenum target, GLenum internalformat, GLuint buffer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexBufferOES(target, internalformat, buffer); + + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} -- 2.7.4 From b794300e5551c15ab04db52a950ff10318b2f409 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Tue, 9 Aug 2016 03:40:09 +0800 Subject: [PATCH 05/16] coregl_fastpath: Convert for more parameter types Output paremeters which have types added by this patch should be converted by attaching object type Signed-off-by: Zhaowei Yuan Change-Id: Idd582f5810062b2423e8e81e621d3eecdb5735b6 --- src/modules/fastpath/coregl_fastpath_gl.c | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index b5a2aed..f3d5fee 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -3979,7 +3979,12 @@ _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64) break; case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_2D_MULTISAMPLE: + case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES: case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_IMAGE_BINDING_NAME: + case GL_TEXTURE_BINDING_BUFFER_EXT: + case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT: case GL_ARRAY_BUFFER_BINDING: case GL_ELEMENT_ARRAY_BUFFER_BINDING: case GL_COPY_READ_BUFFER_BINDING: @@ -3988,6 +3993,10 @@ _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64) case GL_PIXEL_UNPACK_BUFFER_BINDING: case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: case GL_UNIFORM_BUFFER_BINDING: + case GL_DRAW_INDIRECT_BUFFER_BINDING: + case GL_DISPATCH_INDIRECT_BUFFER_BINDING: + case GL_TEXTURE_BUFFER_BINDING: + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: case GL_DRAW_FRAMEBUFFER_BINDING: case GL_READ_FRAMEBUFFER_BINDING: case GL_RENDERBUFFER_BINDING: @@ -3995,7 +4004,20 @@ _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64) case GL_VERTEX_ARRAY_BINDING: case GL_SAMPLER_BINDING: case GL_TRANSFORM_FEEDBACK_BINDING: - case GL_PROGRAM_PIPELINE_BINDING: { + case GL_SHADER_STORAGE_BUFFER_BINDING: + case GL_ATOMIC_COUNTER_BUFFER_BINDING: + case GL_PROGRAM_PIPELINE_BINDING: + case GL_VERTEX_BINDING_BUFFER: + case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT: + case GL_ACTIVE_PROGRAM: + case GL_VERTEX_SHADER: + case GL_FRAGMENT_SHADER: + case GL_COMPUTE_SHADER: + case GL_INFO_LOG_LENGTH: + case GL_VALIDATE_STATUS: + case GL_TESS_CONTROL_SHADER_EXT: + case GL_TESS_EVALUATION_SHADER_EXT: + case GL_GEOMETRY_SHADER_EXT:{ GLint real_obj_id = _COREGL_INT_INIT_VALUE; GLuint glue_obj_id = _COREGL_INT_INIT_VALUE; GL_Object_Type obj_type = GL_OBJECT_TYPE_UNKNOWN; @@ -4003,7 +4025,12 @@ _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64) switch (pname) { case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_2D_MULTISAMPLE: + case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES: case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_IMAGE_BINDING_NAME: + case GL_TEXTURE_BINDING_BUFFER_EXT: + case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT: obj_type = GL_OBJECT_TYPE_TEXTURE; break; case GL_ARRAY_BUFFER_BINDING: @@ -4014,6 +4041,14 @@ _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64) case GL_PIXEL_UNPACK_BUFFER_BINDING: case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: case GL_UNIFORM_BUFFER_BINDING: + case GL_SHADER_STORAGE_BUFFER_BINDING: + case GL_ATOMIC_COUNTER_BUFFER_BINDING: + case GL_DRAW_INDIRECT_BUFFER_BINDING: + case GL_DISPATCH_INDIRECT_BUFFER_BINDING: + case GL_TEXTURE_BUFFER_BINDING: + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + case GL_VERTEX_BINDING_BUFFER: + case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT: obj_type = GL_OBJECT_TYPE_BUFFER; break; case GL_DRAW_FRAMEBUFFER_BINDING: @@ -4024,6 +4059,15 @@ _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64) obj_type = GL_OBJECT_TYPE_RENDERBUFFER; break; case GL_CURRENT_PROGRAM: + case GL_ACTIVE_PROGRAM: + case GL_VERTEX_SHADER: + case GL_FRAGMENT_SHADER: + case GL_COMPUTE_SHADER: + case GL_INFO_LOG_LENGTH: + case GL_VALIDATE_STATUS: + case GL_TESS_CONTROL_SHADER_EXT: + case GL_TESS_EVALUATION_SHADER_EXT: + case GL_GEOMETRY_SHADER_EXT: obj_type = GL_OBJECT_TYPE_PROGRAM; break; case GL_VERTEX_ARRAY_BINDING: -- 2.7.4 From 7471221050a8cc4ffe082c172bee1f03ce934fd9 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Tue, 9 Aug 2016 03:58:43 +0800 Subject: [PATCH 06/16] coregl_fastpath: Change GL error for failed real object getting If failed to get a real object, GL error should be set according to the same behavior of GL driver Signed-off-by: Zhaowei Yuan Change-Id: I2f3f3506aa459ad1a0409a58e0364cfae3e75837 --- src/modules/fastpath/coregl_fastpath_gl.c | 72 +++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index f3d5fee..c4a6840 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -603,7 +603,7 @@ fastpath_glFramebufferTexture2D(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -628,7 +628,7 @@ fastpath_glFramebufferTexture3DOES(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -653,7 +653,7 @@ fastpath_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -1135,7 +1135,7 @@ fastpath_glBindFramebuffer(GLenum target, GLuint framebuffer) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -1353,7 +1353,7 @@ fastpath_glBindRenderbuffer(GLenum target, GLuint renderbuffer) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -1390,7 +1390,7 @@ fastpath_glFramebufferRenderbuffer(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -1832,6 +1832,11 @@ fastpath_glUseProgram(GLuint program) CURR_STATE_UPDATE(gl_current_program, 0, real_obj) } } + else if(current_ctx->gl_transform_feedback_active[0] == GL_TRUE && + current_ctx->gl_transform_feedback_paused[0] == GL_FALSE) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } goto finish; @@ -4242,6 +4247,10 @@ fastpath_glReadBuffer(GLenum mode) CURR_STATE_UPDATE(gl_read_buffer, 0, mode) } } + else if (current_ctx->gl_framebuffer_binding_read[0] && mode == GL_BACK) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } goto finish; @@ -4468,7 +4477,7 @@ fastpath_glFramebufferTextureLayer(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_VALUE); goto finish; } @@ -4708,7 +4717,7 @@ fastpath_glBindTransformFeedback(GLenum target, GLuint id) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TRANSFORMFEEDBACK, id, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -4718,6 +4727,12 @@ fastpath_glBindTransformFeedback(GLenum target, GLuint id) CURR_STATE_UPDATE(gl_transform_feedback_binding, 0, real_obj) } } + else if(current_ctx->gl_transform_feedback_active[0] == GL_TRUE && + current_ctx->gl_transform_feedback_paused[0] == GL_FALSE) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + goto finish; finish: @@ -5523,7 +5538,7 @@ fastpath_glBindSampler(GLuint unit, GLuint sampler) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5622,6 +5637,7 @@ fastpath_glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5643,6 +5659,7 @@ fastpath_glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint *param) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5664,6 +5681,7 @@ fastpath_glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5686,6 +5704,7 @@ fastpath_glSamplerParameterfv(GLuint sampler, GLenum pname, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5707,6 +5726,7 @@ fastpath_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5728,6 +5748,7 @@ fastpath_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -5896,7 +5917,7 @@ fastpath_glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) if (params == NULL || GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) { - _set_gl_error(GL_INVALID_VALUE); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -6019,7 +6040,7 @@ fastpath_glValidateProgramPipeline(GLuint pipeline) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) { - _set_gl_error(GL_INVALID_VALUE); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -6232,18 +6253,23 @@ finish: void fastpath_glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) { - GLuint real_obj; + GLuint real_program_obj; + GLuint real_pipeline_obj; DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { - _set_gl_error(GL_INVALID_VALUE); + if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_program_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_pipeline_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } - _orig_fastpath_glUseProgramStages(pipeline, stages, real_obj); + _orig_fastpath_glUseProgramStages(real_pipeline_obj, stages, real_program_obj); goto finish; @@ -7171,7 +7197,7 @@ fastpath_glBindFramebufferOES(GLenum target, GLuint framebuffer) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_VALUE); goto finish; } @@ -7248,7 +7274,7 @@ fastpath_glBindRenderbufferOES(GLenum target, GLuint renderbuffer) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_VALUE); goto finish; } @@ -7467,7 +7493,7 @@ fastpath_glFramebufferRenderbufferOES(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_VALUE); goto finish; } @@ -7491,7 +7517,7 @@ fastpath_glFramebufferTexture2DOES(GLenum target, GLenum attachment, INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); + _set_gl_error(GL_INVALID_VALUE); goto finish; } @@ -8102,7 +8128,7 @@ fastpath_glGenVertexArraysOES(GLsizei n, GLuint *arrays) INIT_FASTPATH_GL_FUNC(); if (n < 0) { - _set_gl_error(GL_INVALID_VALUE); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } if (n == 0) goto finish; @@ -8334,7 +8360,7 @@ fastpath_glTexBuffer(GLenum target, GLenum internalformat, GLuint buffer) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - _set_gl_error(GL_INVALID_VALUE); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } _orig_fastpath_glTexBuffer(target, internalformat, real_obj); @@ -8374,7 +8400,7 @@ fastpath_glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, G INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - _set_gl_error(GL_INVALID_VALUE); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } _orig_fastpath_glTexBufferRange(target, internalformat, real_obj, offset, size); @@ -8495,7 +8521,7 @@ fastpath_glGetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { - _set_gl_error(GL_INVALID_VALUE); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } _orig_fastpath_glGetSamplerParameterIiv(real_obj, pname, params); -- 2.7.4 From 4738ec0f061dda7ef80f6b7a3cb11db662648f2f Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Tue, 9 Aug 2016 04:34:17 +0800 Subject: [PATCH 07/16] coregl_fastpath: Fix some issue in core_fastpath_gl.c Modification includes: 1. Add process for missed target 2. Pass real object to GL driver 3. Convert output parameters as needed Signed-off-by: Zhaowei Yuan Change-Id: Idcb6a992db8204d5880f098d6d8b37fdaae6e553 --- src/modules/fastpath/coregl_fastpath_gl.c | 495 ++++++++++++++++++------------ 1 file changed, 303 insertions(+), 192 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index c4a6840..ad9bdb8 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -363,6 +363,7 @@ fastpath_glClientActiveTexture (GLenum texture) CURR_STATE_UPDATE(gl_client_active_texture, 0, texture) } } + goto finish; finish: @@ -377,8 +378,7 @@ fastpath_glSampleCoveragex(GLclampx value, GLboolean invert) INIT_FASTPATH_GL_FUNC(); if(CURR_STATE_COMPARE(gl_sample_coverage_value, 0, value) || - CURR_STATE_COMPARE(gl_sample_coverage_invert, 0, invert)) - { + CURR_STATE_COMPARE(gl_sample_coverage_invert, 0, invert)) { IF_GL_SUCCESS(_orig_fastpath_glSampleCoveragex(value, invert)) { current_ctx->_misc_flag1 |= _MISC_FLAG1_BIT_gl_sample_coverage_value | @@ -388,6 +388,7 @@ fastpath_glSampleCoveragex(GLclampx value, GLboolean invert) CURR_STATE_UPDATE(gl_sample_coverage_invert, 0, invert); } } + goto finish; finish: @@ -531,6 +532,7 @@ fastpath_glBindTexture(GLenum target, GLuint texture) { int active_idx; GLuint real_obj; + int i; DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); @@ -538,14 +540,19 @@ fastpath_glBindTexture(GLenum target, GLuint texture) active_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0; - if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); - goto finish; - } - + /* in case of user didn't call glGenTextures first */ + if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) + real_obj = texture; #define STATE_PROC(gl_state, flagid, flagbit) \ - if CURR_STATE_COMPARE(gl_state, active_idx, real_obj) { \ + if(texture == 0) { \ + IF_GL_SUCCESS(_orig_fastpath_glBindTexture(target, real_obj)) { \ + current_ctx->flagid &= ~(flagbit##_##gl_state); \ + for(i = 0; i < current_ctx->gl_tex_units_num[0]; i++) \ + CURR_STATE_CLEAR(gl_state, i); \ + } \ + } \ + else if CURR_STATE_COMPARE(gl_state, active_idx, real_obj) { \ IF_GL_SUCCESS(_orig_fastpath_glBindTexture(target, real_obj)) { \ current_ctx->flagid |= flagbit##_##gl_state; \ CURR_STATE_UPDATE(gl_state, active_idx, real_obj); \ @@ -577,6 +584,9 @@ fastpath_glBindTexture(GLenum target, GLuint texture) case GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES: STATE_PROC(gl_tex_2d_multisample_array_oes_state, _tex_flag2, _TEX_FLAG2_BIT); break; + case GL_TEXTURE_CUBE_MAP_ARRAY_EXT: + STATE_PROC(gl_tex_cube_map_array_ext_state, _tex_flag2, _TEX_FLAG2_BIT); + break; default: _set_gl_error(GL_INVALID_ENUM); break; @@ -799,6 +809,18 @@ fastpath_glDeleteTextures(GLsizei n, const GLuint *textures) if (cur_gctx->gl_tex_external_oes_state[j] == objid_array[i]) { CURR_STATE_CLEAR(gl_tex_external_oes_state, j) } + if (cur_gctx->gl_tex_buffer_ext_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_buffer_ext_state, j) + } + if (cur_gctx->gl_tex_2d_multisample_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_2d_multisample_state, j) + } + if (cur_gctx->gl_tex_2d_multisample_array_oes_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_2d_multisample_array_oes_state, j) + } + if (cur_gctx->gl_tex_cube_map_array_ext_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_cube_map_array_ext_state, j) + } } } @@ -818,8 +840,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -//////////////////////////////////////////////////////////////////////// - void fastpath_glGenBuffers(GLsizei n, GLuint *buffers) { @@ -869,10 +889,9 @@ fastpath_glBindBuffer(GLenum target, GLuint buffer) _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); - goto finish; - } + /* in case of user didn't call glGenBuffer first */ + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) + real_obj = buffer; /* clear states set in fastpath_glBindBufferBase() */ #define BIND_STATE_ARRAY_CLEAR(gl_state) \ @@ -963,6 +982,112 @@ finish: _COREGL_FASTPATH_FUNC_END(); } +void +fastpath_glBindBufferBase(GLenum target, GLuint index, GLuint buffer) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + +#define STATE_PROC(gl_state, flagid, flagbit) \ + if CURR_STATE_COMPARE(gl_state##_array, index, real_obj) { \ + IF_GL_SUCCESS(_orig_fastpath_glBindBufferBase(target, index, real_obj)) { \ + current_ctx->flagid |= flagbit##_##gl_state; \ + CURR_STATE_UPDATE(gl_state##_array, index, real_obj) \ + current_ctx->gl_state##_array_offset[index] = 0; \ + current_ctx->gl_state##_array_size[index] = 0; \ + } \ + } + + switch (target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + STATE_PROC(gl_transform_feedback_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT); + break; + case GL_UNIFORM_BUFFER: + STATE_PROC(gl_uniform_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT); + break; + case GL_SHADER_STORAGE_BUFFER: + STATE_PROC(gl_shader_storage_buffer_binding, _bind_flag3, _BIND_FLAG3_BIT); + break; + case GL_ATOMIC_COUNTER_BUFFER: + STATE_PROC(gl_atomic_counter_buffer_binding, _bind_flag3, _BIND_FLAG3_BIT); + break; + default: + _set_gl_error(GL_INVALID_ENUM); + break; + } + + +#undef STATE_PROC + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} + +void +fastpath_glBindBufferRange(GLenum target, GLuint index, GLuint buffer, + GLintptr offset, GLsizeiptr size) +{ + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + +#define STATE_PROC(gl_state, flagid, flagbit) \ + { \ + if (CURR_STATE_COMPARE(gl_state##_array, index, real_obj) || \ + current_ctx->gl_state##_array_offset[index] != offset || \ + current_ctx->gl_state##_array_size[index] != size) { \ + IF_GL_SUCCESS(_orig_fastpath_glBindBufferRange(target, index, real_obj, offset, size)) { \ + current_ctx->flagid |= flagbit##gl_state; \ + CURR_STATE_UPDATE(gl_state##_array, index, real_obj) \ + current_ctx->gl_state##_array_offset[index] = offset; \ + current_ctx->gl_state##_array_size[index] = size; \ + } \ + } \ + } + + + switch (target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + STATE_PROC(gl_transform_feedback_buffer_range_binding, _bind_flag4, _BIND_FLAG4_BIT_); + break; + case GL_UNIFORM_BUFFER: + STATE_PROC(gl_uniform_buffer_range_binding, _bind_flag4, _BIND_FLAG4_BIT_); + break; + case GL_SHADER_STORAGE_BUFFER: + STATE_PROC(gl_shader_storage_buffer_range_binding, _bind_flag4, _BIND_FLAG4_BIT_); + break; + case GL_ATOMIC_COUNTER_BUFFER: + STATE_PROC(gl_atomic_counter_buffer_range_binding, _bind_flag4, _BIND_FLAG4_BIT_); + break; + default: + _set_gl_error(GL_INVALID_ENUM); + break; + } + +#undef STATE_PROC + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} GLboolean fastpath_glIsBuffer(GLuint buffer) @@ -992,7 +1117,7 @@ finish: void fastpath_glDeleteBuffers(GLsizei n, const GLuint *buffers) { - int i; + int i, j; GLuint *objid_array = NULL; DEFINE_FASTPAH_GL_FUNC(); @@ -1067,6 +1192,65 @@ fastpath_glDeleteBuffers(GLsizei n, const GLuint *buffers) cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_uniform_buffer_binding); CURR_STATE_CLEAR(gl_uniform_buffer_binding, 0) } + /* clear states array set in fastpath_glBindBufferBase() */ + for(j = 0; j < cur_gctx->gl_transform_feedback_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_transform_feedback_buffer_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag2 &= + (~_BIND_FLAG2_BIT_gl_transform_feedback_buffer_binding); + CURR_STATE_CLEAR(gl_transform_feedback_buffer_binding_array, j) + } + } + for(j = 0; j < cur_gctx->gl_uniform_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_uniform_buffer_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_uniform_buffer_binding); + CURR_STATE_CLEAR(gl_uniform_buffer_binding_array, j) + } + } + for(j = 0; j < cur_gctx->gl_shader_storage_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_shader_storage_buffer_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag3 &= (~_BIND_FLAG3_BIT_gl_shader_storage_buffer_binding); + CURR_STATE_CLEAR(gl_shader_storage_buffer_binding_array, j) + } + } + for(j = 0; j < cur_gctx->gl_atomic_counter_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_atomic_counter_buffer_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag3 &= (~_BIND_FLAG3_BIT_gl_atomic_counter_buffer_binding); + CURR_STATE_CLEAR(gl_atomic_counter_buffer_binding_array, j) + } + } + /* clear states array set in fastpath_glBindBufferRange() */ + for(j = 0; j < cur_gctx->gl_transform_feedback_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_transform_feedback_buffer_range_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag3 &= (~_BIND_FLAG4_BIT_gl_transform_feedback_buffer_range_binding); + CURR_STATE_CLEAR(gl_transform_feedback_buffer_range_binding_array, j) + cur_gctx->gl_transform_feedback_buffer_range_binding_array_offset[j] = 0; + cur_gctx->gl_transform_feedback_buffer_range_binding_array_size[j] = 0; + } + } + for(j = 0; j < cur_gctx->gl_uniform_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_uniform_buffer_range_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag3 &= (~_BIND_FLAG4_BIT_gl_uniform_buffer_range_binding); + CURR_STATE_CLEAR(gl_uniform_buffer_range_binding_array, j) + cur_gctx->gl_uniform_buffer_range_binding_array_offset[j] = 0; + cur_gctx->gl_uniform_buffer_range_binding_array_size[j] = 0; + } + } + for(j = 0; j < cur_gctx->gl_shader_storage_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_shader_storage_buffer_range_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag4 &= (~_BIND_FLAG4_BIT_gl_shader_storage_buffer_range_binding); + CURR_STATE_CLEAR(gl_shader_storage_buffer_range_binding_array, j) + cur_gctx->gl_shader_storage_buffer_range_binding_array_offset[j] = 0; + cur_gctx->gl_shader_storage_buffer_range_binding_array_size[j] = 0; + } + } + for(j = 0; j < cur_gctx->gl_atomic_counter_buffer_binding_num[0]; j++) { + if (cur_gctx->gl_atomic_counter_buffer_range_binding_array[j] == objid_array[i]) { + cur_gctx->_bind_flag4 &= (~_BIND_FLAG4_BIT_gl_atomic_counter_buffer_range_binding); + CURR_STATE_CLEAR(gl_atomic_counter_buffer_range_binding_array, j) + cur_gctx->gl_atomic_counter_buffer_range_binding_array_offset[j] = 0; + cur_gctx->gl_atomic_counter_buffer_range_binding_array_size[j] = 0; + } + } } current = current->next; } @@ -1084,8 +1268,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -////////////////////////////////////////////////////////////////////////////////// - void fastpath_glGenFramebuffers(GLsizei n, GLuint *framebuffers) { @@ -1124,7 +1306,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - void fastpath_glBindFramebuffer(GLenum target, GLuint framebuffer) { @@ -1202,7 +1383,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - GLboolean fastpath_glIsFramebuffer(GLuint framebuffer) { @@ -1302,8 +1482,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -////////////////////////////////////////////////////////////////////////////////// - void fastpath_glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) { @@ -1428,7 +1606,6 @@ finish: return ret; } - void fastpath_glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) { @@ -1494,9 +1671,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - -////////////////////////////////////////////////////////////////////////////////// - GLuint fastpath_glCreateProgram(void) { @@ -1519,7 +1693,6 @@ finish: return ret; } - GLuint fastpath_glCreateShader(GLenum type) { @@ -1542,7 +1715,6 @@ finish: return ret; } - void fastpath_glShaderSource(GLuint shader, GLsizei count, const char **string, const GLint *length) @@ -1557,6 +1729,7 @@ fastpath_glShaderSource(GLuint shader, GLsizei count, const char **string, _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glShaderSource(real_obj, count, string, length); goto finish; @@ -1565,7 +1738,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - void fastpath_glShaderBinary(GLsizei n, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length) @@ -2163,18 +2335,24 @@ finish: void fastpath_glActiveShaderProgramEXT(GLuint pipeline, GLuint program) { - GLuint real_obj; + GLuint real_program_obj; + GLuint real_pipeline_obj; DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { + if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_program_obj) != 1) { _set_gl_error(GL_INVALID_VALUE); goto finish; } - _orig_fastpath_glActiveShaderProgramEXT(pipeline, real_obj); + if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_pipeline_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glActiveShaderProgramEXT(real_pipeline_obj, real_program_obj); goto finish; @@ -2182,7 +2360,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - void fastpath_glProgramParameteriEXT(GLuint program, GLenum pname, GLint value) { @@ -2731,10 +2908,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - - -////////////////////////////////////////////////////////////////////////////////// - void fastpath_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) @@ -2746,8 +2919,7 @@ fastpath_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, if (CURR_STATE_COMPARE(gl_blend_color, 0, red) || CURR_STATE_COMPARE(gl_blend_color, 1, green) || CURR_STATE_COMPARE(gl_blend_color, 2, blue) || - CURR_STATE_COMPARE(gl_blend_color, 3, alpha) - ) { + CURR_STATE_COMPARE(gl_blend_color, 3, alpha)) { IF_GL_SUCCESS(_orig_fastpath_glBlendColor(red, green, blue, alpha)) { current_ctx->_blend_flag |= _BLEND_FLAG_BIT_gl_blend_color; CURR_STATE_UPDATE(gl_blend_color, 0, red) @@ -2786,7 +2958,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - void fastpath_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { @@ -3106,6 +3277,9 @@ fastpath_glDisable(GLenum cap) case GL_SAMPLE_MASK: STATE_PROC(gl_sample_mask, _enable_flag2, _ENABLE_FLAG2_BIT); break; + case GL_BLEND_ADVANCED_COHERENT_KHR: + STATE_PROC(gl_blend_advanced_coherent_khr, _enable_flag3, _ENABLE_FLAG3_BIT); + break; default: _set_gl_error(GL_INVALID_ENUM); break; @@ -3152,14 +3326,12 @@ fastpath_glEnable(GLenum cap) INIT_FASTPATH_GL_FUNC(); #define STATE_PROC(gl_state, flagid, flagbit) \ - if CURR_STATE_COMPARE(gl_state, 0, GL_TRUE) \ - { \ + if CURR_STATE_COMPARE(gl_state, 0, GL_TRUE) { \ _orig_fastpath_glEnable(cap); \ current_ctx->flagid |= flagbit##_##gl_state; \ CURR_STATE_UPDATE(gl_state, 0, GL_TRUE) \ } - switch (cap) { case GL_BLEND: STATE_PROC(gl_blend, _enable_flag1, _ENABLE_FLAG1_BIT); @@ -3195,9 +3367,15 @@ fastpath_glEnable(GLenum cap) case GL_STENCIL_TEST: STATE_PROC(gl_stencil_test, _enable_flag2, _ENABLE_FLAG2_BIT); break; + case GL_SAMPLE_MASK: + STATE_PROC(gl_sample_mask, _enable_flag2, _ENABLE_FLAG2_BIT); + break; case GL_BLEND_ADVANCED_COHERENT_KHR: STATE_PROC(gl_blend_advanced_coherent_khr, _enable_flag3, _ENABLE_FLAG3_BIT); break; + case GL_SAMPLE_SHADING_OES: + STATE_PROC(gl_sample_shading_oes, _enable_flag2, _ENABLE_FLAG2_BIT); + break; default: _set_gl_error(GL_INVALID_ENUM); break; @@ -3211,7 +3389,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - void fastpath_glEnableVertexAttribArray(GLuint index) { @@ -3261,7 +3438,6 @@ fastpath_glHint(GLenum target, GLenum mode) _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - #define STATE_PROC(gl_state, flagid, flagbit) \ if CURR_STATE_COMPARE(gl_state, 0, mode) { \ IF_GL_SUCCESS(_orig_fastpath_glHint(target, mode)) { \ @@ -3270,7 +3446,6 @@ fastpath_glHint(GLenum target, GLenum mode) } \ } - switch (target) { case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: STATE_PROC_WITH_CHECK(gl_fragment_shader_derivative_hint, _misc_flag1, @@ -4481,7 +4656,7 @@ fastpath_glFramebufferTextureLayer(GLenum target, GLenum attachment, goto finish; } - _orig_fastpath_glFramebufferTextureLayer(target, attachment, texture, level, + _orig_fastpath_glFramebufferTextureLayer(target, attachment, real_obj, level, layer); goto finish; @@ -4490,9 +4665,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - -//////////////////////////////////////////////////////////////////////// - void fastpath_glGenVertexArrays(GLsizei n, GLuint *arrays) { @@ -4648,8 +4820,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -//////////////////////////////////////////////////////////////////////// - void fastpath_glGetIntegeri_v(GLenum target, GLuint index, GLint *data) { @@ -4666,8 +4836,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -//////////////////////////////////////////////////////////////////////// - void fastpath_glGenTransformFeedbacks(GLsizei n, GLuint *ids) { @@ -4912,112 +5080,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -//////////////////////////////////////////////////////////////////////// - - -void -fastpath_glBindBufferBase(GLenum target, GLuint index, GLuint buffer) -{ - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); - goto finish; - } - -#define STATE_PROC(gl_state, flagid, flagbit) \ - if CURR_STATE_COMPARE(gl_state##_array, index, real_obj) { \ - IF_GL_SUCCESS(_orig_fastpath_glBindBufferBase(target, index, real_obj)) { \ - current_ctx->flagid |= flagbit##_##gl_state; \ - CURR_STATE_UPDATE(gl_state##_array, index, real_obj) \ - current_ctx->gl_state##_array_offset[index] = 0; \ - current_ctx->gl_state##_array_size[index] = 0; \ - } \ - } - - switch (target) { - case GL_TRANSFORM_FEEDBACK_BUFFER: - STATE_PROC(gl_transform_feedback_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT); - break; - case GL_UNIFORM_BUFFER: - STATE_PROC(gl_uniform_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT); - break; - case GL_SHADER_STORAGE_BUFFER: - STATE_PROC(gl_shader_storage_buffer_binding, _bind_flag3, _BIND_FLAG3_BIT); - break; - case GL_ATOMIC_COUNTER_BUFFER: - STATE_PROC(gl_atomic_counter_buffer_binding, _bind_flag3, _BIND_FLAG3_BIT); - break; - default: - _set_gl_error(GL_INVALID_ENUM); - break; - } - - -#undef STATE_PROC - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - - - -void -fastpath_glBindBufferRange(GLenum target, GLuint index, GLuint buffer, - GLintptr offset, GLsizeiptr size) -{ - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { - _set_gl_error(GL_OUT_OF_MEMORY); - goto finish; - } - -#define STATE_PROC(gl_state, flagnum) \ - { \ - if CURR_STATE_COMPARE(gl_state##_array, index, real_obj) { \ - IF_GL_SUCCESS(_orig_fastpath_glBindBufferRange(target, index, real_obj, offset, size)) { \ - current_ctx->_bind_flag2 |= _BIND_FLAG2_BIT_##gl_state; \ - CURR_STATE_UPDATE(gl_state##_array, index, real_obj) \ - current_ctx->gl_state##_array_offset[index] = offset; \ - current_ctx->gl_state##_array_size[index] = size; \ - } \ - } \ - } - - - switch (target) { - case GL_TRANSFORM_FEEDBACK_BUFFER: - STATE_PROC(gl_transform_feedback_buffer_binding, 0); - break; - case GL_UNIFORM_BUFFER: - STATE_PROC(gl_uniform_buffer_binding, 0); - break; - default: - _set_gl_error(GL_INVALID_ENUM); - break; - } - - -#undef STATE_PROC - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - - void fastpath_glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar *const *varyings, GLenum bufferMode) @@ -5486,9 +5548,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - -//////////////////////////////////////////////////////////////////////// - void fastpath_glGenSamplers(GLsizei n, GLuint *samplers) { @@ -5543,6 +5602,7 @@ fastpath_glBindSampler(GLuint unit, GLuint sampler) } _orig_fastpath_glBindSampler(unit, real_obj); + goto finish; finish: @@ -5624,9 +5684,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -//////////////////////////////////////////////////////////////////////// - - void fastpath_glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) { @@ -5730,7 +5787,9 @@ fastpath_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) goto finish; } - _orig_fastpath_glGetSamplerParameteriv(real_obj, pname, params); + IF_GL_SUCCESS(_orig_fastpath_glGetSamplerParameteriv(real_obj, pname, params)) { + _modify_get_value(pname, params, GL_INT, GL_FALSE); + } goto finish; @@ -5752,7 +5811,9 @@ fastpath_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) goto finish; } - _orig_fastpath_glGetSamplerParameterfv(real_obj, pname, params); + IF_GL_SUCCESS(_orig_fastpath_glGetSamplerParameterfv(real_obj, pname, params)) { + _modify_get_value(pname, params, GL_FLOAT, GL_FALSE); + } goto finish; @@ -5928,7 +5989,13 @@ fastpath_glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) case GL_COMPUTE_SHADER: case GL_INFO_LOG_LENGTH: case GL_VALIDATE_STATUS: - _orig_fastpath_glGetProgramPipelineiv(real_obj, pname, params); + case GL_TESS_CONTROL_SHADER_EXT: + case GL_TESS_EVALUATION_SHADER_EXT: + case GL_GEOMETRY_SHADER_EXT: + IF_GL_SUCCESS(_orig_fastpath_glGetProgramPipelineiv(real_obj, pname, params)) { + if(pname != GL_INFO_LOG_LENGTH && pname != GL_VALIDATE_STATUS) + _modify_get_value(pname, params, GL_INT, GL_FALSE); + } break; default: _set_gl_error(GL_INVALID_ENUM); @@ -6280,18 +6347,24 @@ finish: void fastpath_glActiveShaderProgram(GLuint pipeline, GLuint program) { - GLuint real_obj; + GLuint real_program_obj; + GLuint real_pipeline_obj; DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { + if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_program_obj) != 1) { _set_gl_error(GL_INVALID_VALUE); goto finish; } - _orig_fastpath_glActiveShaderProgram(pipeline, real_obj); + if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_pipeline_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glActiveShaderProgram(real_pipeline_obj, real_program_obj); goto finish; @@ -7094,11 +7167,18 @@ void fastpath_glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) { + GLuint real_obj; + DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - _orig_fastpath_glBindImageTexture(unit, texture, level, layered, layer, access, + if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + + _orig_fastpath_glBindImageTexture(unit, real_obj, level, layered, layer, access, format); goto finish; @@ -7147,7 +7227,9 @@ fastpath_glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - _orig_fastpath_glGetTexLevelParameteriv (target, level, pname, params); + IF_GL_SUCCESS(_orig_fastpath_glGetTexLevelParameteriv (target, level, pname, params)) { + _modify_get_value(pname, params, GL_INT, GL_FALSE); + } goto finish; @@ -7163,7 +7245,9 @@ fastpath_glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - _orig_fastpath_glGetTexLevelParameterfv (target, level, pname, params); + IF_GL_SUCCESS(_orig_fastpath_glGetTexLevelParameterfv (target, level, pname, params)) { + _modify_get_value(pname, params, GL_FLOAT, GL_FALSE); + } goto finish; @@ -7175,11 +7259,18 @@ void fastpath_glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride) { + GLuint real_obj; + DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - _orig_fastpath_glBindVertexBuffer(bindingindex, buffer, offset, stride); + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } + + _orig_fastpath_glBindVertexBuffer(bindingindex, real_obj, offset, stride); goto finish; @@ -7793,6 +7884,7 @@ fastpath_glDeleteQueriesEXT(GLsizei n, const GLuint *ids) { int i; GLuint *objid_array = NULL; + int real_n = 0; DEFINE_FASTPAH_GL_FUNC(); _COREGL_FASTPATH_FUNC_BEGIN(); @@ -7808,25 +7900,22 @@ fastpath_glDeleteQueriesEXT(GLsizei n, const GLuint *ids) AST(current_ctx->ostate.shared != NULL); objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); - { - int real_n = 0; - for (i = 0; i < n; i++) { - int real_objid = _COREGL_INT_INIT_VALUE; - if (ids[i] == 0) continue; + for (i = 0; i < n; i++) { + GLuint real_obj; + if (ids[i] == 0) + continue; - real_objid = fastpath_ostate_get_object(¤t_ctx->ostate, - GL_OBJECT_TYPE_QUERY, ids[i]); - if (real_objid == 0) continue; + if(GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, ids[i], &real_obj) != 1) + continue; AST(fastpath_ostate_remove_object(¤t_ctx->ostate, GL_OBJECT_TYPE_QUERY, ids[i]) == 1); - objid_array[real_n++] = real_objid; - } - - _orig_fastpath_glDeleteQueriesEXT(real_n, objid_array); + objid_array[real_n++] = real_obj; } + _orig_fastpath_glDeleteQueriesEXT(real_n, objid_array); + goto finish; finish: @@ -8231,12 +8320,13 @@ fastpath_glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays) int real_n = 0; for (i = 0; i < n; i++) { - int real_objid = _COREGL_INT_INIT_VALUE; - if (arrays[i] == 0) continue; + GLuint real_objid; - real_objid = fastpath_ostate_get_object(¤t_ctx->ostate, - GL_OBJECT_TYPE_VERTEXARRAY, arrays[i]); - if (real_objid == 0) continue; + if (arrays[i] == 0) + continue; + + if(GET_REAL_OBJ(GL_OBJECT_TYPE_VERTEXARRAY, arrays[i],&real_objid) != 1) + continue; AST(fastpath_ostate_remove_object(¤t_ctx->ostate, GL_OBJECT_TYPE_VERTEXARRAY, arrays[i]) == 1); @@ -8323,7 +8413,9 @@ fastpath_glBlendEquationi(GLuint buf, GLenum mode) _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glBlendEquationi(real_obj, mode); + goto finish; finish: @@ -8343,7 +8435,9 @@ fastpath_glBlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeAlpha) _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glBlendEquationSeparatei(real_obj, modeRGB, modeAlpha); + goto finish; finish: @@ -8363,7 +8457,9 @@ fastpath_glTexBuffer(GLenum target, GLenum internalformat, GLuint buffer) _set_gl_error(GL_INVALID_OPERATION); goto finish; } + _orig_fastpath_glTexBuffer(target, internalformat, real_obj); + goto finish; finish: @@ -8403,7 +8499,9 @@ fastpath_glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, G _set_gl_error(GL_INVALID_OPERATION); goto finish; } + _orig_fastpath_glTexBufferRange(target, internalformat, real_obj, offset, size); + goto finish; finish: @@ -8423,7 +8521,9 @@ fastpath_glGetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloa _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glGetnUniformfv(real_obj, location, bufSize, params); + goto finish; finish: @@ -8443,7 +8543,9 @@ fastpath_glGetnUniformiv(GLuint program, GLint location, GLsizei bufSize, GLint _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glGetnUniformiv(real_obj, location, bufSize, params); + goto finish; finish: @@ -8463,7 +8565,9 @@ fastpath_glGetnUniformuiv(GLuint program, GLint location, GLsizei bufSize, GLuin _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glGetnUniformuiv(real_obj, location, bufSize, params); + goto finish; finish: @@ -8485,6 +8589,7 @@ fastpath_glSamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *param) } _orig_fastpath_glSamplerParameterIiv(real_obj, pname, param); + goto finish; finish: @@ -8504,7 +8609,9 @@ fastpath_glSamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *para _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glSamplerParameterIuiv(real_obj, pname, param); + goto finish; finish: @@ -8524,7 +8631,9 @@ fastpath_glGetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) _set_gl_error(GL_INVALID_OPERATION); goto finish; } + _orig_fastpath_glGetSamplerParameterIiv(real_obj, pname, params); + goto finish; finish: @@ -8544,7 +8653,9 @@ fastpath_glGetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) _set_gl_error(GL_INVALID_VALUE); goto finish; } + _orig_fastpath_glGetSamplerParameterIuiv(real_obj, pname, params); + goto finish; finish: -- 2.7.4 From 6d246ee4c1db2482bb911fbe999e220e01b98232 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Tue, 9 Aug 2016 04:37:30 +0800 Subject: [PATCH 08/16] coregl_fastpath: reconstruct two functions This patch reconstruct function fastpath_glBindFramebuffer and fastpath_glBindFramebufferOES, make them more readable Signed-off-by: Zhaowei Yuan Change-Id: I4409475b970408da31bf95564954c43861657868 --- src/modules/fastpath/coregl_fastpath_gl.c | 191 ++++++++++++------------------ 1 file changed, 79 insertions(+), 112 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index ad9bdb8..3126967 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -1320,63 +1320,52 @@ fastpath_glBindFramebuffer(GLenum target, GLuint framebuffer) goto finish; } - if (target == GL_FRAMEBUFFER) { - if (current_ctx->gl_framebuffer_binding_read_used == 1) { - if CURR_STATE_COMPARE(gl_framebuffer_binding_read, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read; - CURR_STATE_UPDATE(gl_framebuffer_binding_read, 0, real_obj) - } - } - if CURR_STATE_COMPARE(gl_framebuffer_binding_draw, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw; - CURR_STATE_UPDATE(gl_framebuffer_binding_draw, 0, real_obj) - } - } - } else { - if CURR_STATE_COMPARE(gl_framebuffer_binding, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding; - CURR_STATE_UPDATE(gl_framebuffer_binding, 0, real_obj) - } - } - } - } else if (target == GL_READ_FRAMEBUFFER && - current_ctx->gl_framebuffer_binding_read_used) { - if CURR_STATE_COMPARE(gl_framebuffer_binding_read, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read; - CURR_STATE_UPDATE(gl_framebuffer_binding_read, 0, real_obj) - } - } - } else if (target == GL_DRAW_FRAMEBUFFER && - current_ctx->gl_framebuffer_binding_draw_used) { - if CURR_STATE_COMPARE(gl_framebuffer_binding_draw, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw; - CURR_STATE_UPDATE(gl_framebuffer_binding_draw, 0, real_obj) - } - } - } else { - _set_gl_error(GL_INVALID_ENUM); - goto finish; +#define STATE_PROC(gl_state, flagid, flagbit) \ + { \ + if(real_obj == 0) { \ + IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { \ + current_ctx->flagid &= (~flagbit##_##gl_state); \ + CURR_STATE_CLEAR(gl_state, 0); \ + } \ + }\ + else if CURR_STATE_COMPARE(gl_state, 0, real_obj) { \ + IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) { \ + if (real_obj == 0) \ + current_ctx->flagid &= (~flagbit##_##gl_state); \ + else \ + current_ctx->flagid |= flagbit##_##gl_state; \ + CURR_STATE_UPDATE(gl_state, 0, real_obj) \ + if((target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER) && \ + current_ctx->gl_framebuffer_binding_read_used) \ + CURR_STATE_CLEAR(gl_read_buffer, 0) \ + } \ + } \ + } + + switch(target) { + case GL_FRAMEBUFFER: + if (current_ctx->gl_framebuffer_binding_read_used) + STATE_PROC(gl_framebuffer_binding_read, _bind_flag1, _BIND_FLAG1_BIT) + if (current_ctx->gl_framebuffer_binding_draw_used) + STATE_PROC(gl_framebuffer_binding_draw, _bind_flag1, _BIND_FLAG1_BIT) + if(!current_ctx->gl_framebuffer_binding_read_used && !current_ctx->gl_framebuffer_binding_draw_used) + STATE_PROC(gl_framebuffer_binding, _bind_flag1, _BIND_FLAG1_BIT) + break; + case GL_READ_FRAMEBUFFER: + if (current_ctx->gl_framebuffer_binding_read_used) + STATE_PROC(gl_framebuffer_binding_read, _bind_flag1, _BIND_FLAG1_BIT) + break; + case GL_DRAW_FRAMEBUFFER: + if (current_ctx->gl_framebuffer_binding_draw_used) + STATE_PROC(gl_framebuffer_binding_draw, _bind_flag1, _BIND_FLAG1_BIT) + break; + default: + _set_gl_error(GL_INVALID_ENUM); + goto finish; } + +#undef STATE_PROC + goto finish; finish: @@ -7292,63 +7281,41 @@ fastpath_glBindFramebufferOES(GLenum target, GLuint framebuffer) goto finish; } - if (target == GL_FRAMEBUFFER) { - if (current_ctx->gl_framebuffer_binding_read_used == 1) { - if CURR_STATE_COMPARE(gl_framebuffer_binding_read, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read; - CURR_STATE_UPDATE(gl_framebuffer_binding_read, 0, real_obj) - } - } - if CURR_STATE_COMPARE(gl_framebuffer_binding_draw, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw; - CURR_STATE_UPDATE(gl_framebuffer_binding_draw, 0, real_obj) - } - } - } else { - if CURR_STATE_COMPARE(gl_framebuffer_binding, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding; - CURR_STATE_UPDATE(gl_framebuffer_binding, 0, real_obj) - } - } - } - } else if (target == GL_READ_FRAMEBUFFER && - current_ctx->gl_framebuffer_binding_read_used) { - if CURR_STATE_COMPARE(gl_framebuffer_binding_read, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read; - CURR_STATE_UPDATE(gl_framebuffer_binding_read, 0, real_obj) - } - } - } else if (target == GL_DRAW_FRAMEBUFFER && - current_ctx->gl_framebuffer_binding_draw_used) { - if CURR_STATE_COMPARE(gl_framebuffer_binding_draw, 0, real_obj) { - IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) { - if (real_obj == 0) - current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw); - else - current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw; - CURR_STATE_UPDATE(gl_framebuffer_binding_draw, 0, real_obj) - } - } - } else { - _set_gl_error(GL_INVALID_ENUM); - goto finish; +#define STATE_PROC(gl_state, flagid, flagbit) \ + if CURR_STATE_COMPARE(gl_framebuffer_binding_read, 0, real_obj) { \ + IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) { \ + if (real_obj == 0) \ + current_ctx->flagid &= (~flagbit##_##gl_state); \ + else \ + current_ctx->flagid |= flagbit##_##gl_state; \ + CURR_STATE_UPDATE(gl_state, 0, real_obj) \ + } \ + } + + switch(target) { + case GL_FRAMEBUFFER: + if (current_ctx->gl_framebuffer_binding_read_used) + STATE_PROC(gl_framebuffer_binding_read, _bind_flag1, _BIND_FLAG1_BIT) + if (current_ctx->gl_framebuffer_binding_draw_used) + STATE_PROC(gl_framebuffer_binding_draw, _bind_flag1, _BIND_FLAG1_BIT) + if(!current_ctx->gl_framebuffer_binding_read_used && !current_ctx->gl_framebuffer_binding_draw_used) + STATE_PROC(gl_framebuffer_binding, _bind_flag1, _BIND_FLAG1_BIT) + break; + case GL_READ_FRAMEBUFFER: + if (current_ctx->gl_framebuffer_binding_read_used) + STATE_PROC(gl_framebuffer_binding_read, _bind_flag1, _BIND_FLAG1_BIT) + break; + case GL_DRAW_FRAMEBUFFER: + if (current_ctx->gl_framebuffer_binding_draw_used) + STATE_PROC(gl_framebuffer_binding_draw, _bind_flag1, _BIND_FLAG1_BIT) + break; + default: + _set_gl_error(GL_INVALID_ENUM); + goto finish; } + +#undef STATE_PROC + goto finish; finish: -- 2.7.4 From 13c8865e82d7c81b14366b1fb3fa69b0a2937063 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Wed, 24 Aug 2016 03:20:04 +0800 Subject: [PATCH 09/16] coregl_fastpath: Adjust Sequence of functions according their category It's better to put functions together which belong to a same category Signed-off-by: Zhaowei Yuan Change-Id: I9919b884df98515bc85e3777fb407e3ff638874f --- src/modules/fastpath/coregl_fastpath_gl.c | 278 +++++++++++++++--------------- 1 file changed, 137 insertions(+), 141 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index 3126967..fff59f9 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -601,6 +601,121 @@ finish: _COREGL_FASTPATH_FUNC_END(); } +GLboolean +fastpath_glIsTexture(GLuint texture) +{ + GLboolean ret = GL_FALSE; + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { + ret = GL_FALSE; + goto finish; + } + + ret = _orig_fastpath_glIsTexture(real_obj); + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); + return ret; +} + +void +fastpath_glDeleteTextures(GLsizei n, const GLuint *textures) +{ + int i, j; + GLuint *objid_array = NULL; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (n < 0) { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + if (n == 0) goto finish; + if (textures == NULL) goto finish; + + AST(current_ctx->ostate.shared != NULL); + + objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); + { + int real_n = 0; + + for (i = 0; i < n; i++) { + int real_objid = _COREGL_INT_INIT_VALUE; + if (textures[i] == 0) continue; + + real_objid = fastpath_ostate_get_object(¤t_ctx->ostate, + GL_OBJECT_TYPE_TEXTURE, textures[i]); + if (real_objid == 0) continue; + + AST(fastpath_ostate_remove_object(¤t_ctx->ostate, GL_OBJECT_TYPE_TEXTURE, + textures[i]) == 1); + objid_array[real_n++] = real_objid; + } + + IF_GL_SUCCESS(_orig_fastpath_glDeleteTextures(real_n, objid_array)) { + for (i = 0; i < real_n; i++) { + General_Trace_List *current = NULL; + current = current_ctx->ostate.shared->using_gctxs; + + while (current != NULL) { + GLGlueContext *cur_gctx = (GLGlueContext *)current->value; + + if (cur_gctx->initialized == 1) { + for (j = 0; j < cur_gctx->gl_tex_units_num[0]; j++) { + if (cur_gctx->gl_tex_2d_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_2d_state, j) + } + if (cur_gctx->gl_tex_3d_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_3d_state, j) + } + if (cur_gctx->gl_tex_2d_array_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_2d_array_state, j) + } + if (cur_gctx->gl_tex_cube_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_cube_state, j) + } + if (cur_gctx->gl_tex_external_oes_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_external_oes_state, j) + } + if (cur_gctx->gl_tex_buffer_ext_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_buffer_ext_state, j) + } + if (cur_gctx->gl_tex_2d_multisample_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_2d_multisample_state, j) + } + if (cur_gctx->gl_tex_2d_multisample_array_oes_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_2d_multisample_array_oes_state, j) + } + if (cur_gctx->gl_tex_cube_map_array_ext_state[j] == objid_array[i]) { + CURR_STATE_CLEAR(gl_tex_cube_map_array_ext_state, j) + } + } + } + + current = current->next; + } + } + } + } + + goto finish; + +finish: + if (objid_array != NULL) { + free(objid_array); + objid_array = NULL; + } + _COREGL_FASTPATH_FUNC_END(); +} void fastpath_glFramebufferTexture2D(GLenum target, GLenum attachment, @@ -722,124 +837,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - -GLboolean -fastpath_glIsTexture(GLuint texture) -{ - GLboolean ret = GL_FALSE; - GLuint real_obj; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { - ret = GL_FALSE; - goto finish; - } - - ret = _orig_fastpath_glIsTexture(real_obj); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); - return ret; -} - - -void -fastpath_glDeleteTextures(GLsizei n, const GLuint *textures) -{ - int i, j; - GLuint *objid_array = NULL; - - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - if (n < 0) { - _set_gl_error(GL_INVALID_VALUE); - goto finish; - } - if (n == 0) goto finish; - if (textures == NULL) goto finish; - - AST(current_ctx->ostate.shared != NULL); - - objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); - { - int real_n = 0; - - for (i = 0; i < n; i++) { - int real_objid = _COREGL_INT_INIT_VALUE; - if (textures[i] == 0) continue; - - real_objid = fastpath_ostate_get_object(¤t_ctx->ostate, - GL_OBJECT_TYPE_TEXTURE, textures[i]); - if (real_objid == 0) continue; - - AST(fastpath_ostate_remove_object(¤t_ctx->ostate, GL_OBJECT_TYPE_TEXTURE, - textures[i]) == 1); - objid_array[real_n++] = real_objid; - } - - IF_GL_SUCCESS(_orig_fastpath_glDeleteTextures(real_n, objid_array)) { - for (i = 0; i < real_n; i++) { - General_Trace_List *current = NULL; - current = current_ctx->ostate.shared->using_gctxs; - - while (current != NULL) { - GLGlueContext *cur_gctx = (GLGlueContext *)current->value; - - if (cur_gctx->initialized == 1) { - for (j = 0; j < cur_gctx->gl_tex_units_num[0]; j++) { - if (cur_gctx->gl_tex_2d_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_2d_state, j) - } - if (cur_gctx->gl_tex_3d_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_3d_state, j) - } - if (cur_gctx->gl_tex_2d_array_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_2d_array_state, j) - } - if (cur_gctx->gl_tex_cube_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_cube_state, j) - } - if (cur_gctx->gl_tex_external_oes_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_external_oes_state, j) - } - if (cur_gctx->gl_tex_buffer_ext_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_buffer_ext_state, j) - } - if (cur_gctx->gl_tex_2d_multisample_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_2d_multisample_state, j) - } - if (cur_gctx->gl_tex_2d_multisample_array_oes_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_2d_multisample_array_oes_state, j) - } - if (cur_gctx->gl_tex_cube_map_array_ext_state[j] == objid_array[i]) { - CURR_STATE_CLEAR(gl_tex_cube_map_array_ext_state, j) - } - } - } - - current = current->next; - } - } - } - } - - goto finish; - -finish: - if (objid_array != NULL) { - free(objid_array); - objid_array = NULL; - } - _COREGL_FASTPATH_FUNC_END(); -} - void fastpath_glGenBuffers(GLsizei n, GLuint *buffers) { @@ -3284,29 +3281,6 @@ finish: _COREGL_FASTPATH_FUNC_END(); } - -void -fastpath_glDisableVertexAttribArray(GLuint index) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - 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) - } - } - } - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - void fastpath_glEnable(GLenum cap) { @@ -3400,6 +3374,28 @@ finish: _COREGL_FASTPATH_FUNC_END(); } +void +fastpath_glDisableVertexAttribArray(GLuint index) +{ + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + 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) + } + } + } + + goto finish; + +finish: + _COREGL_FASTPATH_FUNC_END(); +} + void fastpath_glFrontFace(GLenum mode) -- 2.7.4 From 0c4d0844016f2d338b4806cafcce58aa414b055c Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Wed, 24 Aug 2016 03:30:15 +0800 Subject: [PATCH 10/16] coregl_fastpath: Fix issue occurs in vertex array Enable/Disabe 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 Change-Id: I7d686cc603dfb74e305c64687eaea36be6f1aea1 --- src/modules/fastpath/coregl_fastpath_gl.c | 42 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index fff59f9..1f397c6 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -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) { -- 2.7.4 From fb7b279451cb4fabc8fe4f856f9b6a4b5cd81b85 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Wed, 24 Aug 2016 03:54:02 +0800 Subject: [PATCH 11/16] coregl_fastpath: Change GL error number as driver does GL error number should be set according to the behavior of GL driver or specification files Signed-off-by: Zhaowei Yuan Change-Id: I20e2426fd8e472eba4be54b721748e4479a68e05 --- src/modules/fastpath/coregl_fastpath_gl.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index 1f397c6..7c3522e 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -8800,7 +8800,7 @@ fastpath_glGetSamplerParameterIivEXT(GLuint sampler, GLenum pname, GLint *params INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { - _set_gl_error(GL_INVALID_ENUM); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -8821,7 +8821,7 @@ fastpath_glGetSamplerParameterIuivEXT(GLuint sampler, GLenum pname, GLuint *para INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { - _set_gl_error(GL_INVALID_ENUM); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -8842,7 +8842,7 @@ fastpath_glSamplerParameterIivEXT(GLuint sampler, GLenum pname, const GLint *par INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { - _set_gl_error(GL_INVALID_ENUM); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -8883,10 +8883,19 @@ fastpath_glTexBufferRangeEXT(GLenum target, GLenum internalformat, GLuint buffer _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + if(target != GL_TEXTURE_BUFFER_EXT){ _set_gl_error(GL_INVALID_ENUM); goto finish; } + if (offset < 0 || size<=0){ + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); + goto finish; + } _orig_fastpath_glTexBufferRangeEXT(target, internalformat, real_obj, offset, size); @@ -8905,7 +8914,7 @@ fastpath_glSamplerParameterIuivEXT(GLuint sampler, GLenum pname, const GLuint *p INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) { - _set_gl_error(GL_INVALID_ENUM); + _set_gl_error(GL_INVALID_OPERATION); goto finish; } @@ -8925,8 +8934,11 @@ fastpath_glTexBufferEXT(GLenum target, GLenum internalformat, GLuint buffer) _COREGL_FASTPATH_FUNC_BEGIN(); INIT_FASTPATH_GL_FUNC(); - if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + if(target != GL_TEXTURE_BUFFER_EXT) _set_gl_error(GL_INVALID_ENUM); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { + _set_gl_error(GL_INVALID_OPERATION); goto finish; } -- 2.7.4 From ce119e6ed19e74ce7a5f33ac6f75b5f131d25796 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Wed, 24 Aug 2016 05:04:18 +0800 Subject: [PATCH 12/16] Coregl_fastpath: Change fast path process for GLES 1.1 Since contexts with different GLES API version can coexist in a same thread, the real API version can't be decided by driver_gl_version, so create a new global vriable to hold the real GLES API after context switching finished. When real GLES API version becomes 1.1, then disable fast path for all GL interfaces. Modification includes: 1. Create variable current_gl_api_version which will be updated once context switching finished, if it becomes 1.1, disable fast path for all GL interfaces. 2. Change arguments list of function init_export and _clean_overrides in order to reset egl and gl respectively 3. in function _clean_overrides(): Override all interfaces listed in file sym_gl1.h, sym_gl2.h and sym_gl_common.h, regardless of current GLES API version, because interface of low version maybe called during a high version context. Overriding here doesn't cause any problem. Signed-off-by: Zhaowei Yuan Change-Id: I48adacc063105c53276a9c5003142e670dce0ed3 --- src/coregl.c | 2 +- src/coregl_export.c | 25 ++++++++++++------------- src/coregl_export.h | 3 ++- src/coregl_internal.h | 2 +- src/modules/coregl_module.c | 2 +- src/modules/fastpath/coregl_fastpath_egl.c | 5 +++++ 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/coregl.c b/src/coregl.c index e94d1c9..9f70fc1 100644 --- a/src/coregl.c +++ b/src/coregl.c @@ -251,7 +251,7 @@ coregl_initialize() if (!_gl_lib_init()) return 0; - init_export(); + init_export(GL_TRUE, GL_TRUE); COREGL_LOG(" -> Completed\n"); diff --git a/src/coregl_export.c b/src/coregl_export.c index 4215f15..9525dbd 100644 --- a/src/coregl_export.c +++ b/src/coregl_export.c @@ -13,7 +13,7 @@ int export_initialized = 0; static int api_gl_version; static void -_clean_overrides() +_clean_overrides(GLboolean init_egl, GLboolean init_gl) { #define _COREGL_START_API(version) api_gl_version = version; #define _COREGL_END_API(version) api_gl_version = COREGL_GLAPI_2; @@ -22,31 +22,30 @@ _clean_overrides() COREGL_OVERRIDE_API(ovr_, f, _sym_) #define _COREGL_SYMBOL(RET_TYPE, FUNC_NAME, PARAM_LIST) OVERRIDE(FUNC_NAME); -# include "headers/sym_egl.h" + if(init_egl == GL_TRUE) { + # include "headers/sym_egl.h" + } #undef _COREGL_SYMBOL #undef OVERRIDE #define OVERRIDE(f) \ if(api_gl_version<=driver_gl_version) COREGL_OVERRIDE_API(ovr_, f, _sym_) #define _COREGL_SYMBOL(RET_TYPE, FUNC_NAME, PARAM_LIST) OVERRIDE(FUNC_NAME); -if(driver_gl_version == COREGL_GLAPI_1) { - #include "headers/sym_gl1.h" - #include "headers/sym_gl_common.h" -} -else if(driver_gl_version >= COREGL_GLAPI_2) { - #include "headers/sym_gl2.h" - #include "headers/sym_gl_common.h" -} + if(init_gl == GL_TRUE) { + #include "headers/sym_gl1.h" + #include "headers/sym_gl2.h" + #include "headers/sym_gl_common.h" + } #undef _COREGL_SYMBOL - #undef OVERRIDE + #undef _COREGL_START_API #undef _COREGL_END_API } void -init_export() +init_export(GLboolean init_egl, GLboolean init_gl) { - _clean_overrides(); + _clean_overrides(init_egl, init_gl); } diff --git a/src/coregl_export.h b/src/coregl_export.h index 537a313..c6e6309 100644 --- a/src/coregl_export.h +++ b/src/coregl_export.h @@ -9,8 +9,9 @@ extern int export_initialized; extern int driver_gl_version; +extern int current_gl_api_version; -extern void init_export(); +extern void init_export(GLboolean init_egl, GLboolean init_gl); extern void clean_overrides(); #endif // COREGL_EXPORT_H diff --git a/src/coregl_internal.h b/src/coregl_internal.h index b1cfc51..a183dd7 100644 --- a/src/coregl_internal.h +++ b/src/coregl_internal.h @@ -150,7 +150,7 @@ extern GLThreadState *get_current_thread_state(); // Override functions -extern void init_export(); +extern void init_export(GLboolean init_egl, GLboolean init_gl); extern void deinit_export(); // Module interfaces diff --git a/src/modules/coregl_module.c b/src/modules/coregl_module.c index 84081ac..40f8119 100644 --- a/src/modules/coregl_module.c +++ b/src/modules/coregl_module.c @@ -37,7 +37,7 @@ void reset_modules_override() { // Step 1 : Initialization - init_export(); + init_export(GL_TRUE, GL_TRUE); // Step 2 : User Define Modules : Sequence is important! (Last module's API is called first) fastpath_apply_overrides(); diff --git a/src/modules/fastpath/coregl_fastpath_egl.c b/src/modules/fastpath/coregl_fastpath_egl.c index ed3bcbc..265cc18 100644 --- a/src/modules/fastpath/coregl_fastpath_egl.c +++ b/src/modules/fastpath/coregl_fastpath_egl.c @@ -14,6 +14,7 @@ General_Trace_List *glue_ctx_trace_list = NULL; General_Trace_List *context_state_trace_list = NULL; +int current_gl_api_version = 0; static void _dump_context_info(const char *ment, int force_output) @@ -1196,6 +1197,10 @@ fastpath_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, goto finish; } + current_gl_api_version = ((EGL_packed_option *)gctx->real_ctx_option)->attrib_list.context_major_version; + if(current_gl_api_version == COREGL_GLAPI_1) + init_export(GL_FALSE, GL_TRUE); + // Update references only when the contexts are different if (tstate->cstate != gctx->cstate) { if (tstate->cstate != NULL && tstate->cstate->data != NULL) -- 2.7.4 From ebb209707b77d306845250167152827630788283 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Thu, 25 Aug 2016 09:15:07 +0800 Subject: [PATCH 13/16] coregl: Clear GL error after getting state Getting state in function fastpath_dump_context_states and tracepath_dump_context_states is possible failed, but it's acceptable due to GL API version difference, so clear the possible GL error after getting state. Signed-off-by: Zhaowei Yuan Change-Id: I35cf758aa999498f001e2463c2b7988bc4579071 --- src/modules/fastpath/coregl_fastpath.c | 1 + src/modules/tracepath/coregl_tracepath.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/modules/fastpath/coregl_fastpath.c b/src/modules/fastpath/coregl_fastpath.c index 5206bf4..4d3c161 100644 --- a/src/modules/fastpath/coregl_fastpath.c +++ b/src/modules/fastpath/coregl_fastpath.c @@ -1445,6 +1445,7 @@ fastpath_dump_context_states(GLGlueContext *ctx, int force_output) TYPE *value = NULL; \ if(api_gl_version <= driver_gl_version) { \ value = valuedata; GET_STMT; value = valuedata; \ + _sym_glGetError();\ TRACE("\E[40;37;1m %-30.30s : (\E[0m ", #NAME); \ for (int i = 0; i < SIZE; i++) \ { \ diff --git a/src/modules/tracepath/coregl_tracepath.c b/src/modules/tracepath/coregl_tracepath.c index 56781ce..63a1cb9 100644 --- a/src/modules/tracepath/coregl_tracepath.c +++ b/src/modules/tracepath/coregl_tracepath.c @@ -572,6 +572,7 @@ tracepath_dump_context_states(int force_output) TYPE valuedata[SIZE]; \ TYPE *value = NULL; \ value = valuedata; GET_STMT; value = valuedata; \ + _sym_glGetError(); \ TRACE("\E[40;37;1m %-30.30s : (\E[0m ", #NAME); \ for (int i = 0; i < SIZE; i++) \ { \ -- 2.7.4 From 405a74929803f3cdc5f72d873759ee5072228c23 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Fri, 26 Aug 2016 05:54:32 +0800 Subject: [PATCH 14/16] coregl_tracepath: Copy name with the real size Memory region newitm->name is new allocated here whose content is uncertain, so the result of strlen(newitm->name) is 0 or a random number Signed-off-by: Zhaowei Yuan Change-Id: I9a08350c2f2326089101f3cc8df74077dd3dd37d --- src/modules/tracepath/coregl_tracepath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/tracepath/coregl_tracepath.c b/src/modules/tracepath/coregl_tracepath.c index 63a1cb9..f3a5a28 100644 --- a/src/modules/tracepath/coregl_tracepath.c +++ b/src/modules/tracepath/coregl_tracepath.c @@ -674,7 +674,7 @@ _get_trace_data(Trace_Data **ftd_table, size_t td_size, const char *name) } else { Trace_Data *newitm = NULL; newitm = (Trace_Data *)calloc(1, td_size); - strncpy(newitm->name, name, strlen(newitm->name)); + strncpy(newitm->name, name, strlen(name) < (sizeof(newitm->name) -1) ? strlen(name) : (sizeof(newitm->name) -1)); newitm->next = NULL; if (prev != NULL) { -- 2.7.4 From c74c199cfbab5d54dad0046b0d747ace552aebe4 Mon Sep 17 00:00:00 2001 From: Junghyun Kim Date: Thu, 25 Aug 2016 09:14:08 +0900 Subject: [PATCH 15/16] build: Use commit date instead of build date to avoid unnecessary rebuilds. - Problem We use OBS to build packages in Tizen. There is a mechanism not to rebuild when the result binary is the same. For example, there is a dependency graph: A->B->C. If A is modified, B would be built. If the result RPM of B is not changed, OBS does not trigger a build of C. To effectively use this mechanism, each packages make sure that the result binary should be the same if the input source is the same. There is a reason we found is including build date. In coregl, bash command 'date' is used in CMakeList.txt. In this case, everytime we build coregl, the build result is always different. - Solution Use commit date instead of build date. There was a hint in Makefile. COMPILE_DATE = "\"`git log -1 --pretty=format:%ci`\"" I used this command in CMakeList.txt I tested this in my test OBS server, and the build result is unchanged when this patch is applied. Change-Id: Iea70e74b6808aa81905eba4afc9e72b6867c097d Signed-off-by: Junghyun Kim --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39bd6ad..78417b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,9 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include_KHR) ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") -EXEC_PROGRAM(date OUTPUT_VARIABLE COMPILE_DATE) +EXEC_PROGRAM(git + ARGS log -1 --pretty=format:%ci + OUTPUT_VARIABLE COMPILE_DATE) ADD_DEFINITIONS("-D_COREGL_COMPILE_DATE=\"${COMPILE_DATE}\"") IF(USE_ADRENO) -- 2.7.4 From 1b04448b538ba0cf1f7336886932b6061322ce4e Mon Sep 17 00:00:00 2001 From: Gwan-gyeong Mun Date: Sat, 27 Aug 2016 04:57:58 -0700 Subject: [PATCH 16/16] This patch does not create right result. When we run gl application, we expect the result like as " [CoreGL] <1004> (Sat Aug 27 11:08:17 UTC 2016) Library initializing... [CoreGL] Driver GL version 3.2 " but this patch shows " [CoreGL] <1026> (fatal: Not a git repository (or any of the parent directories): .git) Library initializing... [CoreGL] Driver GL version 3.2 " so we should fix it Revert "build: Use commit date instead of build date to avoid unnecessary rebuilds." This reverts commit c74c199cfbab5d54dad0046b0d747ace552aebe4. Change-Id: I370d5ea701bd6635be1b99972607c5fff6fbfd58 --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78417b6..39bd6ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,9 +43,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include_KHR) ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") -EXEC_PROGRAM(git - ARGS log -1 --pretty=format:%ci - OUTPUT_VARIABLE COMPILE_DATE) +EXEC_PROGRAM(date OUTPUT_VARIABLE COMPILE_DATE) ADD_DEFINITIONS("-D_COREGL_COMPILE_DATE=\"${COMPILE_DATE}\"") IF(USE_ADRENO) -- 2.7.4