Use local parameters, not environment params, in the arb1/nv2 profiles. trunk
authorRyan C. Gordon <icculus@icculus.org>
Wed, 25 Jun 2008 01:27:05 -0400
branchtrunk
changeset 395 d2307cc5d6e7
parent 394 9a124083cbf2
child 396 3e9713572fa9
Use local parameters, not environment params, in the arb1/nv2 profiles. This matches the GLSL concept of "uniforms" better, but also seems to have a significantly higher upper limit of available resources on Mac OS X (1024 vs 256 on a ATI X1600 in Mac OS X 10.5.3, for example).
mojoshader.c
mojoshader_opengl.c
--- a/mojoshader.c	Wed Jun 25 00:19:32 2008 -0400
+++ b/mojoshader.c	Wed Jun 25 01:27:05 2008 -0400
@@ -3782,7 +3782,7 @@
 {
     const char *varname = get_ARB1_const_array_varname(ctx);
     push_output(ctx, &ctx->globals);
-    output_line(ctx, "PARAM %s[%d] = { program.env[0..%d] };", varname,
+    output_line(ctx, "PARAM %s[%d] = { program.local[0..%d] };", varname,
                 size, size - 1);
     pop_output(ctx);
 } // emit_ARB1_relative
@@ -3800,7 +3800,7 @@
 
         // This works everywhere.
         // !!! FIXME: does this eat more resources?
-        output_line(ctx, "PARAM %s = program.env[%d];", varname, regnum);
+        output_line(ctx, "PARAM %s = program.local[%d];", varname, regnum);
     } // if
     else
     {
@@ -3808,7 +3808,7 @@
         if (regtype != REG_TYPE_CONST)
             fail(ctx, "BUG: non-float uniforms not supported in arb1 at the moment");
         else
-            output_line(ctx, "PARAM %s = program.env[%d];", varname, regnum);
+            output_line(ctx, "PARAM %s = program.local[%d];", varname, regnum);
     } // else
 
     pop_output(ctx);
--- a/mojoshader_opengl.c	Wed Jun 25 00:19:32 2008 -0400
+++ b/mojoshader_opengl.c	Wed Jun 25 01:27:05 2008 -0400
@@ -185,7 +185,7 @@
     PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointer;
     PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
     PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB;
-    PFNGLPROGRAMENVPARAMETER4FVARBPROC glProgramEnvParameter4fvARB;
+    PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB;
     PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
     PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
     PFNGLBINDPROGRAMARBPROC glBindProgramARB;
@@ -343,7 +343,7 @@
     DO_LOOKUP(GL_ARB_vertex_program, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointer);
     DO_LOOKUP(GL_ARB_vertex_program, PFNGLGETPROGRAMIVARBPROC, glGetProgramivARB);
     DO_LOOKUP(GL_ARB_vertex_program, PFNGLGETPROGRAMSTRINGARBPROC, glGetProgramStringARB);
-    DO_LOOKUP(GL_ARB_vertex_program, PFNGLPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB);
+    DO_LOOKUP(GL_ARB_vertex_program, PFNGLPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB);
     DO_LOOKUP(GL_ARB_vertex_program, PFNGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB);
     DO_LOOKUP(GL_ARB_vertex_program, PFNGLGENPROGRAMSARBPROC, glGenProgramsARB);
     DO_LOOKUP(GL_ARB_vertex_program, PFNGLBINDPROGRAMARBPROC, glBindProgramARB);
@@ -1421,7 +1421,7 @@
     int i;
     const GLenum shader_type = arb1_shader_type(pd->shader_type);
     for (i = 0; i < siz; i++, v += 4)
-        ctx->glProgramEnvParameter4fvARB(shader_type, loc + i, v);
+        ctx->glProgramLocalParameter4fvARB(shader_type, loc + i, v);
 } // impl_ARB1_Uniform4fv
 
 static void impl_ARB1_Uniform4iv(const MOJOSHADER_parseData *pd, GLint loc,
@@ -1434,7 +1434,7 @@
         GLfloat f[4] = {
             (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]
         };
-        ctx->glProgramEnvParameter4fvARB(shader_type, loc + i, f);
+        ctx->glProgramLocalParameter4fvARB(shader_type, loc + i, f);
     } // for
 } // impl_ARB1_Uniform4iv
 
@@ -1444,7 +1444,7 @@
     const GLenum shader_type = arb1_shader_type(pd->shader_type);
     const GLfloat v = (GLfloat) _v;
     GLfloat f[4] = { v, v, v, v };
-    ctx->glProgramEnvParameter4fvARB(shader_type, loc, f);
+    ctx->glProgramLocalParameter4fvARB(shader_type, loc, f);
 } // impl_ARB1_Uniform1i
 
 static void impl_ARB1_SetSampler(GLint loc, GLuint sampler)