From f4adbd04ae4d4908640cb4eb3f851db695d491df Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 22:55:03 +0100 Subject: [PATCH] (gl.c) Reduce amount of time video_driver_get_size is called inside gl_frame --- gfx/drivers/gl.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 4ca72da58b..9fc9948e78 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -212,18 +212,18 @@ static void gl_overlay_tex_geom(void *data, tex[7] = y + h; } -static void gl_render_overlay(gl_t *gl) +static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_info_t shader_info; - unsigned i, width, height; + unsigned i; + unsigned width = video_info->width; + unsigned height = video_info->height; if (!gl || !gl->overlay_enable) return; - video_driver_get_size(&width, &height); - glEnable(GL_BLEND); if (gl->overlay_full_screen) @@ -309,14 +309,13 @@ void gl_set_viewport(void *data, video_frame_info_t *video_info, bool force_full, bool allow_rotate) { gfx_ctx_aspect_t aspect_data; - unsigned width, height; int x = 0; int y = 0; float device_aspect = (float)viewport_width / viewport_height; struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; gl_t *gl = (gl_t*)data; - - video_driver_get_size(&width, &height); + unsigned width = video_info->width; + unsigned height = video_info->height; aspect_data.aspect = &device_aspect; aspect_data.width = viewport_width; @@ -1013,13 +1012,14 @@ static void gl_pbo_async_readback(gl_t *gl) } #endif -static INLINE void gl_draw_texture(gl_t *gl) +static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_info_t shader_info; - unsigned width, height; GLfloat color[16]; + unsigned width = video_info->width; + unsigned height = video_info->height; color[ 0] = 1.0f; color[ 1] = 1.0f; @@ -1041,8 +1041,6 @@ static INLINE void gl_draw_texture(gl_t *gl) if (!gl->menu_texture) return; - video_driver_get_size(&width, &height); - gl->coords.vertex = vertexes_flipped; gl->coords.tex_coord = tex_coords; gl->coords.color = color; @@ -1095,11 +1093,13 @@ static bool gl_frame(void *data, const void *frame, video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; - unsigned width, height; struct video_tex_info feedback_info; video_shader_ctx_info_t shader_info; - static struct retro_perf_counter frame_run = {0}; + static struct + retro_perf_counter frame_run = {0}; gl_t *gl = (gl_t*)data; + unsigned width = video_info->width; + unsigned height = video_info->height; performance_counter_init(&frame_run, "frame_run"); performance_counter_start(&frame_run); @@ -1107,8 +1107,6 @@ static bool gl_frame(void *data, const void *frame, if (!gl) return false; - video_driver_get_size(&width, &height); - context_bind_hw_render(false); #ifndef HAVE_OPENGLES @@ -1282,7 +1280,7 @@ static bool gl_frame(void *data, const void *frame, menu_driver_frame(video_info); if (gl->menu_texture_enable) - gl_draw_texture(gl); + gl_draw_texture(gl, video_info); } #endif @@ -1290,7 +1288,7 @@ static bool gl_frame(void *data, const void *frame, font_driver_render_msg(NULL, msg, NULL); #ifdef HAVE_OVERLAY - gl_render_overlay(gl); + gl_render_overlay(gl, video_info); #endif video_context_driver_update_window_title(video_info);