Merge pull request #6249 from fr500/master

Shader preset changes
This commit is contained in:
Twinaphex 2018-02-08 05:32:04 +01:00 committed by GitHub
commit 5f14aab6fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 188 additions and 147 deletions

View File

@ -36,6 +36,8 @@
- LOCALIZATION: Update Spanish translation.
- NETPLAY: Add menu option to select different MITM (relay) server locations.
- OSX: Modify HID buttons detection algorithm.
- SHADERS: Allow saving of shader presets based on the parent directory (Saving one for */foo/bar/mario.sfc* would result in *shaders/presets/corename/bar.ext*). We decided it's safer to still isolate the presets to a single core because different cores may treat video output differently.
- SHADERS: Don't save the path to the current preset to the main config. This was causing weird behavior, instead it will try to load *currentconfig.ext* and it will save a preset with that name when select *apply shader preset*. The resulting shader will restore properly after restarting and even after core/parent/game specific presets are loaded
- SOLARIS: Initial port.
- SWITCH: Initial Nintendo Switch port, based on libtransistor SDK.
- PS3: Enable Cheevos.

View File

@ -220,6 +220,7 @@ bool command_set_shader(const char *arg)
{
char msg[256];
enum rarch_shader_type type = RARCH_SHADER_NONE;
struct video_shader *shader = menu_shader_get();
switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(arg))))
{
@ -245,7 +246,8 @@ bool command_set_shader(const char *arg)
msg_hash_to_str(MSG_APPLYING_SHADER),
arg);
return video_driver_set_shader(type, arg);
retroarch_set_shader_preset(arg);
return menu_shader_manager_set_preset(shader, type, arg);
}
#if defined(HAVE_COMMAND) && defined(HAVE_CHEEVOS)
@ -1295,31 +1297,13 @@ static void command_event_disable_overrides(void)
return;
/* reload the original config */
config_unload_override();
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
static void command_event_restore_default_shader_preset(void)
{
if (!path_is_empty(RARCH_PATH_DEFAULT_SHADER_PRESET))
{
/* auto shader preset: reload the original shader */
settings_t *settings = config_get_ptr();
const char *shader_preset = path_get(RARCH_PATH_DEFAULT_SHADER_PRESET);
if (!string_is_empty(shader_preset))
{
RARCH_LOG("%s %s\n",
msg_hash_to_str(MSG_RESTORING_DEFAULT_SHADER_PRESET_TO),
shader_preset);
strlcpy(settings->paths.path_shader,
shader_preset,
sizeof(settings->paths.path_shader));
}
}
path_clear(RARCH_PATH_DEFAULT_SHADER_PRESET);
retroarch_unset_shader_preset();
}
static void command_event_restore_remaps(void)
@ -1440,6 +1424,7 @@ static bool command_event_save_core_config(void)
{
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true);
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
free (config_dir);
return false;
}

View File

