From ce675466314de1eddb14628eba18f3f8a46a4ae4 Mon Sep 17 00:00:00 2001 From: Haegeun Park Date: Mon, 14 Oct 2013 03:06:19 -0700 Subject: [PATCH] [INTERNAL ES3.0] Added Handling for ReadBuffer, Queries Object --- src/modules/fastpath/coregl_fastpath.c | 41 ++++-- src/modules/fastpath/coregl_fastpath.h | 4 + src/modules/fastpath/coregl_fastpath_gl.c | 182 +++++++++++++++++++++------ src/modules/fastpath/coregl_fastpath_state.h | 3 + 4 files changed, 179 insertions(+), 51 deletions(-) diff --git a/src/modules/fastpath/coregl_fastpath.c b/src/modules/fastpath/coregl_fastpath.c index c944e2e..c84b712 100644 --- a/src/modules/fastpath/coregl_fastpath.c +++ b/src/modules/fastpath/coregl_fastpath.c @@ -295,9 +295,9 @@ fastpath_apply_overrides_gl(int enable) COREGL_OVERRIDE(fastpath_, glEGLImageTargetTexture2DOES); COREGL_OVERRIDE(fastpath_, glFramebufferTexture3DOES); - /* ES 3.0 BLOCK */ COREGL_OVERRIDE(fastpath_, glReadBuffer); - COREGL_OVERRIDE(fastpath_, glDrawRangeElements); + + /* ES 3.0 BLOCK */ COREGL_OVERRIDE(fastpath_, glGenQueries); COREGL_OVERRIDE(fastpath_, glDeleteQueries); COREGL_OVERRIDE(fastpath_, glIsQuery); @@ -417,6 +417,8 @@ _get_shared_object_hash(GL_Shared_Object_State *sostate, GL_Object_Type type) return &sostate->renderbuffer; case GL_OBJECT_TYPE_PROGRAM: return &sostate->program; + case GL_OBJECT_TYPE_QUERY: + return &sostate->query; default: return NULL; } @@ -437,6 +439,8 @@ _get_shared_object_hash_real(GL_Shared_Object_State *sostate, GL_Object_Type typ return &sostate->renderbuffer_real; case GL_OBJECT_TYPE_PROGRAM: return &sostate->program_real; + case GL_OBJECT_TYPE_QUERY: + return &sostate->query_real; default: return NULL; } @@ -603,12 +607,14 @@ fastpath_sostate_init(GL_Shared_Object_State *sostate) HASH_INIT(sostate->framebuffer); HASH_INIT(sostate->renderbuffer); HASH_INIT(sostate->program); + HASH_INIT(sostate->query); HASH_INIT(sostate->texture_real); HASH_INIT(sostate->buffer_real); HASH_INIT(sostate->framebuffer_real); HASH_INIT(sostate->renderbuffer_real); HASH_INIT(sostate->program_real); + HASH_INIT(sostate->query_real); #undef HASH_INIT } @@ -704,12 +710,14 @@ fastpath_sostate_deinit(GL_Shared_Object_State *sostate) HASH_DEINIT(sostate->framebuffer, 1); HASH_DEINIT(sostate->renderbuffer, 1); HASH_DEINIT(sostate->program, 1); + HASH_DEINIT(sostate->query, 1); HASH_DEINIT(sostate->texture_real, 0); HASH_DEINIT(sostate->buffer_real, 0); HASH_DEINIT(sostate->framebuffer_real, 0); HASH_DEINIT(sostate->renderbuffer_real, 0); HASH_DEINIT(sostate->program_real, 0); + HASH_DEINIT(sostate->query_real, 0); #undef HASH_DEINIT } @@ -1336,7 +1344,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_BLEND)) - } + } STATE_COMPARE(gl_cull_face[0]) { if (newctx->gl_cull_face[0]) @@ -1345,7 +1353,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_CULL_FACE)) - } + } STATE_COMPARE(gl_depth_test[0]) { if (newctx->gl_depth_test[0]) @@ -1354,7 +1362,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_DEPTH_TEST)) - } + } STATE_COMPARE(gl_dither[0]) { if (newctx->gl_dither[0]) @@ -1363,7 +1371,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_DITHER)) - } + } } // _enable_flag2 @@ -1378,7 +1386,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_POLYGON_OFFSET_FILL)) - } + } STATE_COMPARE(gl_sample_alpha_to_coverage[0]) { if (newctx->gl_sample_alpha_to_coverage[0]) @@ -1387,7 +1395,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE)) - } + } STATE_COMPARE(gl_sample_coverage[0]) { if (newctx->gl_sample_coverage[0]) @@ -1396,7 +1404,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SAMPLE_COVERAGE)) - } + } STATE_COMPARE(gl_scissor_test[0]) { if (newctx->gl_scissor_test[0]) @@ -1405,7 +1413,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_SCISSOR_TEST)) - } + } STATE_COMPARE(gl_stencil_test[0]) { if (newctx->gl_stencil_test[0]) @@ -1414,7 +1422,7 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } else CHECK_GL_ERROR(_orig_fastpath_glDisable(GL_STENCIL_TEST)) - } + } } #ifdef COREGL_USE_MODULE_TRACEPATH @@ -1680,6 +1688,17 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) CHECK_GL_ERROR(_orig_fastpath_glPixelStorei(GL_UNPACK_ALIGNMENT, newctx->gl_unpack_alignment[0])) } } + + // _misc_flag3 + flag = oldctx->_misc_flag3 | newctx->_misc_flag3; + if (flag) + { + STATE_COMPARE(gl_read_buffer[0]) + { + CHECK_GL_ERROR(_orig_fastpath_glReadBuffer(newctx->gl_read_buffer[0])) + } + } + #ifdef COREGL_USE_MODULE_TRACEPATH tracepath_api_trace_end("eglMakeCurrent(FP etc.)", trace_hint_etc, 0); #endif // COREGL_USE_MODULE_TRACEPATH diff --git a/src/modules/fastpath/coregl_fastpath.h b/src/modules/fastpath/coregl_fastpath.h index 70757d3..c5ffc06 100644 --- a/src/modules/fastpath/coregl_fastpath.h +++ b/src/modules/fastpath/coregl_fastpath.h @@ -123,6 +123,7 @@ typedef enum GL_OBJECT_TYPE_FRAMEBUFFER = 0x3000000, GL_OBJECT_TYPE_RENDERBUFFER = 0x4000000, GL_OBJECT_TYPE_PROGRAM = 0x5000000, + GL_OBJECT_TYPE_QUERY = 0x6000000, } GL_Object_Type; typedef struct _GL_Object @@ -161,12 +162,14 @@ typedef struct _GL_Shared_Object_State GL_Object_Hash_Base framebuffer; GL_Object_Hash_Base renderbuffer; GL_Object_Hash_Base program; + GL_Object_Hash_Base query; GL_Object_Hash_Base texture_real; GL_Object_Hash_Base buffer_real; GL_Object_Hash_Base framebuffer_real; GL_Object_Hash_Base renderbuffer_real; GL_Object_Hash_Base program_real; + GL_Object_Hash_Base query_real; } GL_Shared_Object_State; typedef struct _GLGlueContext @@ -203,6 +206,7 @@ typedef struct _GLGlueContext unsigned char _stencil_flag2; unsigned char _misc_flag1; unsigned char _misc_flag2; + unsigned char _misc_flag3; unsigned char _vattrib_flag; GL_Shared_Object_State *sostate; diff --git a/src/modules/fastpath/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c index 17d0628..06069e0 100644 --- a/src/modules/fastpath/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -4025,22 +4025,6 @@ finish: -void -fastpath_glDrawArrays(GLenum mode, GLint first, GLsizei count) -{ - DEFINE_FASTPAH_GL_FUNC(); - _COREGL_FASTPATH_FUNC_BEGIN(); - INIT_FASTPATH_GL_FUNC(); - - _orig_fastpath_glDrawArrays(mode, first, count); - - goto finish; - -finish: - _COREGL_FASTPATH_FUNC_END(); -} - - /* ES 3.0 PASS (SUPPORT) */ void fastpath_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary) @@ -4065,6 +4049,7 @@ finish: _COREGL_FASTPATH_FUNC_END(); } + void fastpath_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length) { @@ -4088,16 +4073,22 @@ finish: _COREGL_FASTPATH_FUNC_END(); } -/* ES 3.0 BLOCK (UNTIL SUPPORT) */ -#define SIGILL_ERROR() \ - COREGL_ERR("\E[40;31;1mFASTPATH can't support ES3.0 API '%s' (will be terminated with Illegal instruction!)\E[0m\n", __func__); \ - kill(getpid(), SIGILL) void fastpath_glReadBuffer(GLenum mode) { - _COREGL_FASTPATH_FUNC_BEGIN(); SIGILL_ERROR(); // BLOCK API - _orig_fastpath_glReadBuffer(mode); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + CURR_STATE_COMPARE(gl_read_buffer, mode) + { + IF_GL_SUCCESS(_orig_fastpath_glReadBuffer(mode)) + { + current_ctx->_misc_flag3 |= FLAG_BIT_0; + current_ctx->gl_read_buffer[0] = mode; + } + } goto finish; @@ -4105,49 +4096,141 @@ finish: _COREGL_FASTPATH_FUNC_END(); } + void -fastpath_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) +fastpath_glGenQueries(GLsizei n, GLuint* ids) { - _COREGL_FASTPATH_FUNC_BEGIN(); SIGILL_ERROR(); // BLOCK API - _orig_fastpath_glDrawRangeElements(mode, start, end, count, type, indices); + int i; + GLuint *objid_array = NULL; - goto finish; + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); -finish: - _COREGL_FASTPATH_FUNC_END(); -} + if (n < 0) + { + _set_gl_error(GL_INVALID_VALUE); + goto finish; + } + if (n == 0) goto finish; + if (ids == NULL) goto finish; -void -fastpath_glGenQueries(GLsizei n, GLuint* ids) -{ - _COREGL_FASTPATH_FUNC_BEGIN(); SIGILL_ERROR(); // BLOCK API - _orig_fastpath_glGenQueries(n, ids); + AST(current_ctx->sostate != NULL); + + objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); + + IF_GL_SUCCESS(_orig_fastpath_glGenQueries(n, objid_array)) + { + for (i = 0; i < n; i++) + { + ids[i] = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_QUERY, objid_array[i]); + } + } goto finish; finish: + if (objid_array != NULL) + { + free(objid_array); + objid_array = NULL; + } _COREGL_FASTPATH_FUNC_END(); } + void fastpath_glDeleteQueries(GLsizei n, const GLuint* ids) { - _COREGL_FASTPATH_FUNC_BEGIN(); SIGILL_ERROR(); // BLOCK API - _orig_fastpath_glDeleteQueries(n, ids); + 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 (ids == NULL) goto finish; + + AST(current_ctx->sostate != 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; + + real_objid = fastpath_sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_QUERY, ids[i]); + if (real_objid == 0) continue; + + AST(fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_QUERY, ids[i]) == 1); + objid_array[real_n++] = real_objid; + } + + IF_GL_SUCCESS(_orig_fastpath_glDeleteQueries(real_n, objid_array)) + { + /* + for (i = 0; i < real_n; i++) + { + General_Trace_List *current = NULL; + current = current_ctx->sostate->using_gctxs; + + while (current != NULL) + { + GLGlueContext *cur_gctx = (GLGlueContext *)current->value; + + for (j = 0; j < cur_gctx->gl_num_tex_units[0]; j++) + { + if (cur_gctx->gl_tex_2d_state[j] == objid_array[i]) + cur_gctx->gl_tex_2d_state[j] = 0; + if (cur_gctx->gl_tex_cube_state[j] == objid_array[i]) + cur_gctx->gl_tex_cube_state[j] = 0; + } + + current = current->next; + } + } + */ + } + } goto finish; finish: + if (objid_array != NULL) + { + free(objid_array); + objid_array = NULL; + } _COREGL_FASTPATH_FUNC_END(); } + GLboolean fastpath_glIsQuery(GLuint id) { GLboolean ret = GL_FALSE; + GLuint real_obj; - _COREGL_FASTPATH_FUNC_BEGIN(); SIGILL_ERROR(); // BLOCK API - ret = _orig_fastpath_glIsQuery(id); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) + { + ret = GL_FALSE; + goto finish; + } + + ret = _orig_fastpath_glIsQuery(real_obj); goto finish; @@ -4156,11 +4239,30 @@ finish: return ret; } + + +/* ES 3.0 BLOCK (UNTIL SUPPORT) */ +#define SIGILL_ERROR() \ + COREGL_ERR("\E[40;31;1mFASTPATH can't support ES3.0 API '%s' (will be terminated with Illegal instruction!)\E[0m\n", __func__); \ + kill(getpid(), SIGILL) + + void fastpath_glBeginQuery(GLenum target, GLuint id) { - _COREGL_FASTPATH_FUNC_BEGIN(); SIGILL_ERROR(); // BLOCK API - _orig_fastpath_glBeginQuery(target, id); + GLuint real_obj; + + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); + + if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) + { + _set_gl_error(GL_OUT_OF_MEMORY); + goto finish; + } + + ret = _orig_fastpath_glBeginQuery(target, real_obj); goto finish; diff --git a/src/modules/fastpath/coregl_fastpath_state.h b/src/modules/fastpath/coregl_fastpath_state.h index 71040bf..af134b0 100644 --- a/src/modules/fastpath/coregl_fastpath_state.h +++ b/src/modules/fastpath/coregl_fastpath_state.h @@ -146,3 +146,6 @@ GLUE_STATE(GLfloat, gl_vertex_attrib_value, 4 * INITIAL_CTX->gl_num_vertex_attri SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 4, SET_4(0, 0, 0, 1)), SET_N(INITIAL_CTX->gl_num_vertex_attribs[0], 4, _sym_glGetVertexAttribfv(i, GL_CURRENT_VERTEX_ATTRIB, (GLfloat *)value);)) +// MISC FLAG 3 +GLUE_STATE(GLenum, gl_read_buffer, 1, 1, SET_1(GL_BACK), _sym_glGetIntegerv(GL_READ_BUFFER, (GLint *)value);) + -- 2.7.4