(GLES2 GL) Query GL_EXT_unpack_subimage and if it's there, use it -

Tegra 4 should support it etc.
This commit is contained in:
twinaphex 2013-10-29 23:21:15 +01:00
parent 9be4fe705b
commit aaa8fc1f37
2 changed files with 27 additions and 2 deletions

View File

@ -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();

View File

@ -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);