@ -2875,29 +2875,29 @@ static bool config_load_file(const char *path, bool set_defaults,
config_read_keybinds_conf(conf);
const char *shader_ext = path_get_extension(settings->paths.path_shader);
if (!string_is_empty(shader_ext))
{
for(i = FILE_PATH_CGP_EXTENSION; i <= FILE_PATH_SLANGP_EXTENSION; i++)
{
enum file_path_enum ext = (enum file_path_enum)(i);
if(!strstr(file_path_str(ext), shader_ext))
continue;
if (check_shader_compatibility(ext))
continue;
RARCH_LOG("Incompatible shader for backend %s, clearing...\n",
settings->arrays.video_driver);
settings->paths.path_shader[0] = '\0';
break;
}
}
ret = true;
{
const char *shader_ext = path_get_extension(settings->paths.path_shader);
if (!string_is_empty(shader_ext))
{
for(i = FILE_PATH_CGP_EXTENSION; i <= FILE_PATH_SLANGP_EXTENSION; i++)
{
enum file_path_enum ext = (enum file_path_enum)(i);
if(!strstr(file_path_str(ext), shader_ext))
continue;
if (check_shader_compatibility(ext))
continue;
RARCH_LOG("Incompatible shader for backend %s, clearing...\n",
settings->arrays.video_driver);
settings->paths.path_shader[0] = '\0';
break;
}
}
}
end:
if (conf)
@ -3227,10 +3227,15 @@ bool config_load_shader_preset(void)
char *shader_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
char *parent_path = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char parent_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(parent_name, path_get(RARCH_PATH_BASENAME), sizeof(parent_name));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
@ -3246,6 +3251,9 @@ bool config_load_shader_preset(void)
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for game-specific configuration (prefix+suffix) */
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for parent-dir-specific configuration (prefix+suffix) */
parent_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
shader_directory[0] = core_path[0] = game_path[0] = '\0';
fill_pathname_join (shader_directory, settings->paths.directory_video_shader,
@ -3282,9 +3290,33 @@ bool config_load_shader_preset(void)
/* Game shader preset exists, load it. */
RARCH_LOG("Shaders: game-specific shader preset found at %s.\n", game_path);
retroarch_set_shader_preset(game_path);
goto success;
}
path_set(RARCH_PATH_DEFAULT_SHADER_PRESET, settings->paths.path_shader);
strlcpy(settings->paths.path_shader, game_path, sizeof(settings->paths.path_shader));
for(idx = FILE_PATH_CGP_EXTENSION; idx <= FILE_PATH_SLANGP_EXTENSION; idx++)
{
if (!check_shader_compatibility((enum file_path_enum)(idx)))
continue;
/* Concatenate strings into full paths for core_path, parent path */
fill_pathname_join_special_ext(parent_path,
shader_directory, core_name,
parent_name,
file_path_str((enum file_path_enum)(idx)),
path_size);
/* Create a new config file from parent path */
new_conf = config_file_new(parent_path);
if (!new_conf)
{
RARCH_LOG("Shaders: no parent-dir-specific preset found at %s.\n", parent_path);
continue;
}
/* Parent-dir shader preset exists, load it. */
RARCH_LOG("Shaders: parent-dir-specific shader preset found at %s.\n", parent_path);
retroarch_set_shader_preset(parent_path);
goto success;
}
@ -3310,8 +3342,7 @@ bool config_load_shader_preset(void)
/* Core shader preset exists, load it. */
RARCH_LOG("Shaders: core-specific shader preset found at %s.\n", core_path);
path_set(RARCH_PATH_DEFAULT_SHADER_PRESET, settings->paths.path_shader);
strlcpy(settings->paths.path_shader, core_path, sizeof(settings->paths.path_shader));
retroarch_set_shader_preset(core_path);
goto success;
}
@ -3324,6 +3355,7 @@ success:
free(shader_directory);
free(core_path);
free(game_path);
free(parent_path);
config_file_free(new_conf);
return true;
}

View File

