Add VAO callback functions

This commit is contained in:
twinaphex 2017-11-08 16:16:17 +01:00
parent 5b268b79d2
commit 308818afd1
3 changed files with 69 additions and 22 deletions

View File

@ -579,11 +579,9 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video)
(void)texture_type;
(void)texture_fmt;
#if defined(HAVE_EGL) && defined(HAVE_OPENGLES)
/* Use regular textures if we use HW render. */
gl->egl_images = !gl->hw_render_use && gl_check_capability(GL_CAPS_EGLIMAGE) &&
video_context_driver_init_image_buffer((void*)video);
#endif
#ifdef HAVE_PSGL
if (!gl->pbo)
@ -669,7 +667,8 @@ static INLINE void gl_copy_frame(gl_t *gl,
img_info.rgb32 = (gl->base_size == 4);
img_info.handle = &img;
new_egl = video_context_driver_write_to_image_buffer(&img_info);
new_egl =
video_context_driver_write_to_image_buffer(&img_info);
if (img == EGL_NO_IMAGE_KHR)
{
@ -1167,10 +1166,8 @@ static bool gl_frame(void *data, const void *frame,
context_bind_hw_render(false);
#ifndef HAVE_OPENGLES
if (gl->core_context_in_use)
glBindVertexArray(gl->vao);
#endif
if (gl->core_context_in_use && gl->renderchain_driver->bind_vao)
gl->renderchain_driver->bind_vao(gl);
video_info->cb_shader_use(gl, video_info->shader_data, 1, true);
@ -1412,10 +1409,9 @@ static bool gl_frame(void *data, const void *frame,
}
}
#ifndef HAVE_OPENGLES
if (gl->core_context_in_use)
glBindVertexArray(0);
#endif
if (gl->core_context_in_use &&
gl->renderchain_driver->unbind_vao)
gl->renderchain_driver->unbind_vao(gl);
context_bind_hw_render(true);
@ -1506,13 +1502,13 @@ static void gl_free(void *data)
gl->renderchain_driver->free(gl);
gl_deinit_chain(gl);
#ifndef HAVE_OPENGLES
if (gl->core_context_in_use)
{
glBindVertexArray(0);
glDeleteVertexArrays(1, &gl->vao);
if (gl->renderchain_driver->unbind_vao)
gl->renderchain_driver->unbind_vao(gl);
if (gl->renderchain_driver->free_vao)
gl->renderchain_driver->free_vao(gl);
}
#endif
video_context_driver_free();
@ -1550,6 +1546,12 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident)
{
gfx_ctx_flags_t flags;
if (!gl_check_capability(GL_CAPS_VAO))
{
RARCH_ERR("[GL]: Failed to initialize VAOs.\n");
return false;
}
gl_query_core_context_set(true);
gl->core_context_in_use = true;
@ -1561,13 +1563,9 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident)
video_context_driver_set_flags(&flags);
RARCH_LOG("[GL]: Using Core GL context.\n");
if (!gl_check_capability(GL_CAPS_VAO))
{
RARCH_ERR("[GL]: Failed to initialize VAOs.\n");
return false;
}
glGenVertexArrays(1, &gl->vao);
RARCH_LOG("[GL]: Using Core GL context, setting up VAO...\n");
if (gl->renderchain_driver->new_vao)
gl->renderchain_driver->new_vao(gl);
}
#endif
/* ES2 Compat - GL_RGB565 internal format support.

View File

@ -1158,7 +1158,52 @@ static void gl2_renderchain_disable_client_arrays(void)
}
#endif
#ifndef HAVE_OPENGLES
static void gl2_renderchain_bind_vao(void *data)
{
gl_t *gl = (gl_t*)data;
if (!gl)
return;
glBindVertexArray(gl->vao);
}
static void gl2_renderchain_unbind_vao(void *data)
{
gl_t *gl = (gl_t*)data;
if (!gl)
return;
glBindVertexArray(0);
}
static void gl2_renderchain_new_vao(void *data)
{
gl_t *gl = (gl_t*)data;
if (!gl)
return;
glGenVertexArrays(1, &gl->vao);
}
static void gl2_renderchain_free_vao(void *data)
{
gl_t *gl = (gl_t*)data;
if (!gl)
return;
glDeleteVertexArrays(1, &gl->vao);
}
#endif
gl_renderchain_driver_t gl2_renderchain = {
#ifdef HAVE_OPENGLES
NULL,
NULL,
NULL,
NULL,
#else
gl2_renderchain_new_vao,
gl2_renderchain_free_vao,
gl2_renderchain_bind_vao,
gl2_renderchain_unbind_vao,
#endif
#ifdef NO_GL_FF_VERTEX
NULL,
NULL,

View File

@ -827,6 +827,10 @@ typedef struct d3d_renderchain_driver
typedef struct gl_renderchain_driver
{
void (*new_vao)(void *data);
void (*free_vao)(void *data);
void (*bind_vao)(void *data);
void (*unbind_vao)(void *data);
void (*disable_client_arrays)(void);
void (*ff_vertex)(const void *data);
void (*ff_matrix)(const void *data);