mirror of
https://github.com/libretro/RetroArch
synced 2025-02-26 06:40:39 +00:00
Add CGP preset load to RGUI.
This commit is contained in:
parent
f968ee6527
commit
241d55ccbf
@ -198,9 +198,10 @@ static bool menu_type_is_settings(unsigned type)
|
|||||||
|
|
||||||
static bool menu_type_is_shader_browser(unsigned type)
|
static bool menu_type_is_shader_browser(unsigned type)
|
||||||
{
|
{
|
||||||
return type >= RGUI_SETTINGS_SHADER_0 &&
|
return (type >= RGUI_SETTINGS_SHADER_0 &&
|
||||||
type <= RGUI_SETTINGS_SHADER_LAST &&
|
type <= RGUI_SETTINGS_SHADER_LAST &&
|
||||||
((type - RGUI_SETTINGS_SHADER_0) % 3) == 0;
|
((type - RGUI_SETTINGS_SHADER_0) % 3) == 0) ||
|
||||||
|
type == RGUI_SETTINGS_SHADER_PRESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgui_handle_t *rgui_init(const char *base_path,
|
rgui_handle_t *rgui_init(const char *base_path,
|
||||||
@ -445,7 +446,7 @@ static void render_text(rgui_handle_t *rgui)
|
|||||||
unsigned port = menu_type - RGUI_SETTINGS_CONTROLLER_1;
|
unsigned port = menu_type - RGUI_SETTINGS_CONTROLLER_1;
|
||||||
|
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
if (type >= RGUI_SETTINGS_SHADER_APPLY &&
|
if (type >= RGUI_SETTINGS_SHADER_PRESET &&
|
||||||
type <= RGUI_SETTINGS_SHADER_LAST)
|
type <= RGUI_SETTINGS_SHADER_LAST)
|
||||||
{
|
{
|
||||||
// HACK. Work around that we're using the menu_type as dir type to propagate state correctly.
|
// HACK. Work around that we're using the menu_type as dir type to propagate state correctly.
|
||||||
@ -455,6 +456,8 @@ static void render_text(rgui_handle_t *rgui)
|
|||||||
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
||||||
w = 5;
|
w = 5;
|
||||||
}
|
}
|
||||||
|
else if (type == RGUI_SETTINGS_SHADER_PRESET)
|
||||||
|
strlcpy(type_str, "...", sizeof(type_str));
|
||||||
else
|
else
|
||||||
shader_manager_get_str(&rgui->shader, type_str, sizeof(type_str), type);
|
shader_manager_get_str(&rgui->shader, type_str, sizeof(type_str), type);
|
||||||
}
|
}
|
||||||
@ -536,6 +539,7 @@ static void render_text(rgui_handle_t *rgui)
|
|||||||
case RGUI_SETTINGS_OPEN_FILEBROWSER:
|
case RGUI_SETTINGS_OPEN_FILEBROWSER:
|
||||||
case RGUI_SETTINGS_CORE_OPTIONS:
|
case RGUI_SETTINGS_CORE_OPTIONS:
|
||||||
case RGUI_SETTINGS_SHADER_MANAGER:
|
case RGUI_SETTINGS_SHADER_MANAGER:
|
||||||
|
case RGUI_SETTINGS_SHADER_PRESET:
|
||||||
case RGUI_SETTINGS_CUSTOM_VIEWPORT:
|
case RGUI_SETTINGS_CUSTOM_VIEWPORT:
|
||||||
case RGUI_SETTINGS_CORE:
|
case RGUI_SETTINGS_CORE:
|
||||||
case RGUI_SETTINGS_CONTROLLER_1:
|
case RGUI_SETTINGS_CONTROLLER_1:
|
||||||
@ -671,7 +675,7 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
|
|||||||
(void)rgui;
|
(void)rgui;
|
||||||
|
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
if (setting >= RGUI_SETTINGS_SHADER_APPLY && setting <= RGUI_SETTINGS_SHADER_LAST)
|
if (setting >= RGUI_SETTINGS_SHADER_PRESET && setting <= RGUI_SETTINGS_SHADER_LAST)
|
||||||
return shader_manager_toggle_setting(rgui, setting, action);
|
return shader_manager_toggle_setting(rgui, setting, action);
|
||||||
#endif
|
#endif
|
||||||
if (setting >= RGUI_SETTINGS_CORE_OPTION_START)
|
if (setting >= RGUI_SETTINGS_CORE_OPTION_START)
|
||||||
@ -1103,6 +1107,8 @@ static void rgui_settings_shader_manager_populate_entries(rgui_handle_t *rgui)
|
|||||||
rgui_list_clear(rgui->selection_buf);
|
rgui_list_clear(rgui->selection_buf);
|
||||||
rgui_list_push(rgui->selection_buf, "Apply changes",
|
rgui_list_push(rgui->selection_buf, "Apply changes",
|
||||||
RGUI_SETTINGS_SHADER_APPLY, 0);
|
RGUI_SETTINGS_SHADER_APPLY, 0);
|
||||||
|
rgui_list_push(rgui->selection_buf, "Load shader preset",
|
||||||
|
RGUI_SETTINGS_SHADER_PRESET, 0);
|
||||||
rgui_list_push(rgui->selection_buf, "Shader passes",
|
rgui_list_push(rgui->selection_buf, "Shader passes",
|
||||||
RGUI_SETTINGS_SHADER_PASSES, 0);
|
RGUI_SETTINGS_SHADER_PASSES, 0);
|
||||||
|
|
||||||
@ -1152,6 +1158,25 @@ static enum rarch_shader_type shader_manager_get_type(const struct gfx_shader *s
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shader_manager_set_preset(enum rarch_shader_type type, const char *path)
|
||||||
|
{
|
||||||
|
RARCH_LOG("Setting RGUI shader: %s.\n", path ? path : "N/A (stock)");
|
||||||
|
bool ret = video_set_shader_func(type, path);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
// Makes sure that we use RGUI CGP shader on driver reinit.
|
||||||
|
// Only do this when the cgp actually works to avoid potential errors.
|
||||||
|
strlcpy(g_settings.video.shader_path, path ? path : "",
|
||||||
|
sizeof(g_settings.video.shader_path));
|
||||||
|
g_settings.video.shader_enable = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RARCH_ERR("Setting RGUI CGP failed.\n");
|
||||||
|
g_settings.video.shader_enable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting, rgui_action_t action)
|
static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting, rgui_action_t action)
|
||||||
{
|
{
|
||||||
unsigned dist_shader = setting - RGUI_SETTINGS_SHADER_0;
|
unsigned dist_shader = setting - RGUI_SETTINGS_SHADER_0;
|
||||||
@ -1167,7 +1192,6 @@ static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting,
|
|||||||
|
|
||||||
enum rarch_shader_type type = shader_manager_get_type(&rgui->shader);
|
enum rarch_shader_type type = shader_manager_get_type(&rgui->shader);
|
||||||
|
|
||||||
bool ret = false;
|
|
||||||
if (rgui->shader.passes && type != RARCH_SHADER_NONE)
|
if (rgui->shader.passes && type != RARCH_SHADER_NONE)
|
||||||
{
|
{
|
||||||
const char *conf_path = type == RARCH_SHADER_GLSL ? "rgui.glslp" : "rgui.cgp";
|
const char *conf_path = type == RARCH_SHADER_GLSL ? "rgui.glslp" : "rgui.cgp";
|
||||||
@ -1183,28 +1207,10 @@ static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting,
|
|||||||
config_file_write(conf, cgp_path);
|
config_file_write(conf, cgp_path);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
||||||
RARCH_LOG("Setting RGUI shader: %s.\n", cgp_path);
|
shader_manager_set_preset(type, cgp_path);
|
||||||
ret = video_set_shader_func(type, cgp_path);
|
|
||||||
|
|
||||||
// Makes sure that we use RGUI CGP shader on driver reinit.
|
|
||||||
// Only do this when the cgp actually works to avoid potential errors.
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
strlcpy(g_settings.video.shader_path, cgp_path, sizeof(g_settings.video.shader_path));
|
|
||||||
g_settings.video.shader_enable = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
shader_manager_set_preset(RARCH_SHADER_CG, NULL);
|
||||||
ret = video_set_shader_func(RARCH_SHADER_CG, NULL);
|
|
||||||
g_settings.video.shader_enable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
RARCH_ERR("Setting RGUI CGP failed.\n");
|
|
||||||
g_settings.video.shader_enable = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (setting == RGUI_SETTINGS_SHADER_PASSES)
|
else if (setting == RGUI_SETTINGS_SHADER_PASSES)
|
||||||
{
|
{
|
||||||
@ -1231,10 +1237,11 @@ static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting,
|
|||||||
|
|
||||||
rgui->need_refresh = true;
|
rgui->need_refresh = true;
|
||||||
}
|
}
|
||||||
else if ((dist_shader % 3) == 0)
|
else if ((dist_shader % 3) == 0 || setting == RGUI_SETTINGS_SHADER_PRESET)
|
||||||
{
|
{
|
||||||
dist_shader /= 3;
|
dist_shader /= 3;
|
||||||
struct gfx_shader_pass *pass = &rgui->shader.pass[dist_shader];
|
struct gfx_shader_pass *pass = setting == RGUI_SETTINGS_SHADER_PRESET ?
|
||||||
|
&rgui->shader.pass[dist_shader] : NULL;
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case RGUI_ACTION_LEFT:
|
case RGUI_ACTION_LEFT:
|
||||||
@ -1246,6 +1253,7 @@ static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RGUI_ACTION_START:
|
case RGUI_ACTION_START:
|
||||||
|
if (pass)
|
||||||
*pass->source.cg = '\0';
|
*pass->source.cg = '\0';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1678,6 +1686,8 @@ static bool directory_parse(rgui_handle_t *rgui, const char *directory, unsigned
|
|||||||
if (core_chooser)
|
if (core_chooser)
|
||||||
exts = EXT_EXECUTABLES;
|
exts = EXT_EXECUTABLES;
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
|
else if (menu_type == RGUI_SETTINGS_SHADER_PRESET)
|
||||||
|
exts = "cgp|glslp";
|
||||||
else if (menu_type_is_shader_browser(menu_type))
|
else if (menu_type_is_shader_browser(menu_type))
|
||||||
exts = "cg|glsl";
|
exts = "cg|glsl";
|
||||||
#endif
|
#endif
|
||||||
@ -1809,10 +1819,20 @@ int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
if (menu_type_is_shader_browser(menu_type))
|
if (menu_type_is_shader_browser(menu_type))
|
||||||
|
{
|
||||||
|
if (menu_type == RGUI_SETTINGS_SHADER_PRESET)
|
||||||
|
{
|
||||||
|
char shader_path[PATH_MAX];
|
||||||
|
fill_pathname_join(shader_path, dir, path, sizeof(shader_path));
|
||||||
|
shader_manager_set_preset(gfx_shader_parse_type(shader_path, RARCH_SHADER_NONE),
|
||||||
|
shader_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
unsigned pass = (menu_type - RGUI_SETTINGS_SHADER_0) / 3;
|
unsigned pass = (menu_type - RGUI_SETTINGS_SHADER_0) / 3;
|
||||||
fill_pathname_join(rgui->shader.pass[pass].source.cg,
|
fill_pathname_join(rgui->shader.pass[pass].source.cg,
|
||||||
dir, path, sizeof(rgui->shader.pass[pass].source.cg));
|
dir, path, sizeof(rgui->shader.pass[pass].source.cg));
|
||||||
|
}
|
||||||
|
|
||||||
// Pop stack until we hit shader manager again.
|
// Pop stack until we hit shader manager again.
|
||||||
// We don't have to do this in CORE selection because it only
|
// We don't have to do this in CORE selection because it only
|
||||||
|
@ -38,6 +38,7 @@ typedef enum
|
|||||||
|
|
||||||
// Shader stuff
|
// Shader stuff
|
||||||
RGUI_SETTINGS_SHADER_MANAGER,
|
RGUI_SETTINGS_SHADER_MANAGER,
|
||||||
|
RGUI_SETTINGS_SHADER_PRESET,
|
||||||
RGUI_SETTINGS_SHADER_APPLY,
|
RGUI_SETTINGS_SHADER_APPLY,
|
||||||
RGUI_SETTINGS_SHADER_PASSES,
|
RGUI_SETTINGS_SHADER_PASSES,
|
||||||
RGUI_SETTINGS_SHADER_0,
|
RGUI_SETTINGS_SHADER_0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user