@ -56,6 +56,7 @@
#include "../../core.h"
#include "../../verbosity.h"
#include "../../retroarch.h"
static LPDIRECT3D9 g_pD3D9;
@ -1081,7 +1082,7 @@ static bool d3d9_init_internal(d3d_video_t *d3d,
if (settings->bools.video_shader_enable)
{
enum rarch_shader_type type =
video_shader_parse_type(settings->paths.path_shader,
video_shader_parse_type(retroarch_get_shader_preset(),
RARCH_SHADER_NONE);
switch (type)
@ -1089,8 +1090,8 @@ static bool d3d9_init_internal(d3d_video_t *d3d,
case RARCH_SHADER_CG:
if (!string_is_empty(d3d->shader_path))
free(d3d->shader_path);
if (!string_is_empty(settings->paths.path_shader))
d3d->shader_path = strdup(settings->paths.path_shader);
if (!string_is_empty(retroarch_get_shader_preset()))
d3d->shader_path = strdup(retroarch_get_shader_preset());
break;
default:
break;

View File

@ -379,11 +379,17 @@ static bool gl_shader_init(gl_t *gl, const gfx_ctx_driver_t *ctx_driver,
{
video_shader_ctx_init_t init_data;
settings_t *settings = config_get_ptr();
const char *shader_path = (settings->bools.video_shader_enable
&& *settings->paths.path_shader) ? settings->paths.path_shader : NULL;
enum rarch_shader_type type = video_shader_parse_type(shader_path,
const char *shader_path = retroarch_get_shader_preset();
enum rarch_shader_type type;
if (shader_path)
{
type = video_shader_parse_type(shader_path,
gl->core_context_in_use
? RARCH_SHADER_GLSL : DEFAULT_SHADER_TYPE);
}
else
type = DEFAULT_SHADER_TYPE;
switch (type)
{

View File

@ -23,6 +23,7 @@
#include "../../driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#include "../../retroarch.h"
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -446,7 +447,7 @@ static void *wiiu_gfx_init(const video_info_t *video,
if(settings->bools.video_shader_enable)
{
const char* ext = path_get_extension(settings->paths.path_shader);
const char* ext = retroarch_get_shader_preset();
if(ext && !strncmp(ext, "slang", 5))
wiiu_gfx_set_shader(wiiu, RARCH_SHADER_SLANG, settings->paths.path_shader);

View File

@ -810,8 +810,7 @@ static bool vulkan_init_filter_chain_preset(vk_t *vk, const char *shader_path)
static bool vulkan_init_filter_chain(vk_t *vk)
{
settings_t *settings = config_get_ptr();
const char *shader_path = (settings->bools.video_shader_enable && *settings->paths.path_shader) ?
settings->paths.path_shader : NULL;
const char *shader_path = retroarch_get_shader_preset();
enum rarch_shader_type type = video_shader_parse_type(shader_path, RARCH_SHADER_NONE);

View File

@ -296,7 +296,7 @@ static bool hlsl_d3d9_renderchain_init_shader(void *data,
init.shader_type = RARCH_SHADER_HLSL;
init.data = data;
init.path = settings->paths.path_shader;
init.path = retroarch_get_shader_preset();
init.shader = &hlsl_backend;
RARCH_LOG("D3D]: Using HLSL shader backend.\n");

View File

@ -31,6 +31,8 @@
#include <gfx/video_frame.h>
#include <formats/image.h>
#include "../menu/menu_shader.h"
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
@ -672,9 +674,11 @@ retro_proc_address_t video_driver_get_proc_address(const char *sym)
bool video_driver_set_shader(enum rarch_shader_type type,
const char *path)
{
bool ret = false;
if (current_video->set_shader)
return current_video->set_shader(video_driver_data, type, path);
return false;
ret = current_video->set_shader(video_driver_data, type, path);
return ret;
}
static void video_driver_filter_free(void)

View File

@ -1642,8 +1642,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"預覽Shader參數")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"戴入Shader預設")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"選單Shader參數")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"儲存Shader預設為")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1689,8 +1689,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Vorschau der Shader-Parameter")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Shader-Voreinstellung laden")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Shader-Parameter anpassen")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Shader-Voreinstellung speichern unter...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1542,8 +1542,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Preview Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Load Shader Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Menu Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Save Shader Preset As")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -2985,10 +2985,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Cargar preset de shaders"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Parámetros de shaders del menú"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Guardar preset de shaders como.."

View File

@ -1659,8 +1659,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Prévisualiser les paramètres")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Charger un pré-réglage de shader")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Charger un pré-réglage de shader")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Enregistrer le pré-réglage sous")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1687,8 +1687,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Anteprima dei parametri Shader")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Carica Shader Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Parametri Shader del menu")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Salvare Preset Shader come")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1753,8 +1753,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"シェーダーパラメータのプレビュー")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"シェーダーのプリセットをロード")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"メニューのシェーダーパラメータ")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"シェーダーのプリセットを名前を付けて保存")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1639,8 +1639,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"쉐이더 매개변수 미리보기")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"쉐이더 프리셋 불러오기")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"메뉴 쉐이더 매개변수")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"쉐이더 프리셋 다른 이름으로 저장")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1540,8 +1540,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Voorbeeldweergave Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Load Shader Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Menu Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Shader Preset Opslaan Als")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1701,8 +1701,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Podgląd parametrów modułu cieniującego")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Załaduj ustawienia Shader")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Parametry menu Shadera")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Zapisz ustawienie Shadera jako")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -2148,9 +2148,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Carregar Predefinição de Shader"
)
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Menu de Parâmetros de Shader"
)
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Salvar Predefinição de Shader Como"
)

View File

