Skip to content

Instantly share code, notes, and snippets.

@Themaister
Created January 26, 2016 19:08
Show Gist options
  • Save Themaister/78eef68eed974ade585f to your computer and use it in GitHub Desktop.
Save Themaister/78eef68eed974ade585f to your computer and use it in GitHub Desktop.
From 429188faf002ec326593bde627e9660943113896 Mon Sep 17 00:00:00 2001
From: Hans-Kristian Arntzen <[email protected]>
Date: Tue, 26 Jan 2016 20:07:26 +0100
Subject: [PATCH] Strip lines with #pragma parameter.
It's not valid GLSL to have quotes in them, and it's meaningless
to pass in the #pragmas to the driver.
---
gfx/drivers_shader/shader_glsl.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c
index 2c47098..2a1aeef 100644
--- a/gfx/drivers_shader/shader_glsl.c
+++ b/gfx/drivers_shader/shader_glsl.c
@@ -442,6 +442,21 @@ static GLuint gl_glsl_compile_program(glsl_shader_data_t *glsl,
return prog;
}
+static void gl_glsl_strip_parameter_pragmas(char *source)
+{
+ /* #pragma parameter lines tend to have " characters in them, which is not legal GLSL. */
+ char *s = strstr(source, "#pragma parameter");
+ while (s)
+ {
+ /* #pragmas have to be on a single line,
+ * so we can just replace the entire line with spaces.
+ */
+ while (*s != '\0' && *s != '\n')
+ *s++ = ' ';
+ s = strstr(s, "#pragma parameter");
+ }
+}
+
static bool gl_glsl_load_source_path(struct video_shader_pass *pass,
const char *path)
{
@@ -450,6 +465,7 @@ static bool gl_glsl_load_source_path(struct video_shader_pass *pass,
if (!ret || len <= 0)
return false;
+ gl_glsl_strip_parameter_pragmas(pass->source.string.vertex);
pass->source.string.fragment = strdup(pass->source.string.vertex);
return pass->source.string.fragment && pass->source.string.vertex;
}
--
2.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment