Make the bool register file uint8, instead of GLint. Saves 12k of memory.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 13 Aug 2009 21:41:04 -0400
changeset 772 6ada59b8559a
parent 771 91888f4b8772
child 773 3e3638be6e2b
Make the bool register file uint8, instead of GLint. Saves 12k of memory.
mojoshader_opengl.c
--- a/mojoshader_opengl.c	Sun Aug 09 15:04:26 2009 -0400
+++ b/mojoshader_opengl.c	Thu Aug 13 21:41:04 2009 -0400
@@ -116,10 +116,10 @@
     // Man, it kills me how much memory this takes...
     GLfloat vs_reg_file_f[8192 * 4];
     GLint vs_reg_file_i[2047 * 4];
-    GLint vs_reg_file_b[2047];
+    uint8 vs_reg_file_b[2047];
     GLfloat ps_reg_file_f[8192 * 4];
     GLint ps_reg_file_i[2047 * 4];
-    GLint ps_reg_file_b[2047];
+    uint8 ps_reg_file_b[2047];
     GLuint sampler_reg_file[16];
 
     // GL stuff...
@@ -1615,8 +1615,8 @@
     const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_f) / 4;
     if (idx < maxregs)
     {
-        GLint *wptr = ctx->vs_reg_file_b + idx;
-        GLint *endptr = wptr + minuint(maxregs - idx, bcount);
+        uint8 *wptr = ctx->vs_reg_file_b + idx;
+        uint8 *endptr = wptr + minuint(maxregs - idx, bcount);
         while (wptr != endptr)
             *(wptr++) = *(data++) ? 1 : 0;
     } // if
@@ -1655,8 +1655,8 @@
     const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_f) / 4;
     if (idx < maxregs)
     {
-        GLint *wptr = ctx->ps_reg_file_b + idx;
-        GLint *endptr = wptr + minuint(maxregs - idx, bcount);
+        uint8 *wptr = ctx->ps_reg_file_b + idx;
+        uint8 *endptr = wptr + minuint(maxregs - idx, bcount);
         while (wptr != endptr)
             *(wptr++) = *(data++) ? 1 : 0;
     } // if
@@ -1746,7 +1746,7 @@
         const uint32 count = program->uniform_count;
         const GLfloat *srcf = ctx->vs_reg_file_f;
         const GLint *srci = ctx->vs_reg_file_i;
-        const GLint *srcb = ctx->vs_reg_file_b;
+        const uint8 *srcb = ctx->vs_reg_file_b;
         MOJOSHADER_shaderType shader_type = MOJOSHADER_TYPE_VERTEX;
         GLfloat *dstf = program->vs_uniforms_float4;
         GLint *dsti = program->vs_uniforms_int4;
@@ -1805,8 +1805,10 @@
             else if (type == MOJOSHADER_UNIFORM_BOOL)
             {
                 const size_t count = size;
-                const GLint *b = &srcb[index];
-                memcpy(dstb, b, sizeof (GLint) * count);
+                const uint8 *b = &srcb[index];
+                int i;
+                for (i = 0; i < count; i++)
+                    dstb[i] = (GLint) b[i];
                 dstb += count;
             } // else if