@ -1630,9 +1630,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES,
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Ver parâmetros de sombreamento")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Carregar sombreamento pré-definido")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Menu de parâmetros de sombramento")
"Carregar Sombreamento Predefinido")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Guardar pré-definições de sombreamento como")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1668,8 +1668,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Предварительный просмотр параметров шейдера")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Загрузить предварительную настройку шейдера")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Параметры меню шейдера")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Сохранить предустановку шейдера как")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -1756,15 +1756,15 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_DIR,
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES,
"Shader Passes")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Preview Shader Parameters")
"Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Load Shader Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Menu Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Save Shader Preset As")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,
"Save Core Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_PARENT,
"Save Content Directory Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GAME,
"Save Game Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHARED_CONTEXT,
@ -3147,6 +3147,8 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_AS,
"Save the current shader settings as a new shader preset.")
MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_CORE,
"Save the current shader settings as the default settings for this application/core.")
MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_PARENT,
"Save the current shader settings as the default settings for all files in the current content directory.")
MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_GAME,
"Save the current shader settings as the default settings for the content.")
MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_SHADER_PARAMETERS,

View File

@ -1653,8 +1653,6 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS,
"Preview Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET,
"Tải Shader Preset")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS,
"Menu Shader Parameters")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS,
"Save Shader Preset As")
MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE,

View File

@ -60,33 +60,25 @@ static int generic_shader_action_parameter_left(
return 0;
}
static int shader_action_parameter_left(unsigned type, const char *label,
bool wraparound)
static int shader_action_parameter_left(unsigned type, const char *label, bool wraparound)
{
video_shader_ctx_t shader_info;
struct video_shader_parameter *param = NULL;
video_shader_driver_get_current_shader(&shader_info);
param = &shader_info.data->parameters[type
- MENU_SETTINGS_SHADER_PARAMETER_0];
param = &shader_info.data->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0];
if (!param)
return 0;
return generic_shader_action_parameter_left(param,
type, label, wraparound);
return menu_cbs_exit();
generic_shader_action_parameter_left(param, type, label, wraparound);
param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PARAMETER_0);
if (!param)
return menu_cbs_exit();
return generic_shader_action_parameter_left(param, type, label, wraparound);
}
static int shader_action_parameter_preset_left(unsigned type,
const char *label,
bool wraparound)
{
struct video_shader_parameter *param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
if (!param)
return 0;
return generic_shader_action_parameter_left(param,
type, label, wraparound);
}
#endif
static int action_left_cheat(unsigned type, const char *label,
@ -614,7 +606,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_LEFT(cbs, shader_action_parameter_preset_left);
BIND_ACTION_LEFT(cbs, shader_action_parameter_left);
}
#endif
else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN

View File

@ -1868,7 +1868,8 @@ default_action_dialog_start(action_ok_rename_entry,
enum
{
ACTION_OK_SHADER_PRESET_SAVE_CORE = 0,
ACTION_OK_SHADER_PRESET_SAVE_GAME
ACTION_OK_SHADER_PRESET_SAVE_GAME,
ACTION_OK_SHADER_PRESET_SAVE_PARENT
};
static int generic_action_ok_shader_preset_save(const char *path,
@ -1915,6 +1916,12 @@ static int generic_action_ok_shader_preset_save(const char *path,
fill_pathname_join(file, directory, game_name, sizeof(file));
}
break;
case ACTION_OK_SHADER_PRESET_SAVE_PARENT:
{
fill_pathname_parent_dir_name(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp));
fill_pathname_join(file, directory, tmp, sizeof(file));
}
break;
}
if(menu_shader_manager_save_preset(file, false, true))
@ -1943,7 +1950,12 @@ static int action_ok_shader_preset_save_game(const char *path,
idx, entry_idx, ACTION_OK_SHADER_PRESET_SAVE_GAME);
}
static int action_ok_shader_preset_save_parent(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_shader_preset_save(path, label, type,
idx, entry_idx, ACTION_OK_SHADER_PRESET_SAVE_PARENT);
}
static int generic_action_ok_remap_file_operation(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx,
@ -4189,6 +4201,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE:
BIND_ACTION_OK(cbs, action_ok_shader_preset_save_core);
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT:
BIND_ACTION_OK(cbs, action_ok_shader_preset_save_parent);
break;
case MENU_ENUM_LABEL_CHEAT_FILE_SAVE_AS:
BIND_ACTION_OK(cbs, action_ok_cheat_file_save_as);
break;

View File

@ -71,16 +71,12 @@ int shader_action_parameter_right(unsigned type, const char *label, bool wraparo
video_shader_driver_get_current_shader(&shader_info);
param = &shader_info.data->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0];
if (!param)
return menu_cbs_exit();
return generic_shader_action_parameter_right(param, type, label, wraparound);
}
int shader_action_parameter_preset_right(unsigned type, const char *label,
bool wraparound)
{
struct video_shader_parameter *param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
generic_shader_action_parameter_right(param, type, label, wraparound);
param = menu_shader_manager_get_parameters(
type - MENU_SETTINGS_SHADER_PARAMETER_0);
if (!param)
return menu_cbs_exit();
return generic_shader_action_parameter_right(param, type, label, wraparound);
@ -481,7 +477,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_RIGHT(cbs, shader_action_parameter_preset_right);
BIND_ACTION_RIGHT(cbs, shader_action_parameter_right);
}
#endif
else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN

