Give shaders in Effects files a unique main function name.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 28 May 2016 22:25:43 -0400
changeset 1168 ddd9304d03a8
parent 1167 62d88009015d
child 1169 68e644e677fd
Give shaders in Effects files a unique main function name. This lets you generate Metal shaders that won't conflict in the same library.
mojoshader_effects.c
--- a/mojoshader_effects.c	Sat May 28 22:08:22 2016 -0400
+++ b/mojoshader_effects.c	Sat May 28 22:25:43 2016 -0400
@@ -622,9 +622,11 @@
         else if (object->type == MOJOSHADER_SYMTYPE_PIXELSHADER
               || object->type == MOJOSHADER_SYMTYPE_VERTEXSHADER)
         {
+            char mainfn[32];
+            snprintf(mainfn, sizeof (mainfn), "ShaderFunction%u", (unsigned int) index);
             object->shader.technique = -1;
             object->shader.pass = -1;
-            object->shader.shader = MOJOSHADER_parse(profile, NULL, *ptr, length,
+            object->shader.shader = MOJOSHADER_parse(profile, mainfn, *ptr, length,
                                                      swiz, swizcount, smap, smapcount,
                                                      m, f, d);
             // !!! FIXME: check for errors.
@@ -745,7 +747,9 @@
             } // if
             else
             {
-                object->shader.shader = MOJOSHADER_parse(emitter, NULL, *ptr, length,
+                char mainfn[32];
+                snprintf(mainfn, sizeof (mainfn), "ShaderFunction%u", (unsigned int) objectIndex);
+                object->shader.shader = MOJOSHADER_parse(emitter, mainfn, *ptr, length,
                                                          swiz, swizcount, smap, smapcount,
                                                          m, f, d);
                 // !!! FIXME: check for errors.