mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +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)
|
if (lines.size < 1)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* If this is the 'parent' shader file, ensure that first
|
/* If this is the 'parent' shader file and a slang file,
|
||||||
* line is a 'VERSION' string */
|
* ensure that first line is a 'VERSION' string */
|
||||||
if (root_file)
|
if (root_file && string_is_equal(path_get_extension(path), "slang"))
|
||||||
{
|
{
|
||||||
const char *line = lines.elems[0].data;
|
const char *line = lines.elems[0].data;
|
||||||
|
|
||||||
@ -166,9 +166,9 @@ bool glslang_read_shader_file(const char *path,
|
|||||||
if (!string_list_append(output, line, attr))
|
if (!string_list_append(output, line, attr))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Allows us to use #line to make dealing with shader
|
/* Allows us to use #line to make dealing with shader
|
||||||
* errors easier.
|
* errors easier.
|
||||||
* This is supported by glslang, but since we always
|
* This is supported by glslang, but since we always
|
||||||
* use glslang statically, this is fine. */
|
* use glslang statically, this is fine. */
|
||||||
if (!string_list_append(output,
|
if (!string_list_append(output,
|
||||||
"#extension GL_GOOGLE_cpp_style_line_directive : require",
|
"#extension GL_GOOGLE_cpp_style_line_directive : require",
|
||||||
|
@ -120,6 +120,14 @@ const char *glslang_format_to_string(glslang_format fmt);
|
|||||||
|
|
||||||
enum glslang_format glslang_find_format(const char *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,
|
bool glslang_read_shader_file(const char *path,
|
||||||
struct string_list *output, bool root_file);
|
struct string_list *output, bool root_file);
|
||||||
|
|
||||||
|
@ -870,28 +870,15 @@ void video_shader_resolve_parameters(struct video_shader *shader)
|
|||||||
uint8_t *buf = NULL;
|
uint8_t *buf = NULL;
|
||||||
int64_t buf_len = 0;
|
int64_t buf_len = 0;
|
||||||
|
|
||||||
if (string_is_empty(path))
|
if (string_is_empty(path) || !path_is_valid(path))
|
||||||
continue;
|
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)
|
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
||||||
/* FIXME: The check for slang can be removed
|
/* Now uses the same slang parsing for parameters since
|
||||||
* if it's sufficiently tested for GLSL/Cg as well,
|
* it should be the same implementation, but supporting
|
||||||
* it should be the same implementation.
|
* #include directives */
|
||||||
* The problem with switching currently is that it looks
|
slang_preprocess_parse_parameters(path, shader);
|
||||||
* for a #version string in the first line of the file
|
#else
|
||||||
* which glsl doesn't have */
|
|
||||||
|
|
||||||
if ( string_is_equal(path_get_extension(path), "slang")
|
|
||||||
&& slang_preprocess_parse_parameters(path, shader))
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read file contents */
|
/* Read file contents */
|
||||||
if (filestream_read_file(path, (void**)&buf, &buf_len))
|
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);
|
string_list_deinitialize(&lines);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user