Skip to content

Commit

Permalink
Give shaders in Effects files a unique main function name.
Browse files Browse the repository at this point in the history
This lets you generate Metal shaders that won't conflict in the same library.
  • Loading branch information
icculus committed May 29, 2016
1 parent 8f24a1d commit 570666a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mojoshader_effects.c
Expand Up @@ -622,9 +622,11 @@ static void readsmallobjects(const uint32 numsmallobjects,
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.
Expand Down Expand Up @@ -745,7 +747,9 @@ static void readlargeobjects(const uint32 numlargeobjects,
} // 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.
Expand Down

0 comments on commit 570666a

Please sign in to comment.