mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 04:20:28 +00:00
restore the original shader on close
This commit is contained in:
parent
fcd5507158
commit
d58c802e3b
11
command.c
11
command.c
@ -1170,6 +1170,7 @@ static void command_event_deinit_core(bool reinit)
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
|
||||
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
|
||||
}
|
||||
|
||||
static void command_event_init_cheats(void)
|
||||
@ -1386,6 +1387,12 @@ static void command_event_disable_overrides(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void command_event_restore_default_shader_preset(void)
|
||||
{
|
||||
/* auto shader preset: reload the original shader */
|
||||
config_unload_shader_preset();
|
||||
}
|
||||
|
||||
static bool command_event_save_auto_state(void)
|
||||
{
|
||||
bool ret;
|
||||
@ -1910,6 +1917,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||
case CMD_EVENT_QUIT:
|
||||
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
|
||||
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
|
||||
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
@ -2523,6 +2531,9 @@ bool command_event(enum event_command cmd, void *data)
|
||||
case CMD_EVENT_DISABLE_OVERRIDES:
|
||||
command_event_disable_overrides();
|
||||
break;
|
||||
case CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET:
|
||||
command_event_restore_default_shader_preset();
|
||||
break;
|
||||
case CMD_EVENT_NONE:
|
||||
default:
|
||||
return false;
|
||||
|
@ -212,7 +212,8 @@ enum event_command
|
||||
CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG,
|
||||
CMD_EVENT_VOLUME_UP,
|
||||
CMD_EVENT_VOLUME_DOWN,
|
||||
CMD_EVENT_DISABLE_OVERRIDES
|
||||
CMD_EVENT_DISABLE_OVERRIDES,
|
||||
CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET
|
||||
};
|
||||
|
||||
#ifdef HAVE_COMMAND
|
||||
|
@ -2295,6 +2295,7 @@ bool config_load_shader_preset(void)
|
||||
if (new_conf)
|
||||
{
|
||||
RARCH_LOG("Shaders: game-specific shader preset found at %s.\n", game_path);
|
||||
runloop_ctl(RUNLOOP_CTL_SET_DEFAULT_SHADER_PRESET, settings->path.shader);
|
||||
strlcpy(settings->path.shader, game_path, sizeof(settings->path.shader));
|
||||
return true;
|
||||
}
|
||||
@ -2310,6 +2311,7 @@ bool config_load_shader_preset(void)
|
||||
if (new_conf)
|
||||
{
|
||||
RARCH_LOG("Shaders: core-specific shader preset found at %s.\n", core_path);
|
||||
runloop_ctl(RUNLOOP_CTL_SET_DEFAULT_SHADER_PRESET, settings->path.shader);
|
||||
strlcpy(settings->path.shader, core_path, sizeof(settings->path.shader));
|
||||
return true;
|
||||
}
|
||||
@ -2322,6 +2324,28 @@ bool config_load_shader_preset(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_unload_shader_preset:
|
||||
*
|
||||
* Restores the original preset that was loaded before a core/game.
|
||||
* preset was loaded
|
||||
*
|
||||
* Returns: false if there was an error.
|
||||
*/
|
||||
bool config_unload_shader_preset(void)
|
||||
{
|
||||
char *preset = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (runloop_ctl(RUNLOOP_CTL_GET_DEFAULT_SHADER_PRESET, &preset) &&
|
||||
preset)
|
||||
{
|
||||
RARCH_WARN("Shaders: restoring default shader preset to %s\n",
|
||||
preset);
|
||||
strlcpy(settings->path.shader, preset, sizeof(settings->path.shader));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void parse_config_file(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
@ -628,6 +628,16 @@ bool config_load_remap(void);
|
||||
*/
|
||||
bool config_load_shader_preset(void);
|
||||
|
||||
/**
|
||||
* config_unload_shader_preset:
|
||||
*
|
||||
* Restores the original preset that was loaded before a core/game.
|
||||
* preset was loaded
|
||||
*
|
||||
* Returns: false if there was an error.
|
||||
*/
|
||||
bool config_unload_shader_preset(void);
|
||||
|
||||
/**
|
||||
* config_save_autoconf_profile:
|
||||
* @path : Path that shall be written to.
|
||||
|
21
runloop.c
21
runloop.c
@ -100,6 +100,7 @@ typedef struct event_cmd_state
|
||||
|
||||
static rarch_dir_list_t runloop_shader_dir;
|
||||
static char runloop_fullpath[PATH_MAX_LENGTH];
|
||||
static char runloop_default_shader_preset[PATH_MAX_LENGTH];
|
||||
static rarch_system_info_t runloop_system;
|
||||
static unsigned runloop_pending_windowed_scale;
|
||||
static struct retro_frame_time_callback runloop_frame_time;
|
||||
@ -931,6 +932,26 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
strlcpy(runloop_fullpath, fullpath, sizeof(runloop_fullpath));
|
||||
}
|
||||
break;
|
||||
case RUNLOOP_CTL_CLEAR_DEFAULT_SHADER_PRESET:
|
||||
*runloop_default_shader_preset = '\0';
|
||||
break;
|
||||
case RUNLOOP_CTL_GET_DEFAULT_SHADER_PRESET:
|
||||
{
|
||||
char **preset = (char**)data;
|
||||
if (!preset)
|
||||
return false;
|
||||
*preset = (char*)runloop_default_shader_preset;
|
||||
}
|
||||
break;
|
||||
case RUNLOOP_CTL_SET_DEFAULT_SHADER_PRESET:
|
||||
{
|
||||
const char *preset = (const char*)data;
|
||||
if (!preset)
|
||||
return false;
|
||||
strlcpy(runloop_default_shader_preset, preset,
|
||||
sizeof(runloop_default_shader_preset));
|
||||
}
|
||||
break;
|
||||
case RUNLOOP_CTL_FRAME_TIME_FREE:
|
||||
memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback));
|
||||
runloop_frame_time_last = 0;
|
||||
|
@ -61,6 +61,10 @@ enum runloop_ctl_state
|
||||
RUNLOOP_CTL_SET_CONTENT_PATH,
|
||||
RUNLOOP_CTL_CLEAR_CONTENT_PATH,
|
||||
|
||||
RUNLOOP_CTL_GET_DEFAULT_SHADER_PRESET,
|
||||
RUNLOOP_CTL_SET_DEFAULT_SHADER_PRESET,
|
||||
RUNLOOP_CTL_CLEAR_DEFAULT_SHADER_PRESET,
|
||||
|
||||
RUNLOOP_CTL_SET_LIBRETRO_PATH,
|
||||
|
||||
RUNLOOP_CTL_IS_SLOWMOTION,
|
||||
|
Loading…
x
Reference in New Issue
Block a user