summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-09-15 09:45:18 -0600
committerBrian Paul <[email protected]>2009-09-15 09:45:18 -0600
commit5d526ed21ac9f1ec9220c2adb4c905893eb9d990 (patch)
tree2e9c6b0794d903aa9c137d591f956619a51608d7 /src/mesa/shader/slang
parent2b992dc327e02a412c0cc8c5d015ac534114848c (diff)
parent799631acb18be93afab29e27241cde3780672e98 (diff)
Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_link.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 169c07f8cea..8f2b40d5dfb 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -546,6 +546,32 @@ _slang_update_inputs_outputs(struct gl_program *prog)
+/**
+ * Remove extra #version directives from the concatenated source string.
+ * Disable the extra ones by converting first two chars to //, a comment.
+ * This is a bit of hack to work around a preprocessor bug that only
+ * allows one #version directive per source.
+ */
+static void
+remove_extra_version_directives(GLchar *source)
+{
+ GLuint verCount = 0;
+ while (1) {
+ char *ver = _mesa_strstr(source, "#version");
+ if (ver) {
+ verCount++;
+ if (verCount > 1) {
+ ver[0] = '/';
+ ver[1] = '/';
+ }
+ source += 8;
+ }
+ else {
+ break;
+ }
+ }
+}
+
/**
@@ -593,6 +619,8 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
_mesa_printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source);
*/
+ remove_extra_version_directives(source);
+
newShader = CALLOC_STRUCT(gl_shader);
newShader->Type = shaderType;
newShader->Source = source;