View File

@ -132,7 +132,7 @@ static int shader_action_parameter_select(const char *path, const char *label, u
static int shader_action_parameter_preset_select(const char *path, const char *label, unsigned type,
size_t idx)
{
return shader_action_parameter_preset_right(type, label, true);
return shader_action_parameter_right(type, label, true);
}
#endif

View File

@ -135,12 +135,7 @@ static int action_start_shader_action_parameter(unsigned type, const char *label
#endif
return 0;
}
static int action_start_shader_action_preset_parameter(unsigned type, const char *label)
{
unsigned parameter = type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0;
unsigned parameter = type - MENU_SETTINGS_SHADER_PARAMETER_0;
return menu_shader_manager_clear_parameter(parameter);
}
@ -337,7 +332,7 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
{
BIND_ACTION_START(cbs, action_start_shader_action_preset_parameter);
BIND_ACTION_START(cbs, action_start_shader_action_parameter);
}
else if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN &&
type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END)

View File

@ -358,6 +358,7 @@ default_sublabel_macro(action_bind_sublabel_shader_num_passes,
default_sublabel_macro(action_bind_sublabel_shader_preset, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_as, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_AS)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_core, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_CORE)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_parent, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_PARENT)
default_sublabel_macro(action_bind_sublabel_shader_preset_save_game, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_GAME)
default_sublabel_macro(action_bind_sublabel_shader_parameters, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PARAMETERS)
default_sublabel_macro(action_bind_sublabel_shader_preset_parameters, MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_PARAMETERS)
@ -505,6 +506,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_shader_preset_save_core);
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_shader_preset_save_parent);
break;
case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_GAME:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_shader_preset_save_game);
break;

View File

@ -141,9 +141,6 @@ int action_refresh_default(file_list_t *list, file_list_t *menu_list);
int shader_action_parameter_right(unsigned type, const char *label, bool wraparound);
int shader_action_parameter_preset_right(unsigned type, const char *label,
bool wraparound);
int generic_action_ok_displaylist_push(const char *path, const char *new_path,
const char *label, unsigned type, size_t idx, size_t entry_idx,
unsigned action_type);

View File

@ -1384,12 +1384,17 @@ static int menu_displaylist_parse_shader_options(menu_displaylist_info_t *info)
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_AS),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_CORE,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_PARENT),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_PARENT,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GAME),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_AS),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_GAME),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_SAVE_GAME,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
@ -1397,11 +1402,6 @@ static int menu_displaylist_parse_shader_options(menu_displaylist_info_t *info)
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS),
MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_PARAMETERS),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS),
MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PARAMETERS,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES),
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_NUM_PASSES),

View File

