shader code - Get rid of more hashes
This commit is contained in:
parent
f00d194ae3
commit
74309e6e1c
25
command.c
25
command.c
|
@ -219,26 +219,13 @@ static bool command_reply(const char * data, size_t len)
|
||||||
bool command_set_shader(const char *arg)
|
bool command_set_shader(const char *arg)
|
||||||
{
|
{
|
||||||
char msg[256];
|
char msg[256];
|
||||||
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
bool is_preset = false;
|
||||||
struct video_shader *shader = menu_shader_get();
|
struct video_shader *shader = menu_shader_get();
|
||||||
|
enum rarch_shader_type type = video_shader_get_type_from_ext(
|
||||||
|
path_get_extension(arg), &is_preset);
|
||||||
|
|
||||||
switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(arg))))
|
if (type == RARCH_SHADER_NONE)
|
||||||
{
|
return false;
|
||||||
case FILE_TYPE_SHADER_GLSL:
|
|
||||||
case FILE_TYPE_SHADER_PRESET_GLSLP:
|
|
||||||
type = RARCH_SHADER_GLSL;
|
|
||||||
break;
|
|
||||||
case FILE_TYPE_SHADER_CG:
|
|
||||||
case FILE_TYPE_SHADER_PRESET_CGP:
|
|
||||||
type = RARCH_SHADER_CG;
|
|
||||||
break;
|
|
||||||
case FILE_TYPE_SHADER_SLANG:
|
|
||||||
case FILE_TYPE_SHADER_PRESET_SLANGP:
|
|
||||||
type = RARCH_SHADER_SLANG;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg);
|
snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg);
|
||||||
runloop_msg_queue_push(msg, 1, 120, true);
|
runloop_msg_queue_push(msg, 1, 120, true);
|
||||||
|
|
|
@ -1062,6 +1062,56 @@ void video_shader_write_conf_cgp(config_file_t *conf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool video_shader_is_supported(enum rarch_shader_type type)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SLANG
|
||||||
|
if (type == RARCH_SHADER_SLANG)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GLSL
|
||||||
|
if (type == RARCH_SHADER_GLSL)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_HLSL
|
||||||
|
if (type == RARCH_SHADER_HLSL)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_CG
|
||||||
|
if (type == RARCH_SHADER_CG)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum rarch_shader_type video_shader_get_type_from_ext(
|
||||||
|
const char *ext, bool *is_preset)
|
||||||
|
{
|
||||||
|
*is_preset = false;
|
||||||
|
|
||||||
|
if (string_is_equal_noncase(ext, "cg"))
|
||||||
|
return RARCH_SHADER_CG;
|
||||||
|
if (string_is_equal_noncase(ext, "cgp"))
|
||||||
|
{
|
||||||
|
*is_preset = true;
|
||||||
|
return RARCH_SHADER_CG;
|
||||||
|
}
|
||||||
|
if (string_is_equal_noncase(ext, "glsl"))
|
||||||
|
return RARCH_SHADER_GLSL;
|
||||||
|
if (string_is_equal_noncase(ext, "glslp"))
|
||||||
|
{
|
||||||
|
*is_preset = true;
|
||||||
|
return RARCH_SHADER_GLSL;
|
||||||
|
}
|
||||||
|
if (string_is_equal_noncase(ext, "slang"))
|
||||||
|
return RARCH_SHADER_SLANG;
|
||||||
|
if (string_is_equal_noncase(ext, "slangp"))
|
||||||
|
{
|
||||||
|
*is_preset = true;
|
||||||
|
return RARCH_SHADER_SLANG;
|
||||||
|
}
|
||||||
|
return RARCH_SHADER_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video_shader_parse_type:
|
* video_shader_parse_type:
|
||||||
* @path : Shader path.
|
* @path : Shader path.
|
||||||
|
@ -1076,35 +1126,17 @@ void video_shader_write_conf_cgp(config_file_t *conf,
|
||||||
enum rarch_shader_type video_shader_parse_type(const char *path,
|
enum rarch_shader_type video_shader_parse_type(const char *path,
|
||||||
enum rarch_shader_type fallback)
|
enum rarch_shader_type fallback)
|
||||||
{
|
{
|
||||||
|
bool is_preset = false;
|
||||||
enum rarch_shader_type shader_type = RARCH_SHADER_NONE;
|
enum rarch_shader_type shader_type = RARCH_SHADER_NONE;
|
||||||
enum gfx_ctx_api api = video_context_driver_get_api();
|
enum gfx_ctx_api api = video_context_driver_get_api();
|
||||||
#ifdef HAVE_CG
|
bool cg_supported = video_shader_is_supported(RARCH_SHADER_CG);
|
||||||
bool cg_supported = true;
|
|
||||||
#else
|
|
||||||
bool cg_supported = false;
|
|
||||||
#endif
|
|
||||||
const char *ext = NULL;
|
const char *ext = NULL;
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|
||||||
ext = path_get_extension(path);
|
ext = path_get_extension(path);
|
||||||
|
shader_type = video_shader_get_type_from_ext(ext, &is_preset);
|
||||||
if (
|
|
||||||
string_is_equal_noncase(ext, "cg") ||
|
|
||||||
string_is_equal_noncase(ext, "cgp")
|
|
||||||
)
|
|
||||||
shader_type = RARCH_SHADER_CG;
|
|
||||||
else if (
|
|
||||||
string_is_equal_noncase(ext, "glsl") ||
|
|
||||||
string_is_equal_noncase(ext, "glslp")
|
|
||||||
)
|
|
||||||
shader_type = RARCH_SHADER_GLSL;
|
|
||||||
else if (
|
|
||||||
string_is_equal_noncase(ext, "slang") ||
|
|
||||||
string_is_equal_noncase(ext, "slangp")
|
|
||||||
)
|
|
||||||
shader_type = RARCH_SHADER_SLANG;
|
|
||||||
|
|
||||||
switch (api)
|
switch (api)
|
||||||
{
|
{
|
||||||
|
|
|
@ -239,6 +239,11 @@ bool video_shader_resolve_parameters(config_file_t *conf,
|
||||||
enum rarch_shader_type video_shader_parse_type(const char *path,
|
enum rarch_shader_type video_shader_parse_type(const char *path,
|
||||||
enum rarch_shader_type fallback);
|
enum rarch_shader_type fallback);
|
||||||
|
|
||||||
|
enum rarch_shader_type video_shader_get_type_from_ext(
|
||||||
|
const char *ext, bool *is_preset);
|
||||||
|
|
||||||
|
bool video_shader_is_supported(enum rarch_shader_type type);
|
||||||
|
|
||||||
bool video_shader_check_for_changes(void);
|
bool video_shader_check_for_changes(void);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
|
@ -104,12 +104,6 @@ void menu_shader_manager_increment_amount_passes(void)
|
||||||
shader->passes++;
|
shader->passes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_shader_manager_free(void)
|
|
||||||
{
|
|
||||||
if (menu_driver_shader)
|
|
||||||
free(menu_driver_shader);
|
|
||||||
menu_driver_shader = NULL;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
struct video_shader *menu_shader_get(void)
|
struct video_shader *menu_shader_get(void)
|
||||||
{
|
{
|
||||||
|
@ -127,9 +121,15 @@ struct video_shader_pass *menu_shader_manager_get_pass(unsigned i)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned menu_shader_manager_get_amount_passes(void) { return 0; }
|
unsigned menu_shader_manager_get_amount_passes(void) { return 0; }
|
||||||
void menu_shader_manager_free(void) { }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void menu_shader_manager_free(void)
|
||||||
|
{
|
||||||
|
if (menu_driver_shader)
|
||||||
|
free(menu_driver_shader);
|
||||||
|
menu_driver_shader = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void menu_shader_manager_init_paths(void)
|
void menu_shader_manager_init_paths(void)
|
||||||
{
|
{
|
||||||
const char *config_path = path_get(RARCH_PATH_CONFIG);
|
const char *config_path = path_get(RARCH_PATH_CONFIG);
|
||||||
|
@ -177,9 +177,12 @@ void menu_shader_manager_init_paths(void)
|
||||||
**/
|
**/
|
||||||
bool menu_shader_manager_init(void)
|
bool menu_shader_manager_init(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
bool is_preset = false;
|
||||||
|
config_file_t *conf = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
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;
|
||||||
|
|
||||||
menu_shader_manager_free();
|
menu_shader_manager_free();
|
||||||
|
|
||||||
|
@ -191,76 +194,68 @@ bool menu_shader_manager_init(void)
|
||||||
|
|
||||||
menu_shader_manager_init_paths();
|
menu_shader_manager_init_paths();
|
||||||
|
|
||||||
switch (msg_hash_to_file_type(msg_hash_calculate(
|
type = video_shader_get_type_from_ext(path_get_extension(path_shader),
|
||||||
path_get_extension(path_shader))))
|
&is_preset);
|
||||||
{
|
|
||||||
case FILE_TYPE_SHADER_PRESET_GLSLP:
|
|
||||||
case FILE_TYPE_SHADER_PRESET_CGP:
|
|
||||||
case FILE_TYPE_SHADER_PRESET_SLANGP:
|
|
||||||
{
|
|
||||||
config_file_t *conf = config_file_new(path_shader);
|
|
||||||
|
|
||||||
if (conf)
|
if (is_preset)
|
||||||
{
|
{
|
||||||
if (video_shader_read_conf_cgp(conf, menu_driver_shader))
|
conf = config_file_new(path_shader);
|
||||||
{
|
new_path = strdup(path_shader);
|
||||||
video_shader_resolve_relative(menu_driver_shader,
|
}
|
||||||
path_shader);
|
else
|
||||||
video_shader_resolve_parameters(conf, menu_driver_shader);
|
{
|
||||||
}
|
if (video_shader_is_supported(type))
|
||||||
config_file_free(conf);
|
{
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FILE_TYPE_SHADER_GLSL:
|
|
||||||
case FILE_TYPE_SHADER_CG:
|
|
||||||
case FILE_TYPE_SHADER_SLANG:
|
|
||||||
strlcpy(menu_driver_shader->pass[0].source.path, path_shader,
|
strlcpy(menu_driver_shader->pass[0].source.path, path_shader,
|
||||||
sizeof(menu_driver_shader->pass[0].source.path));
|
sizeof(menu_driver_shader->pass[0].source.path));
|
||||||
menu_driver_shader->passes = 1;
|
menu_driver_shader->passes = 1;
|
||||||
break;
|
}
|
||||||
default:
|
else
|
||||||
|
{
|
||||||
|
char preset_path[PATH_MAX_LENGTH];
|
||||||
|
config_file_t *conf = NULL;
|
||||||
|
const char *shader_dir =
|
||||||
|
*settings->paths.directory_video_shader ?
|
||||||
|
settings->paths.directory_video_shader :
|
||||||
|
settings->paths.directory_system;
|
||||||
|
|
||||||
|
preset_path[0] = '\0';
|
||||||
|
|
||||||
|
fill_pathname_join(preset_path, shader_dir,
|
||||||
|
"menu.glslp", sizeof(preset_path));
|
||||||
|
conf = config_file_new(preset_path);
|
||||||
|
|
||||||
|
if (!conf)
|
||||||
{
|
{
|
||||||
char preset_path[PATH_MAX_LENGTH];
|
|
||||||
config_file_t *conf = NULL;
|
|
||||||
const char *shader_dir =
|
|
||||||
*settings->paths.directory_video_shader ?
|
|
||||||
settings->paths.directory_video_shader :
|
|
||||||
settings->paths.directory_system;
|
|
||||||
|
|
||||||
preset_path[0] = '\0';
|
|
||||||
|
|
||||||
fill_pathname_join(preset_path, shader_dir,
|
fill_pathname_join(preset_path, shader_dir,
|
||||||
"menu.glslp", sizeof(preset_path));
|
"menu.cgp", sizeof(preset_path));
|
||||||
conf = config_file_new(preset_path);
|
conf = config_file_new(preset_path);
|
||||||
|
|
||||||
if (!conf)
|
|
||||||
{
|
|
||||||
fill_pathname_join(preset_path, shader_dir,
|
|
||||||
"menu.cgp", sizeof(preset_path));
|
|
||||||
conf = config_file_new(preset_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!conf)
|
|
||||||
{
|
|
||||||
fill_pathname_join(preset_path, shader_dir,
|
|
||||||
"menu.slangp", sizeof(preset_path));
|
|
||||||
conf = config_file_new(preset_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf)
|
|
||||||
{
|
|
||||||
if (video_shader_read_conf_cgp(conf, menu_driver_shader))
|
|
||||||
{
|
|
||||||
video_shader_resolve_relative(menu_driver_shader, preset_path);
|
|
||||||
video_shader_resolve_parameters(conf, menu_driver_shader);
|
|
||||||
}
|
|
||||||
config_file_free(conf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
if (!conf)
|
||||||
|
{
|
||||||
|
fill_pathname_join(preset_path, shader_dir,
|
||||||
|
"menu.slangp", sizeof(preset_path));
|
||||||
|
conf = config_file_new(preset_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
new_path = strdup(preset_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string_is_empty(new_path))
|
||||||
|
{
|
||||||
|
if (conf)
|
||||||
|
{
|
||||||
|
if (video_shader_read_conf_cgp(conf, menu_driver_shader))
|
||||||
|
{
|
||||||
|
video_shader_resolve_relative(menu_driver_shader, new_path);
|
||||||
|
video_shader_resolve_parameters(conf, menu_driver_shader);
|
||||||
|
}
|
||||||
|
config_file_free(conf);
|
||||||
|
}
|
||||||
|
free(new_path);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -393,25 +388,23 @@ bool menu_shader_manager_save_preset(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *conf_path = NULL;
|
const char *conf_path = NULL;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case RARCH_SHADER_GLSL:
|
case RARCH_SHADER_GLSL:
|
||||||
#ifdef HAVE_GLSL
|
if (video_shader_is_supported(type))
|
||||||
conf_path = default_glslp;
|
conf_path = default_glslp;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RARCH_SHADER_SLANG:
|
case RARCH_SHADER_SLANG:
|
||||||
#ifdef HAVE_SLANG
|
if (video_shader_is_supported(type))
|
||||||
conf_path = default_slangp;
|
conf_path = default_slangp;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case RARCH_SHADER_CG:
|
case RARCH_SHADER_CG:
|
||||||
#ifdef HAVE_CG
|
if (video_shader_is_supported(type))
|
||||||
conf_path = default_cgp;
|
conf_path = default_cgp;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,13 +632,15 @@ void menu_shader_manager_apply_changes(void)
|
||||||
|
|
||||||
if (shader_type == RARCH_SHADER_NONE)
|
if (shader_type == RARCH_SHADER_NONE)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_GLSL)
|
if (video_shader_is_supported(RARCH_SHADER_GLSL))
|
||||||
shader_type = RARCH_SHADER_GLSL;
|
shader_type = RARCH_SHADER_GLSL;
|
||||||
#elif defined(HAVE_CG) || defined(HAVE_HLSL)
|
else if (
|
||||||
shader_type = RARCH_SHADER_CG;
|
video_shader_is_supported(RARCH_SHADER_CG) ||
|
||||||
#elif defined(HAVE_SLANG)
|
video_shader_is_supported(RARCH_SHADER_HLSL)
|
||||||
shader_type = RARCH_SHADER_SLANG;
|
)
|
||||||
#endif
|
shader_type = RARCH_SHADER_CG;
|
||||||
|
else if (video_shader_is_supported(RARCH_SHADER_SLANG))
|
||||||
|
shader_type = RARCH_SHADER_SLANG;
|
||||||
}
|
}
|
||||||
menu_shader_manager_set_preset(NULL, shader_type, NULL);
|
menu_shader_manager_set_preset(NULL, shader_type, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -293,10 +293,12 @@ bool task_push_decompress(
|
||||||
/* ZIP or APK only */
|
/* ZIP or APK only */
|
||||||
if (
|
if (
|
||||||
!filestream_exists(source_file) ||
|
!filestream_exists(source_file) ||
|
||||||
!string_is_equal_noncase(ext, "zip")
|
(
|
||||||
|
(!string_is_equal_noncase(ext, "zip"))
|
||||||
#ifdef HAVE_7ZIP
|
#ifdef HAVE_7ZIP
|
||||||
&& !string_is_equal_noncase(ext, "7z")
|
&& (!string_is_equal_noncase(ext, "7z"))
|
||||||
#endif
|
#endif
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RARCH_WARN(
|
RARCH_WARN(
|
||||||
|
|
Loading…
Reference in New Issue