Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ltw/src/main/tinywrapper/egl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ltw/src/main/tinywrapper/es3_overrides.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ GLESOVERRIDE(glGetTexImage)
GLESOVERRIDE(glGetQueryObjectiv)
GLESOVERRIDE(glGetQueryObjecti64v)
GLESOVERRIDE(glGetQueryObjectui64v)
GLESOVERRIDE(glQueryCounter)
GLESOVERRIDE(glDepthRange)
GLESOVERRIDE(glVertexAttrib1d)
GLESOVERRIDE(glVertexAttrib1dv)
Expand Down
30 changes: 11 additions & 19 deletions ltw/src/main/tinywrapper/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion ltw/src/main/tinywrapper/stubs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <stdio.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

Expand Down