@ -30,6 +30,7 @@
#include "../file_path_special.h"
#include "../configuration.h"
#include "../paths.h"
#include "../retroarch.h"
#include "../verbosity.h"
#ifdef HAVE_SHADER_MANAGER
@ -130,14 +131,14 @@ bool menu_shader_manager_init(void)
#ifdef HAVE_SHADER_MANAGER
settings_t *settings = config_get_ptr();
const char *config_path = path_get(RARCH_PATH_CONFIG);
const char *path_shader = settings->paths.path_shader;
const char *path_shader = retroarch_get_shader_preset();
menu_shader_manager_free();
menu_driver_shader = (struct video_shader*)
calloc(1, sizeof(struct video_shader));
if (!menu_driver_shader)
if (!menu_driver_shader || !path_shader)
return false;
/* In a multi-config setting, we can't have
@ -248,7 +249,7 @@ bool menu_shader_manager_init(void)
*
* Sets shader preset.
**/
void menu_shader_manager_set_preset(void *data,
bool menu_shader_manager_set_preset(void *data,
unsigned type, const char *preset_path)
{
#ifdef HAVE_SHADER_MANAGER
@ -260,7 +261,7 @@ void menu_shader_manager_set_preset(void *data,
if (!video_driver_set_shader((enum rarch_shader_type)type, preset_path))
{
configuration_set_bool(settings, settings->bools.video_shader_enable, false);
return;
return false;
}
/* Makes sure that we use Menu Preset shader on driver reinit.
@ -271,7 +272,7 @@ void menu_shader_manager_set_preset(void *data,
configuration_set_bool(settings, settings->bools.video_shader_enable, true);
if (!preset_path || !shader)
return;
return false;
/* Load stored Preset into menu on success.
* Used when a preset is directly loaded.
@ -280,7 +281,7 @@ void menu_shader_manager_set_preset(void *data,
conf = config_file_new(preset_path);
if (!conf)
return;
return false;
RARCH_LOG("Setting Menu shader: %s.\n", preset_path);
@ -292,6 +293,8 @@ void menu_shader_manager_set_preset(void *data,
config_file_free(conf);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
return true;
#endif
}

View File

@ -48,7 +48,7 @@ bool menu_shader_manager_init(void);
*
* Sets shader preset.
**/
void menu_shader_manager_set_preset(
bool menu_shader_manager_set_preset(
void *data, unsigned type, const char *preset_path);
/**

View File

@ -1514,6 +1514,7 @@ enum msg_hash_enums
MENU_LABEL(VIDEO_SHADER_PRESET_SAVE_AS),
MENU_LABEL(VIDEO_SHADER_PRESET_SAVE_CORE),
MENU_LABEL(VIDEO_SHADER_PRESET_SAVE_GAME),
MENU_LABEL(VIDEO_SHADER_PRESET_SAVE_PARENT),
MENU_LABEL(USER_LANGUAGE),
MENU_LABEL(NETPLAY_NICKNAME),
MENU_LABEL(VIDEO_VI_WIDTH),

View File

@ -182,6 +182,7 @@ static jmp_buf error_sjlj_context;
static enum rarch_core_type current_core_type = CORE_TYPE_PLAIN;
static enum rarch_core_type explicit_current_core_type = CORE_TYPE_PLAIN;
static char error_string[255] = {0};
static char runtime_shader_preset[255] = {0};
#ifdef HAVE_THREAD_STORAGE
static sthread_tls_t rarch_tls;
@ -1924,6 +1925,36 @@ void retroarch_unset_forced_fullscreen(void)
rarch_force_fullscreen = false;
}
/* set a runtime shader preset without overwriting the settings value */
void retroarch_set_shader_preset(const char* preset)
{
if (!string_is_empty(preset))
strlcpy(runtime_shader_preset, preset, sizeof(runtime_shader_preset));
else
runtime_shader_preset[0] = '\0';
}
/* unset a runtime shader preset */
void retroarch_unset_shader_preset(void)
{
runtime_shader_preset[0] = '\0';
}
/* get the name of the current shader preset */
char* retroarch_get_shader_preset(void)
{
settings_t *settings = config_get_ptr();
if (!settings->bools.video_shader_enable)
return NULL;
if (!string_is_empty(runtime_shader_preset))
return runtime_shader_preset;
else if (!string_is_empty(settings->paths.path_shader))
return settings->paths.path_shader;
else
return NULL;
}
bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx, void *data)
{
switch (enum_idx)

View File

@ -288,6 +288,12 @@ void retroarch_unset_forced_fullscreen(void);
void retroarch_set_current_core_type(enum rarch_core_type type, bool explicitly_set);
void retroarch_set_shader_preset(const char* preset);
void retroarch_unset_shader_preset(void);
char* retroarch_get_shader_preset(void);
/**
* retroarch_fail:
* @error_code : Error code.