From a0dabeb4ace6c674a7dcb9df0d421743a7723f6e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 1 Oct 2014 17:15:02 +0200 Subject: [PATCH] (GL) Optimization to gl_copy_frame --- gfx/gl.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index dba0127d94..1ad8cbc907 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1329,8 +1329,8 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, un if (width != pitch_width) { - /* conv_buffer - this buffer is - * preallocated in case we hit this path. */ + /* Slow path - conv_buffer is preallocated + * just in case we hit this path. */ unsigned h; const unsigned line_bytes = width * gl->base_size; @@ -1361,30 +1361,21 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, un glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); #else + const GLvoid *data_buf = frame; glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(pitch)); - if (gl->base_size == 2) - { - const void *buf = frame; - if (!gl->have_es2_compat) - { - // Convert to 32-bit textures on desktop GL. - gl_convert_frame_rgb16_32(gl, gl->conv_buffer, frame, width, height, pitch); - buf = gl->conv_buffer; - } - else - glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / gl->base_size); - glTexSubImage2D(GL_TEXTURE_2D, - 0, 0, 0, width, height, gl->texture_type, - gl->texture_fmt, buf); + if (gl->base_size == 2 && !gl->have_es2_compat) + { + /* Convert to 32-bit textures on desktop GL. */ + gl_convert_frame_rgb16_32(gl, gl->conv_buffer, frame, width, height, pitch); + data_buf = gl->conv_buffer; } else - { 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); - } + + glTexSubImage2D(GL_TEXTURE_2D, + 0, 0, 0, width, height, gl->texture_type, + gl->texture_fmt, data_buf); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); #endif