mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
detect shader file changes on move and delete as well, and wait a few frames before re-applying changes
This commit is contained in:
parent
f087b150c9
commit
9e347ec71f
@ -2357,6 +2357,10 @@ static void frontend_unix_watch_path_for_changes(struct string_list *list, int f
|
||||
inotify_mask |= IN_MODIFY;
|
||||
if (flags & PATH_CHANGE_TYPE_WRITE_FILE_CLOSED)
|
||||
inotify_mask |= IN_CLOSE_WRITE;
|
||||
if (flags & PATH_CHANGE_TYPE_FILE_MOVED)
|
||||
inotify_mask |= IN_MOVE_SELF;
|
||||
if (flags & PATH_CHANGE_TYPE_FILE_DELETED)
|
||||
inotify_mask |= IN_DELETE_SELF;
|
||||
|
||||
inotify_data->flags = inotify_mask;
|
||||
|
||||
|
@ -56,10 +56,13 @@ enum frontend_architecture
|
||||
FRONTEND_ARCH_TILE
|
||||
};
|
||||
|
||||
/* different platforms may only support some of these types */
|
||||
enum path_change_type
|
||||
{
|
||||
PATH_CHANGE_TYPE_MODIFIED = (1 << 0),
|
||||
PATH_CHANGE_TYPE_WRITE_FILE_CLOSED = (1 << 1)
|
||||
PATH_CHANGE_TYPE_WRITE_FILE_CLOSED = (1 << 1),
|
||||
PATH_CHANGE_TYPE_FILE_MOVED = (1 << 2),
|
||||
PATH_CHANGE_TYPE_FILE_DELETED = (1 << 3)
|
||||
};
|
||||
|
||||
typedef struct path_change_data
|
||||
|
@ -809,7 +809,12 @@ bool video_shader_read_conf_cgp(config_file_t *conf,
|
||||
|
||||
if (settings->bools.video_shader_watch_files)
|
||||
{
|
||||
frontend_driver_watch_path_for_changes(file_list, PATH_CHANGE_TYPE_WRITE_FILE_CLOSED, &file_change_data);
|
||||
int flags = PATH_CHANGE_TYPE_MODIFIED |
|
||||
PATH_CHANGE_TYPE_WRITE_FILE_CLOSED |
|
||||
PATH_CHANGE_TYPE_FILE_MOVED |
|
||||
PATH_CHANGE_TYPE_FILE_DELETED;
|
||||
|
||||
frontend_driver_watch_path_for_changes(file_list, flags, &file_change_data);
|
||||
string_list_free(file_list);
|
||||
}
|
||||
|
||||
|
27
retroarch.c
27
retroarch.c
@ -130,6 +130,8 @@
|
||||
#define DEFAULT_EXT ""
|
||||
#endif
|
||||
|
||||
#define SHADER_FILE_WATCH_DELAY_FRAMES 5
|
||||
|
||||
/* Descriptive names for options without short variant.
|
||||
*
|
||||
* Please keep the name in sync with the option name.
|
||||
@ -2996,8 +2998,31 @@ static enum runloop_state runloop_check_state(
|
||||
|
||||
if (settings->bools.video_shader_watch_files)
|
||||
{
|
||||
static bool need_to_apply = false;
|
||||
static int elapsed_frames = 0;
|
||||
|
||||
if (video_shader_check_for_changes())
|
||||
command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL);
|
||||
{
|
||||
need_to_apply = true;
|
||||
elapsed_frames = 0;
|
||||
}
|
||||
|
||||
/* If a file is modified atomically (moved/renamed from a different file), we have no idea how long that might take.
|
||||
* If we're trying to re-apply shaders immediately after changes are made to the original file(s), the filesystem might be in an in-between
|
||||
* state where the new file hasn't been moved over yet and the original file was already deleted. This leaves us no choice
|
||||
* but to wait an arbitrary amount of time and hope for the best.
|
||||
*/
|
||||
if (need_to_apply)
|
||||
{
|
||||
if (elapsed_frames > SHADER_FILE_WATCH_DELAY_FRAMES)
|
||||
{
|
||||
need_to_apply = false;
|
||||
elapsed_frames = 0;
|
||||
command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL);
|
||||
}
|
||||
else
|
||||
elapsed_frames++;
|
||||
}
|
||||
}
|
||||
|
||||
return RUNLOOP_STATE_ITERATE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user