Skip to content

Commit

Permalink
Use local parameters, not environment params, in the arb1/nv2 profiles.
Browse files Browse the repository at this point in the history
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).

--HG--
branch : trunk
  • Loading branch information
icculus committed Jun 25, 2008
1 parent baddd71 commit 4c59978
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions mojoshader.c
Expand Up @@ -3782,7 +3782,7 @@ static void emit_ARB1_relative(Context *ctx, int size)
{
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
Expand All @@ -3800,15 +3800,15 @@ static void emit_ARB1_uniform(Context *ctx, RegisterType regtype, int regnum)

// 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
{
// !!! FIXME: this only works if you have no bool or int uniforms.
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);
Expand Down
10 changes: 5 additions & 5 deletions mojoshader_opengl.c
Expand Up @@ -185,7 +185,7 @@ struct MOJOSHADER_glContext
PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointer;
PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB;
PFNGLPROGRAMENVPARAMETER4FVARBPROC glProgramEnvParameter4fvARB;
PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB;
PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
PFNGLBINDPROGRAMARBPROC glBindProgramARB;
Expand Down Expand Up @@ -343,7 +343,7 @@ static void lookup_entry_points(void *(*lookup)(const char *fnname))
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);
Expand Down Expand Up @@ -1421,7 +1421,7 @@ static void impl_ARB1_Uniform4fv(const MOJOSHADER_parseData *pd, GLint loc,
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,
Expand All @@ -1434,7 +1434,7 @@ static void impl_ARB1_Uniform4iv(const MOJOSHADER_parseData *pd, GLint loc,
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

Expand All @@ -1444,7 +1444,7 @@ static void impl_ARB1_Uniform1i(const MOJOSHADER_parseData *pd, GLint loc,
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)
Expand Down

0 comments on commit 4c59978

Please sign in to comment.