mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 18:40:49 +00:00
Simplified parameter parsing to have all shader formats use the same slang method
(when HAVE_SLANG and HAVE_SPIRV_CROSS are defined) - backport of HyperSpaceMadness' PR
This commit is contained in:
parent
42f66adbf2
commit
d60d320e76
@ -150,9 +150,9 @@ bool glslang_read_shader_file(const char *path,
|
||||
if (lines.size < 1)
|
||||
goto error;
|
||||
|
||||
/* If this is the 'parent' shader file, ensure that first
|
||||
* line is a 'VERSION' string */
|
||||
if (root_file)
|
||||
/* If this is the 'parent' shader file and a slang file,
|
||||
* ensure that first line is a 'VERSION' string */
|
||||
if (root_file && string_is_equal(path_get_extension(path), "slang"))
|
||||
{
|
||||
const char *line = lines.elems[0].data;
|
||||
|
||||
|
@ -120,6 +120,14 @@ const char *glslang_format_to_string(glslang_format fmt);
|
||||
|
||||
enum glslang_format glslang_find_format(const char *fmt);
|
||||
|
||||
/* Reads a shader file and outputs its contents as a string list.
|
||||
Takes the path of the shader file and appends each line of the file
|
||||
to the output string list.
|
||||
If the root_file argument is set to true, it expects the first line of the file
|
||||
to be a valid '#version' string
|
||||
Handles '#include' statements by recursively parsing included files and appending their contents.
|
||||
Returns a Bool indicating if parsing was successful.
|
||||
*/
|
||||
bool glslang_read_shader_file(const char *path,
|
||||
struct string_list *output, bool root_file);
|
||||
|
||||
|
@ -870,28 +870,15 @@ void video_shader_resolve_parameters(struct video_shader *shader)
|
||||
uint8_t *buf = NULL;
|
||||
int64_t buf_len = 0;
|
||||
|
||||
if (string_is_empty(path))
|
||||
if (string_is_empty(path) || !path_is_valid(path))
|
||||
continue;
|
||||
|
||||
if (!path_is_valid(path))
|
||||
continue;
|
||||
|
||||
/* First try to use the more robust slang implementation
|
||||
* to support #includes. */
|
||||
|
||||
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
||||
/* FIXME: The check for slang can be removed
|
||||
* if it's sufficiently tested for GLSL/Cg as well,
|
||||
* it should be the same implementation.
|
||||
* The problem with switching currently is that it looks
|
||||
* for a #version string in the first line of the file
|
||||
* which glsl doesn't have */
|
||||
|
||||
if ( string_is_equal(path_get_extension(path), "slang")
|
||||
&& slang_preprocess_parse_parameters(path, shader))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
/* Now uses the same slang parsing for parameters since
|
||||
* it should be the same implementation, but supporting
|
||||
* #include directives */
|
||||
slang_preprocess_parse_parameters(path, shader);
|
||||
#else
|
||||
/* Read file contents */
|
||||
if (filestream_read_file(path, (void**)&buf, &buf_len))
|
||||
{
|
||||
@ -956,6 +943,7 @@ void video_shader_resolve_parameters(struct video_shader *shader)
|
||||
|
||||
string_list_deinitialize(&lines);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user