Skip to content

Commit

Permalink
Logic bug: could hit else condition when we didn't want to.
Browse files Browse the repository at this point in the history
Fixes assertion failure for constant arrays.

--HG--
branch : trunk
  • Loading branch information
icculus committed Aug 4, 2008
1 parent ce14b9d commit cd4bb85
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions mojoshader_opengl.c
Expand Up @@ -1140,16 +1140,20 @@ static void lookup_uniforms(MOJOSHADER_glProgram *program,
if (loc != -1) // maybe the Uniform was optimized out?
{
// only do constants once, at link time. These aren't changed ever.
if ( (u->constant) && (ctx->profileMustLoadConstantArrays()) )
if (u->constant)
{
const int base = u->index;
const int size = u->array_count;
GLfloat *f = (GLfloat *) alloca(sizeof (GLfloat) * size * 4);
fill_constant_array(f, base, size, pd);
ctx->profileUseProgramObject(program);
ctx->profileUniform4fv(pd, loc, size, f);
ctx->profileUseProgramObject(ctx->bound_program);
if (ctx->profileMustLoadConstantArrays())
{
const int base = u->index;
const int size = u->array_count;
GLfloat *f = (GLfloat *) alloca(sizeof (GLfloat)*(size*4));
fill_constant_array(f, base, size, pd);
ctx->profileUseProgramObject(program);
ctx->profileUniform4fv(pd, loc, size, f);
ctx->profileUseProgramObject(ctx->bound_program);
} // if
} // if

else
{
UniformMap *map = &program->uniforms[program->uniform_count];
Expand Down

0 comments on commit cd4bb85

Please sign in to comment.