From 395e2ed75617ed70f17ddad51094bcce6eda9e16 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 21 Sep 2014 05:23:51 +0200 Subject: [PATCH] Add "Force-disable sRGB FBO" option for buggy Intel OpenGL drivers on Windows - should hopefully fix messed up colors with it enabled (untested) --- general.h | 1 + gfx/gl.c | 6 ++++++ retroarch.cfg | 4 ++++ settings.c | 6 ++++++ settings_data.c | 1 + 5 files changed, 18 insertions(+) diff --git a/general.h b/general.h index 89bc64f6f8..23bf90d817 100644 --- a/general.h +++ b/general.h @@ -266,6 +266,7 @@ struct settings bool allow_rotate; bool shared_context; + bool force_srgb_disable; } video; #ifdef HAVE_MENU diff --git a/gfx/gl.c b/gfx/gl.c index fe85f30775..51f64f03d4 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -516,6 +516,9 @@ static void gl_create_fbo_textures(gl_t *gl) RARCH_ERR("[GL]: sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result may have banding!\n"); } + if (g_settings.video.force_srgb_disable) + srgb_fbo = false; + #ifndef HAVE_OPENGLES2 if (fp_fbo && gl->has_fp_fbo) { @@ -1874,6 +1877,9 @@ static bool resolve_extensions(gl_t *gl) #endif #endif + if (g_settings.video.force_srgb_disable) + gl->has_srgb_fbo = false; + #ifdef GL_DEBUG // Useful for debugging, but kinda obnoxious otherwise. RARCH_LOG("[GL]: Supported extensions:\n"); diff --git a/retroarch.cfg b/retroarch.cfg index a8019d5269..dc772521e3 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -124,6 +124,10 @@ # Video vsync. # video_vsync = true +# Forcibly disable sRGB FBO support. Some Intel OpenGL drivers on Windows +# have video problems with sRGB FBO support enabled. +# video_force_srgb_disable = false + # Attempts to hard-synchronize CPU and GPU. Can reduce latency at cost of performance. # video_hard_sync = false diff --git a/settings.c b/settings.c index e1f7f00b12..cfa1ecb5b3 100644 --- a/settings.c +++ b/settings.c @@ -306,6 +306,7 @@ void config_set_defaults(void) g_settings.video.threaded = g_defaults.settings.video_threaded_enable; g_settings.video.shared_context = video_shared_context; + g_settings.video.force_srgb_disable = false; #ifdef GEKKO g_settings.video.viwidth = video_viwidth; #endif @@ -430,6 +431,7 @@ void config_set_defaults(void) g_extern.console.screen.viewports.custom_vp.x = 0; g_extern.console.screen.viewports.custom_vp.y = 0; + /* Make sure settings from other configs carry over into defaults * for another config. */ if (!g_extern.has_set_save_path) @@ -930,6 +932,8 @@ bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_FLOAT(video.msg_pos_y, "video_message_pos_y"); CONFIG_GET_INT(video.rotation, "video_rotation"); + CONFIG_GET_BOOL(video.force_srgb_disable, "video_force_srgb_disable"); + #ifdef RARCH_CONSOLE /* TODO - will be refactored later to make it more clean - it's more * important that it works for consoles right now */ @@ -1451,6 +1455,8 @@ bool config_save_file(const char *path) config_set_bool(conf, "video_threaded", g_settings.video.threaded); config_set_bool(conf, "video_shared_context", g_settings.video.shared_context); + config_set_bool(conf, "video_force_srgb_disable", + g_settings.video.force_srgb_disable); config_set_bool(conf, "video_fullscreen", g_settings.video.fullscreen); config_set_float(conf, "video_refresh_rate", g_settings.video.refresh_rate); config_set_int(conf, "video_monitor_index", diff --git a/settings_data.c b/settings_data.c index 4660a472f8..7d2de48a2e 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2413,6 +2413,7 @@ rarch_setting_t *setting_data_get_list(void) CONFIG_UINT(g_settings.video.fullscreen_y, "video_fullscreen_y", "Fullscreen Height", fullscreen_y, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_FLOAT(g_settings.video.refresh_rate, "video_refresh_rate", "Refresh Rate", refresh_rate, "%.3f Hz", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 0, 0.001, true, false) CONFIG_FLOAT(g_settings.video.refresh_rate, "video_refresh_rate_auto", "Estimated Monitor FPS", refresh_rate, "%.3f Hz", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) + CONFIG_BOOL(g_settings.video.force_srgb_disable, "video_force_srgb_disable", "Force-disable sRGB FBO", false, "OFF", "ON", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_CMD(RARCH_CMD_REINIT) END_SUB_GROUP() START_SUB_GROUP("Aspect", GROUP_NAME)