Only reinit FBO if strictly necessary.

This commit is contained in:
Themaister 2012-11-18 15:22:32 +01:00
parent 77d2c04e26
commit 3065b6740b
1 changed files with 12 additions and 11 deletions

View File

@ -1258,8 +1258,7 @@ static bool resolve_extensions(gl_t *gl)
return true; return true;
} }
#ifdef RARCH_CONSOLE static inline void gl_reinit_textures(gl_t *gl, const video_info_t *video)
static void gl_reinit_textures(gl_t *gl, const video_info_t *video)
{ {
unsigned old_base_size = gl->base_size; unsigned old_base_size = gl->base_size;
unsigned old_width = gl->tex_w; unsigned old_width = gl->tex_w;
@ -1284,17 +1283,20 @@ static void gl_reinit_textures(gl_t *gl, const video_info_t *video)
gl_init_textures_data(gl); gl_init_textures_data(gl);
#ifdef HAVE_FBO #ifdef HAVE_FBO
gl_deinit_fbo(gl); if (gl->tex_w > old_width || gl->tex_h > old_height)
gl_init_fbo(gl, gl->tex_w, gl->tex_h); {
RARCH_LOG("Reiniting FBO.\n");
gl_deinit_fbo(gl);
gl_init_fbo(gl, gl->tex_w, gl->tex_h);
}
#endif #endif
} }
else else
RARCH_LOG("Reinitializing textures skipped.\n"); RARCH_LOG("Reinitializing textures skipped.\n");
if (!gl_check_error()) if (!gl_check_error())
RARCH_LOG("GL error reported while reinitializing textures. This should not happen ...\n"); RARCH_ERR("GL error reported while reinitializing textures. This should not happen ...\n");
} }
#endif
static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{ {
@ -1393,10 +1395,12 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
RARCH_LOG("GL: Loaded %u program(s).\n", gl_shader_num(gl)); RARCH_LOG("GL: Loaded %u program(s).\n", gl_shader_num(gl));
gl->tex_w = RARCH_SCALE_BASE * video->input_scale;
gl->tex_h = RARCH_SCALE_BASE * video->input_scale;
#ifdef HAVE_FBO #ifdef HAVE_FBO
// Set up render to texture. // Set up render to texture.
gl_init_fbo(gl, RARCH_SCALE_BASE * video->input_scale, gl_init_fbo(gl, gl->tex_w, gl->tex_h);
RARCH_SCALE_BASE * video->input_scale);
#endif #endif
gl->keep_aspect = video->force_aspect; gl->keep_aspect = video->force_aspect;
@ -1430,9 +1434,6 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
gl->coords.lut_tex_coord = tex_coords; gl->coords.lut_tex_coord = tex_coords;
gl_shader_set_coords(gl, &gl->coords, &gl->mvp); gl_shader_set_coords(gl, &gl->coords, &gl->mvp);
gl->tex_w = RARCH_SCALE_BASE * video->input_scale;
gl->tex_h = RARCH_SCALE_BASE * video->input_scale;
// Empty buffer that we use to clear out the texture with on res change. // Empty buffer that we use to clear out the texture with on res change.
gl->empty_buf = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h); gl->empty_buf = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h);