Run preshaders during MOJOSHADER_glProgramReady().
authorRyan C. Gordon <icculus@icculus.org>
Tue, 31 May 2011 16:25:37 -0400
changeset 1039 2f758145e80e
parent 1038 9b23f9a8aa31
child 1040 053626102255
Run preshaders during MOJOSHADER_glProgramReady().
mojoshader_opengl.c
--- a/mojoshader_opengl.c	Tue May 31 16:25:00 2011 -0400
+++ b/mojoshader_opengl.c	Tue May 31 16:25:37 2011 -0400
@@ -1826,9 +1826,32 @@
         GLfloat *dstf = program->vs_uniforms_float4;
         GLint *dsti = program->vs_uniforms_int4;
         GLint *dstb = program->vs_uniforms_bool;
+        const MOJOSHADER_preshader *preshader = NULL;
+        int ran_preshader = 0;
         uint32 i;
 
-        program->generation = ctx->generation;
+        if (program->vertex)
+        {
+            preshader = program->vertex->parseData->preshader;
+            if (preshader)
+            {
+                MOJOSHADER_runPreshader(preshader, ctx->vs_reg_file_f);
+                ran_preshader = 1;
+            } // if
+        } // if
+
+        if (program->fragment)
+        {
+            preshader = program->fragment->parseData->preshader;
+            if (preshader)
+            {
+                MOJOSHADER_runPreshader(preshader, ctx->ps_reg_file_f);
+                ran_preshader = 1;
+            } // if
+        } // if
+
+        if (ran_preshader)
+            ctx->generation++;
 
         for (i = 0; i < count; i++)
         {
@@ -1892,6 +1915,8 @@
             // !!! FIXME: set constants that overlap the array.
         } // for
 
+        program->generation = ctx->generation;
+
         ctx->profilePushUniforms();
     } // if
 } // MOJOSHADER_glProgramReady