diff --git a/ltw/src/main/tinywrapper/egl.c b/ltw/src/main/tinywrapper/egl.c index 2d6ce2e..adb8c5c 100644 --- a/ltw/src/main/tinywrapper/egl.c +++ b/ltw/src/main/tinywrapper/egl.c @@ -153,12 +153,13 @@ static void find_esversion(context_t* context) { if(strstr(extensions, "GL_EXT_buffer_storage")) context->buffer_storage = true; if(strstr(extensions, "GL_EXT_texture_buffer")) context->buffer_texture_ext = true; if(strstr(extensions, "GL_EXT_multi_draw_indirect")) context->multidraw_indirect = true; - // EXT_disjoint_timer_query provides accurate int64 timer queries // on Core Profile it's ARB_timer_query instead // This enables real time queries via mentioned extension, otherwise faked ones are used (see query.c) - if(strstr(extensions, "GL_EXT_disjoint_timer_query") || env_istrue_d("LTW_ENABLE_TIMER_QUERY", false)) context->timer_query = true; - + if(strstr(extensions, "GL_EXT_disjoint_timer_query") && !env_istrue_d("LTW_FAKE_TIMER_QUERIES", false)) { + printf("LTW: Will use EXT_disjoint_timer_query for accurate timer queries\n"); + context->timer_query = true; + } bool basevertex_oes = strstr(extensions, "GL_OES_draw_elements_base_vertex"); bool basevertex_ext = strstr(extensions, "GL_EXT_draw_elements_base_vertex"); if(context->es32) context->drawelementsbasevertex = es3_functions.glDrawElementsBaseVertex; diff --git a/ltw/src/main/tinywrapper/es3_overrides.h b/ltw/src/main/tinywrapper/es3_overrides.h index 600ee85..1a614d3 100644 --- a/ltw/src/main/tinywrapper/es3_overrides.h +++ b/ltw/src/main/tinywrapper/es3_overrides.h @@ -81,6 +81,7 @@ GLESOVERRIDE(glGetTexImage) GLESOVERRIDE(glGetQueryObjectiv) GLESOVERRIDE(glGetQueryObjecti64v) GLESOVERRIDE(glGetQueryObjectui64v) +GLESOVERRIDE(glQueryCounter) GLESOVERRIDE(glDepthRange) GLESOVERRIDE(glVertexAttrib1d) GLESOVERRIDE(glVertexAttrib1dv) diff --git a/ltw/src/main/tinywrapper/query.c b/ltw/src/main/tinywrapper/query.c index 264ff6e..755c847 100644 --- a/ltw/src/main/tinywrapper/query.c +++ b/ltw/src/main/tinywrapper/query.c @@ -7,38 +7,30 @@ #include "egl.h" #include "proc.h" -#define CTX_CHECK() if (!current_context) return; +// Timer queries wrapper // Minecraft uses these only for timer queries void glGetQueryObjecti64v(GLuint id, GLenum pname, int64_t* params){ - CTX_CHECK(); + if(!current_context) return; // May be not needed, added just in case - if(!current_context->timer_query){ - *params = 1; - return; - } - es3_functions.glGetQueryObjecti64vEXT(id, pname, params); + if(!current_context->timer_query) *params = pname == GL_QUERY_RESULT_AVAILABLE ? GL_TRUE : 100; + else es3_functions.glGetQueryObjecti64vEXT(id, pname, params); } void glGetQueryObjectui64v(GLuint id, GLenum pname, uint64_t* params){ - CTX_CHECK(); - if(!current_context->timer_query){ - *params = 1; - return; - } - es3_functions.glGetQueryObjectui64vEXT(id, pname, params); + if(!current_context) return; + if(!current_context->timer_query) *params = pname == GL_QUERY_RESULT_AVAILABLE ? GL_TRUE : 100; + else es3_functions.glGetQueryObjectui64vEXT(id, pname, params); } + void glQueryCounter(GLuint id, GLenum target){ - if(!current_context || !current_context->timer_query) - return; + if(!current_context || !current_context->timer_query) return; es3_functions.glQueryCounterEXT(id, target); } // Moved from main.c -void glGetQueryObjectiv( GLuint id, - GLenum name, - GLint * params) { - CTX_CHECK(); +void glGetQueryObjectiv(GLuint id, GLenum name, GLint * params){ + if (!current_context) return; // This is not recommended but i don't care es3_functions.glGetQueryObjectuiv(id, name, (GLuint*)params); } \ No newline at end of file diff --git a/ltw/src/main/tinywrapper/stubs.c b/ltw/src/main/tinywrapper/stubs.c index 1d13fe3..0f8783b 100644 --- a/ltw/src/main/tinywrapper/stubs.c +++ b/ltw/src/main/tinywrapper/stubs.c @@ -1,4 +1,4 @@ -#include +#include #include #include