From aaa8fc1f37ce2bd32edfcacd1d236d0d01905920 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 29 Oct 2013 23:21:15 +0100 Subject: [PATCH] (GLES2 GL) Query GL_EXT_unpack_subimage and if it's there, use it - Tegra 4 should support it etc. --- gfx/gl.c | 18 ++++++++++++++++++ gfx/gl_common.h | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index 7c1e4d173d..ed10fb6b90 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1234,6 +1234,15 @@ static inline void gl_copy_frame(void *data, const void *frame, unsigned width, 0, 0, 0, width, height, gl->texture_type, gl->texture_fmt, gl->conv_buffer); } + else if (gl->support_unpack_row_length) + { + glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / gl->base_size); + glTexSubImage2D(GL_TEXTURE_2D, + 0, 0, 0, width, height, gl->texture_type, + gl->texture_fmt, frame); + + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + } else { // No GL_UNPACK_ROW_LENGTH ;( @@ -2152,6 +2161,15 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gl_init_pbo_readback(gl); #endif +#if defined(HAVE_OPENGLES) + gl->support_unpack_row_length = false; + if (gl_query_extension(gl, "GL_EXT_unpack_subimage")) + { + RARCH_LOG("[GL]: Extension GL_EXT_unpack_subimage, can copy textures faster using UNPACK_ROW_LENGTH.\n"); + gl->support_unpack_row_length = true; + } +#endif + if (!gl_check_error()) { context_destroy_func(); diff --git a/gfx/gl_common.h b/gfx/gl_common.h index d864a3c464..e722d4bee6 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -209,6 +209,9 @@ typedef struct gl GLenum texture_fmt; GLenum wrap_mode; unsigned base_size; // 2 or 4 +#ifdef HAVE_OPENGLES + bool support_unpack_row_length; +#endif // Fonts void *font; @@ -309,8 +312,12 @@ typedef struct gl #define NO_GL_CLAMP_TO_BORDER #endif -#if defined(HAVE_OPENGLES2) // It's an extension. Don't bother checking for it atm. -#undef GL_UNPACK_ROW_LENGTH +#if defined(HAVE_OPENGLES) + +#ifndef GL_UNPACK_ROW_LENGTH +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#endif + #endif void gl_set_projection(void *data, struct gl_ortho *ortho, bool allow_rotate);