mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-11 05:16:12 +00:00
Can save parameters. Can tweak on RGUI presets and current shader.
This commit is contained in:
parent
b38c30b368
commit
ca3d4416d3
@ -43,6 +43,17 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
static inline struct gfx_shader *shader_manager_get_current_shader(rgui_handle_t *rgui, unsigned type)
|
||||
{
|
||||
struct gfx_shader *shader = type == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS ? &rgui->shader : NULL;
|
||||
if (!shader && driver.video_poke && driver.video_data && driver.video_poke->get_current_shader)
|
||||
shader = driver.video_poke->get_current_shader(driver.video_data);
|
||||
|
||||
return shader;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void menu_common_entries_init(void *data, unsigned menu_type)
|
||||
{
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
@ -52,15 +63,15 @@ static void menu_common_entries_init(void *data, unsigned menu_type)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
case RGUI_SETTINGS_SHADER_PARAMETERS:
|
||||
case RGUI_SETTINGS_SHADER_PRESET_PARAMETERS:
|
||||
{
|
||||
file_list_clear(rgui->selection_buf);
|
||||
struct gfx_shader *shader = NULL;
|
||||
if (driver.video_poke && driver.video_data && driver.video_poke->get_current_shader)
|
||||
shader = driver.video_poke->get_current_shader(driver.video_data);
|
||||
|
||||
struct gfx_shader *shader = shader_manager_get_current_shader(rgui, menu_type);
|
||||
if (shader)
|
||||
for (i = 0; i < shader->num_parameters; i++)
|
||||
file_list_push(rgui->selection_buf, shader->parameters[i].desc, RGUI_SETTINGS_SHADER_PARAMETER_0 + i, 0);
|
||||
rgui->parameter_shader = shader;
|
||||
break;
|
||||
}
|
||||
case RGUI_SETTINGS_SHADER_OPTIONS:
|
||||
@ -72,8 +83,10 @@ static void menu_common_entries_init(void *data, unsigned menu_type)
|
||||
RGUI_SETTINGS_SHADER_PRESET, 0);
|
||||
file_list_push(rgui->selection_buf, "Save As Shader Preset",
|
||||
RGUI_SETTINGS_SHADER_PRESET_SAVE, 0);
|
||||
file_list_push(rgui->selection_buf, "Shader Parameters",
|
||||
file_list_push(rgui->selection_buf, "Parameters (Current)",
|
||||
RGUI_SETTINGS_SHADER_PARAMETERS, 0);
|
||||
file_list_push(rgui->selection_buf, "Parameters (RGUI)",
|
||||
RGUI_SETTINGS_SHADER_PRESET_PARAMETERS, 0);
|
||||
file_list_push(rgui->selection_buf, "Shader Passes",
|
||||
RGUI_SETTINGS_SHADER_PASSES, 0);
|
||||
|
||||
@ -520,6 +533,7 @@ static unsigned menu_common_type_is(unsigned type)
|
||||
type == RGUI_SETTINGS_FONT_OPTIONS ||
|
||||
type == RGUI_SETTINGS_SHADER_OPTIONS ||
|
||||
type == RGUI_SETTINGS_SHADER_PARAMETERS ||
|
||||
type == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS ||
|
||||
type == RGUI_SETTINGS_AUDIO_OPTIONS ||
|
||||
type == RGUI_SETTINGS_DISK_OPTIONS ||
|
||||
type == RGUI_SETTINGS_PATH_OPTIONS ||
|
||||
@ -713,6 +727,7 @@ static int menu_settings_iterate(void *data, unsigned action)
|
||||
|| menu_type == RGUI_SETTINGS_FONT_OPTIONS
|
||||
|| menu_type == RGUI_SETTINGS_SHADER_OPTIONS
|
||||
|| menu_type == RGUI_SETTINGS_SHADER_PARAMETERS
|
||||
|| menu_type == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS
|
||||
)
|
||||
menu_common_entries_init(rgui, menu_type);
|
||||
else
|
||||
@ -1376,6 +1391,9 @@ static int menu_common_iterate(void *data, unsigned action)
|
||||
unsigned pass = (menu_type - RGUI_SETTINGS_SHADER_0) / 3;
|
||||
fill_pathname_join(rgui->shader.pass[pass].source.path,
|
||||
dir, path, sizeof(rgui->shader.pass[pass].source.path));
|
||||
|
||||
// This will reset any changed parameters.
|
||||
gfx_shader_resolve_parameters(NULL, &rgui->shader);
|
||||
}
|
||||
|
||||
// Pop stack until we hit shader manager again.
|
||||
@ -1681,7 +1699,10 @@ static void menu_common_shader_manager_init(void *data)
|
||||
if (conf)
|
||||
{
|
||||
if (gfx_shader_read_conf_cgp(conf, &rgui->shader))
|
||||
{
|
||||
gfx_shader_resolve_relative(&rgui->shader, g_settings.video.shader_path);
|
||||
gfx_shader_resolve_parameters(conf, &rgui->shader);
|
||||
}
|
||||
config_file_free(conf);
|
||||
}
|
||||
}
|
||||
@ -1708,7 +1729,10 @@ static void menu_common_shader_manager_init(void *data)
|
||||
if (conf)
|
||||
{
|
||||
if (gfx_shader_read_conf_cgp(conf, &rgui->shader))
|
||||
{
|
||||
gfx_shader_resolve_relative(&rgui->shader, cgp_path);
|
||||
gfx_shader_resolve_parameters(conf, &rgui->shader);
|
||||
}
|
||||
config_file_free(conf);
|
||||
}
|
||||
}
|
||||
@ -1741,6 +1765,7 @@ static void menu_common_shader_manager_set_preset(void *data, unsigned type, con
|
||||
{
|
||||
gfx_shader_read_conf_cgp(conf, shader);
|
||||
gfx_shader_resolve_relative(shader, path);
|
||||
gfx_shader_resolve_parameters(conf, shader);
|
||||
config_file_free(conf);
|
||||
}
|
||||
|
||||
@ -1768,10 +1793,7 @@ static void menu_common_shader_manager_get_str(void *data, char *type_str, size_
|
||||
*type_str = '\0';
|
||||
else if (type >= RGUI_SETTINGS_SHADER_PARAMETER_0 && type <= RGUI_SETTINGS_SHADER_PARAMETER_LAST)
|
||||
{
|
||||
struct gfx_shader *shader = NULL;
|
||||
if (driver.video_poke && driver.video_data && driver.video_poke->get_current_shader)
|
||||
shader = driver.video_poke->get_current_shader(driver.video_data);
|
||||
|
||||
// rgui->parameter_shader here.
|
||||
if (shader)
|
||||
{
|
||||
const struct gfx_shader_parameter *param = &shader->parameters[type - RGUI_SETTINGS_SHADER_PARAMETER_0];
|
||||
@ -1983,7 +2005,7 @@ static int menu_common_shader_manager_setting_toggle(void *data, unsigned settin
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (setting == RGUI_SETTINGS_SHADER_PARAMETERS && action == RGUI_ACTION_OK)
|
||||
else if ((setting == RGUI_SETTINGS_SHADER_PARAMETERS || setting == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS) && action == RGUI_ACTION_OK)
|
||||
{
|
||||
file_list_push(rgui->menu_stack, "", setting, rgui->selection_ptr);
|
||||
menu_clear_navigation(rgui);
|
||||
@ -1991,14 +2013,10 @@ static int menu_common_shader_manager_setting_toggle(void *data, unsigned settin
|
||||
}
|
||||
else if (setting >= RGUI_SETTINGS_SHADER_PARAMETER_0 && setting <= RGUI_SETTINGS_SHADER_PARAMETER_LAST)
|
||||
{
|
||||
struct gfx_shader *shader = NULL;
|
||||
if (driver.video_poke && driver.video_data && driver.video_poke->get_current_shader)
|
||||
shader = driver.video_poke->get_current_shader(driver.video_data);
|
||||
|
||||
if (!shader)
|
||||
if (!rgui->parameter_shader)
|
||||
return 0;
|
||||
|
||||
struct gfx_shader_parameter *param = &shader->parameters[setting - RGUI_SETTINGS_SHADER_PARAMETER_0];
|
||||
struct gfx_shader_parameter *param = &rgui->parameter_shader->parameters[setting - RGUI_SETTINGS_SHADER_PARAMETER_0];
|
||||
switch (action)
|
||||
{
|
||||
case RGUI_ACTION_START:
|
||||
@ -3659,6 +3677,7 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action
|
||||
{
|
||||
case RGUI_ACTION_START:
|
||||
rgui->shader.passes = 0;
|
||||
rgui->need_refresh = true;
|
||||
break;
|
||||
|
||||
case RGUI_ACTION_LEFT:
|
||||
@ -3682,9 +3701,8 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef HAVE_RMENU
|
||||
rgui->need_refresh = true;
|
||||
#endif
|
||||
if (rgui->need_refresh)
|
||||
gfx_shader_resolve_parameters(NULL, &rgui->shader);
|
||||
break;
|
||||
case RGUI_SETTINGS_SHADER_APPLY:
|
||||
{
|
||||
|
@ -62,7 +62,8 @@ typedef enum
|
||||
RGUI_SETTINGS_SHADER_FILTER,
|
||||
RGUI_SETTINGS_SHADER_PRESET,
|
||||
RGUI_SETTINGS_SHADER_APPLY,
|
||||
RGUI_SETTINGS_SHADER_PARAMETERS,
|
||||
RGUI_SETTINGS_SHADER_PARAMETERS, // Modifies current shader directly. Will not get saved to CGP.
|
||||
RGUI_SETTINGS_SHADER_PRESET_PARAMETERS, // Modifies shader preset currently in RGUI.
|
||||
RGUI_SETTINGS_SHADER_PASSES,
|
||||
RGUI_SETTINGS_SHADER_PARAMETER_0,
|
||||
RGUI_SETTINGS_SHADER_PARAMETER_LAST = RGUI_SETTINGS_SHADER_PARAMETER_0 + (GFX_MAX_PARAMETERS - 1),
|
||||
|
@ -317,7 +317,9 @@ static void rgui_render(void *data)
|
||||
else if (menu_type == RGUI_SETTINGS_SHADER_OPTIONS)
|
||||
strlcpy(title, "SHADER OPTIONS", sizeof(title));
|
||||
else if (menu_type == RGUI_SETTINGS_SHADER_PARAMETERS)
|
||||
strlcpy(title, "SHADER PARAMETERS", sizeof(title));
|
||||
strlcpy(title, "SHADER PARAMETERS (CURRENT)", sizeof(title));
|
||||
else if (menu_type == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS)
|
||||
strlcpy(title, "SHADER PARAMETERS (RGUI PRESET)", sizeof(title));
|
||||
#endif
|
||||
else if (menu_type == RGUI_SETTINGS_FONT_OPTIONS)
|
||||
strlcpy(title, "FONT OPTIONS", sizeof(title));
|
||||
@ -453,13 +455,18 @@ static void rgui_render(void *data)
|
||||
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
||||
w = 5;
|
||||
}
|
||||
else if (type == RGUI_SETTINGS_SHADER_OPTIONS || type == RGUI_SETTINGS_SHADER_PRESET || type == RGUI_SETTINGS_SHADER_PARAMETERS)
|
||||
else if (type == RGUI_SETTINGS_SHADER_OPTIONS || type == RGUI_SETTINGS_SHADER_PRESET || type == RGUI_SETTINGS_SHADER_PARAMETERS || type == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS)
|
||||
strlcpy(type_str, "...", sizeof(type_str));
|
||||
else if (type == RGUI_SETTINGS_SHADER_FILTER)
|
||||
snprintf(type_str, sizeof(type_str), "%s",
|
||||
g_settings.video.smooth ? "Linear" : "Nearest");
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->shader_manager_get_str)
|
||||
driver.menu_ctx->backend->shader_manager_get_str(&rgui->shader, type_str, sizeof(type_str), type);
|
||||
{
|
||||
if (type >= RGUI_SETTINGS_SHADER_PARAMETER_0 && type <= RGUI_SETTINGS_SHADER_PARAMETER_LAST)
|
||||
driver.menu_ctx->backend->shader_manager_get_str(rgui->parameter_shader, type_str, sizeof(type_str), type);
|
||||
else
|
||||
driver.menu_ctx->backend->shader_manager_get_str(&rgui->shader, type_str, sizeof(type_str), type);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -164,6 +164,7 @@ typedef struct
|
||||
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
struct gfx_shader shader;
|
||||
struct gfx_shader *parameter_shader; // Points to either shader or graphics driver current shader.
|
||||
#endif
|
||||
unsigned current_pad;
|
||||
|
||||
|
@ -286,9 +286,6 @@ static struct gfx_shader_parameter *find_parameter(struct gfx_shader_parameter *
|
||||
|
||||
bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shader)
|
||||
{
|
||||
char parameters[1024];
|
||||
char *save = NULL;
|
||||
const char *id;
|
||||
unsigned i;
|
||||
|
||||
shader->num_parameters = 0;
|
||||
@ -330,6 +327,10 @@ bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shade
|
||||
// Read in parameters which override the defaults.
|
||||
if (conf)
|
||||
{
|
||||
char parameters[1024];
|
||||
char *save = NULL;
|
||||
const char *id;
|
||||
|
||||
if (!config_get_array(conf, "parameters", parameters, sizeof(parameters)))
|
||||
return true;
|
||||
|
||||
@ -626,6 +627,26 @@ void gfx_shader_write_conf_cgp(config_file_t *conf, const struct gfx_shader *sha
|
||||
shader_write_fbo(conf, &pass->fbo, i);
|
||||
}
|
||||
|
||||
if (shader->num_parameters)
|
||||
{
|
||||
char parameters[4096] = {0};
|
||||
strlcpy(parameters, shader->parameters[0].id, sizeof(parameters));
|
||||
for (i = 1; i < shader->num_parameters; i++)
|
||||
{
|
||||
// O(n^2), but number of parameters is very limited.
|
||||
strlcat(parameters, ";", sizeof(parameters));
|
||||
strlcat(parameters, shader->parameters[i].id, sizeof(parameters));
|
||||
}
|
||||
|
||||
config_set_string(conf, "parameters", parameters);
|
||||
|
||||
for (i = 0; i < shader->num_parameters; i++)
|
||||
{
|
||||
char key[64];
|
||||
config_set_float(conf, shader->parameters[i].id, shader->parameters[i].current);
|
||||
}
|
||||
}
|
||||
|
||||
if (shader->luts)
|
||||
{
|
||||
char textures[4096] = {0};
|
||||
|
Loading…
x
Reference in New Issue
Block a user