simplify video_shader_read_conf_preset() calls
This commit is contained in:
parent
9b4c50a017
commit
f8b92770d4
|
@ -1144,7 +1144,7 @@ typedef struct MTLALIGN(16)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
texture_t *source = NULL;
|
texture_t *source = NULL;
|
||||||
if (!video_shader_read_conf_preset(conf, shader, path.UTF8String))
|
if (!video_shader_read_conf_preset(conf, shader))
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
source = &_engine.frame.texture[0];
|
source = &_engine.frame.texture[0];
|
||||||
|
|
|
@ -365,7 +365,7 @@ static bool d3d10_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||||
|
|
||||||
d3d10->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d10->shader_preset));
|
d3d10->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d10->shader_preset));
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf, d3d10->shader_preset, path))
|
if (!video_shader_read_conf_preset(conf, d3d10->shader_preset))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
source = &d3d10->frame.texture[0];
|
source = &d3d10->frame.texture[0];
|
||||||
|
|
|
@ -383,7 +383,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||||
|
|
||||||
d3d11->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d11->shader_preset));
|
d3d11->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d11->shader_preset));
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf, d3d11->shader_preset, path))
|
if (!video_shader_read_conf_preset(conf, d3d11->shader_preset))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
source = &d3d11->frame.texture[0];
|
source = &d3d11->frame.texture[0];
|
||||||
|
|
|
@ -364,7 +364,7 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||||
|
|
||||||
d3d12->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d12->shader_preset));
|
d3d12->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d12->shader_preset));
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf, d3d12->shader_preset, path))
|
if (!video_shader_read_conf_preset(conf, d3d12->shader_preset))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
source = &d3d12->frame.texture[0];
|
source = &d3d12->frame.texture[0];
|
||||||
|
|
|
@ -339,7 +339,7 @@ static bool d3d9_init_multipass(d3d9_video_t *d3d, const char *shader_path)
|
||||||
|
|
||||||
memset(&d3d->shader, 0, sizeof(d3d->shader));
|
memset(&d3d->shader, 0, sizeof(d3d->shader));
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf, &d3d->shader, shader_path))
|
if (!video_shader_read_conf_preset(conf, &d3d->shader))
|
||||||
{
|
{
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
RARCH_ERR("[D3D9]: Failed to parse shader preset.\n");
|
RARCH_ERR("[D3D9]: Failed to parse shader preset.\n");
|
||||||
|
|
|
@ -1458,7 +1458,7 @@ static bool wiiu_gfx_set_shader(void *data,
|
||||||
|
|
||||||
wiiu->shader_preset = calloc(1, sizeof(*wiiu->shader_preset));
|
wiiu->shader_preset = calloc(1, sizeof(*wiiu->shader_preset));
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf, wiiu->shader_preset, path))
|
if (!video_shader_read_conf_preset(conf, wiiu->shader_preset))
|
||||||
{
|
{
|
||||||
free(wiiu->shader_preset);
|
free(wiiu->shader_preset);
|
||||||
wiiu->shader_preset = NULL;
|
wiiu->shader_preset = NULL;
|
||||||
|
|
|
@ -692,7 +692,7 @@ static bool gl_cg_load_preset(void *data, const char *path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf, cg->shader, path))
|
if (!video_shader_read_conf_preset(conf, cg->shader))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to parse CGP file.\n");
|
RARCH_ERR("Failed to parse CGP file.\n");
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
|
@ -2413,7 +2413,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset(
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf.get(), shader.get(), path))
|
if (!video_shader_read_conf_preset(conf.get(), shader.get()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
bool last_pass_is_fbo = shader->pass[shader->passes - 1].fbo.valid;
|
bool last_pass_is_fbo = shader->pass[shader->passes - 1].fbo.valid;
|
||||||
|
|
|
@ -903,7 +903,7 @@ static void *gl_glsl_init(void *data, const char *path)
|
||||||
conf = config_file_new_from_path_to_string(path);
|
conf = config_file_new_from_path_to_string(path);
|
||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
ret = video_shader_read_conf_preset(conf, glsl->shader, path);
|
ret = video_shader_read_conf_preset(conf, glsl->shader);
|
||||||
glsl->shader->modern = true;
|
glsl->shader->modern = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2890,7 +2890,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!video_shader_read_conf_preset(conf.get(), shader.get(), path))
|
if (!video_shader_read_conf_preset(conf.get(), shader.get()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
bool last_pass_is_fbo = shader->pass[shader->passes - 1].fbo.valid;
|
bool last_pass_is_fbo = shader->pass[shader->passes - 1].fbo.valid;
|
||||||
|
|
|
@ -102,14 +102,13 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode)
|
||||||
* @conf : Preset file to read from.
|
* @conf : Preset file to read from.
|
||||||
* @pass : Shader passes handle.
|
* @pass : Shader passes handle.
|
||||||
* @i : Index of shader pass.
|
* @i : Index of shader pass.
|
||||||
* @ref_path : Base path used to resolve relative paths
|
|
||||||
*
|
*
|
||||||
* Parses shader pass from preset file.
|
* Parses shader pass from preset file.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
static bool video_shader_parse_pass(config_file_t *conf,
|
static bool video_shader_parse_pass(config_file_t *conf,
|
||||||
struct video_shader_pass *pass, unsigned i, const char *ref_path)
|
struct video_shader_pass *pass, unsigned i)
|
||||||
{
|
{
|
||||||
char shader_name[64];
|
char shader_name[64];
|
||||||
char filter_name_buf[64];
|
char filter_name_buf[64];
|
||||||
|
@ -152,7 +151,7 @@ static bool video_shader_parse_pass(config_file_t *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_pathname_resolve_relative(pass->source.path,
|
fill_pathname_resolve_relative(pass->source.path,
|
||||||
ref_path, tmp_path, sizeof(pass->source.path));
|
conf->path, tmp_path, sizeof(pass->source.path));
|
||||||
free(tmp_path);
|
free(tmp_path);
|
||||||
|
|
||||||
/* Smooth */
|
/* Smooth */
|
||||||
|
@ -307,14 +306,13 @@ static bool video_shader_parse_pass(config_file_t *conf,
|
||||||
* video_shader_parse_textures:
|
* video_shader_parse_textures:
|
||||||
* @conf : Preset file to read from.
|
* @conf : Preset file to read from.
|
||||||
* @shader : Shader pass handle.
|
* @shader : Shader pass handle.
|
||||||
* @ref_path : Base path used to resolve relative paths
|
|
||||||
*
|
*
|
||||||
* Parses shader textures.
|
* Parses shader textures.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
static bool video_shader_parse_textures(config_file_t *conf,
|
static bool video_shader_parse_textures(config_file_t *conf,
|
||||||
struct video_shader *shader, const char *ref_path)
|
struct video_shader *shader)
|
||||||
{
|
{
|
||||||
size_t path_size = PATH_MAX_LENGTH;
|
size_t path_size = PATH_MAX_LENGTH;
|
||||||
const char *id = NULL;
|
const char *id = NULL;
|
||||||
|
@ -354,7 +352,7 @@ static bool video_shader_parse_textures(config_file_t *conf,
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_pathname_resolve_relative(shader->lut[shader->luts].path,
|
fill_pathname_resolve_relative(shader->lut[shader->luts].path,
|
||||||
ref_path, tmp_path, sizeof(shader->lut[shader->luts].path));
|
conf->path, tmp_path, sizeof(shader->lut[shader->luts].path));
|
||||||
|
|
||||||
|
|
||||||
strlcpy(shader->lut[shader->luts].id, id,
|
strlcpy(shader->lut[shader->luts].id, id,
|
||||||
|
@ -563,7 +561,6 @@ bool video_shader_resolve_parameters(config_file_t *conf,
|
||||||
* video_shader_read_conf_preset:
|
* video_shader_read_conf_preset:
|
||||||
* @conf : Preset file to read from.
|
* @conf : Preset file to read from.
|
||||||
* @shader : Shader passes handle.
|
* @shader : Shader passes handle.
|
||||||
* @ref_path : Base path used to resolve relative paths
|
|
||||||
*
|
*
|
||||||
* Loads preset file and all associated state (passes,
|
* Loads preset file and all associated state (passes,
|
||||||
* textures, imports, etc).
|
* textures, imports, etc).
|
||||||
|
@ -571,7 +568,7 @@ bool video_shader_resolve_parameters(config_file_t *conf,
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool video_shader_read_conf_preset(config_file_t *conf,
|
bool video_shader_read_conf_preset(config_file_t *conf,
|
||||||
struct video_shader *shader, const char* ref_path)
|
struct video_shader *shader)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
union string_list_elem_attr attr;
|
union string_list_elem_attr attr;
|
||||||
|
@ -618,7 +615,7 @@ bool video_shader_read_conf_preset(config_file_t *conf,
|
||||||
|
|
||||||
for (i = 0; i < shader->passes; i++)
|
for (i = 0; i < shader->passes; i++)
|
||||||
{
|
{
|
||||||
if (!video_shader_parse_pass(conf, &shader->pass[i], i, ref_path))
|
if (!video_shader_parse_pass(conf, &shader->pass[i], i))
|
||||||
{
|
{
|
||||||
if (file_list)
|
if (file_list)
|
||||||
{
|
{
|
||||||
|
@ -648,7 +645,7 @@ bool video_shader_read_conf_preset(config_file_t *conf,
|
||||||
|
|
||||||
command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL);
|
command_event(CMD_EVENT_SHADER_PRESET_LOADED, NULL);
|
||||||
|
|
||||||
if (!video_shader_parse_textures(conf, shader, ref_path))
|
if (!video_shader_parse_textures(conf, shader))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -163,14 +163,13 @@ struct video_shader
|
||||||
* video_shader_read_conf_preset:
|
* video_shader_read_conf_preset:
|
||||||
* @conf : Preset file to read from.
|
* @conf : Preset file to read from.
|
||||||
* @shader : Shader passes handle.
|
* @shader : Shader passes handle.
|
||||||
* @ref_path : Base path used to resolve relative paths
|
|
||||||
* Loads preset file and all associated state (passes,
|
* Loads preset file and all associated state (passes,
|
||||||
* textures, imports, etc).
|
* textures, imports, etc).
|
||||||
*
|
*
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool video_shader_read_conf_preset(config_file_t *conf,
|
bool video_shader_read_conf_preset(config_file_t *conf,
|
||||||
struct video_shader *shader, const char* ref_path);
|
struct video_shader *shader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video_shader_write_conf_preset:
|
* video_shader_write_conf_preset:
|
||||||
|
|
|
@ -61,7 +61,6 @@ bool menu_shader_manager_init(void)
|
||||||
{
|
{
|
||||||
bool is_preset = false;
|
bool is_preset = false;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
char *new_path = NULL;
|
|
||||||
const char *path_shader = retroarch_get_shader_preset();
|
const char *path_shader = retroarch_get_shader_preset();
|
||||||
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
||||||
|
|
||||||
|
@ -80,8 +79,6 @@ bool menu_shader_manager_init(void)
|
||||||
{
|
{
|
||||||
if (path_is_valid(path_shader))
|
if (path_is_valid(path_shader))
|
||||||
conf = config_file_new_from_path_to_string(path_shader);
|
conf = config_file_new_from_path_to_string(path_shader);
|
||||||
|
|
||||||
new_path = strdup(path_shader);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -131,19 +128,12 @@ bool menu_shader_manager_init(void)
|
||||||
conf = config_file_new_from_path_to_string(preset_path);
|
conf = config_file_new_from_path_to_string(preset_path);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
new_path = strdup(preset_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (conf && video_shader_read_conf_preset(conf, menu_driver_shader))
|
||||||
!string_is_empty(new_path) && conf &&
|
|
||||||
video_shader_read_conf_preset(conf, menu_driver_shader, new_path)
|
|
||||||
)
|
|
||||||
video_shader_resolve_parameters(conf, menu_driver_shader);
|
video_shader_resolve_parameters(conf, menu_driver_shader);
|
||||||
|
|
||||||
if (new_path)
|
|
||||||
free(new_path);
|
|
||||||
if (conf)
|
if (conf)
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
||||||
|
@ -191,7 +181,7 @@ bool menu_shader_manager_set_preset(void *data,
|
||||||
|
|
||||||
RARCH_LOG("Setting Menu shader: %s.\n", preset_path);
|
RARCH_LOG("Setting Menu shader: %s.\n", preset_path);
|
||||||
|
|
||||||
if (video_shader_read_conf_preset(conf, shader, preset_path))
|
if (video_shader_read_conf_preset(conf, shader))
|
||||||
video_shader_resolve_parameters(conf, shader);
|
video_shader_resolve_parameters(conf, shader);
|
||||||
|
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
Loading…
Reference in New Issue