# HG changeset patch # User Ryan C. Gordon # Date 1209533746 14400 # Node ID 796394130035f3ca914691f96853c5e50e49b145 # Parent 13184ff204b95fdd196250e45982711593507c95 Fixed logic bug in uniform setting. Should have chosen the MINIMUM value, not the maximum. diff -r 13184ff204b9 -r 796394130035 mojoshader_opengl.c --- a/mojoshader_opengl.c Wed Apr 30 01:22:45 2008 -0400 +++ b/mojoshader_opengl.c Wed Apr 30 01:35:46 2008 -0400 @@ -609,10 +609,10 @@ } // MOJOSHADER_glBindProgram -static inline uint maxuint(const uint a, const uint b) +static inline uint minuint(const uint a, const uint b) { - return ((a > b) ? a : b); -} // maxuint + return ((a < b) ? a : b); +} // minuint void MOJOSHADER_glSetVertexShaderUniformF(unsigned int idx, const float *data, @@ -622,7 +622,7 @@ if (idx < maxregs) { assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (maxuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; + const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; memcpy(ctx->vs_reg_file_f + (idx * 4), data, cpy); } // if } // MOJOSHADER_glSetVertexShaderUniformF @@ -635,7 +635,7 @@ if (idx < maxregs) { assert(sizeof (GLint) == sizeof (int)); - const uint cpy = (maxuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; + const uint cpy = (minuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; memcpy(ctx->vs_reg_file_i + (idx * 4), data, cpy); } // if } // MOJOSHADER_glSetVertexShaderUniformI @@ -648,7 +648,7 @@ if (idx < maxregs) { GLint *wptr = ctx->vs_reg_file_b + idx; - GLint *endptr = wptr + maxuint(maxregs - idx, bcount); + GLint *endptr = wptr + minuint(maxregs - idx, bcount); while (wptr != endptr) *(wptr++) = *(data++) ? 1 : 0; } // if @@ -662,7 +662,7 @@ if (idx < maxregs) { assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (maxuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; + const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; memcpy(ctx->ps_reg_file_f + (idx * 4), data, cpy); } // if } // MOJOSHADER_glSetPixelShaderUniformF @@ -675,7 +675,7 @@ if (idx < maxregs) { assert(sizeof (GLint) == sizeof (int)); - const uint cpy = (maxuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; + const uint cpy = (minuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; memcpy(ctx->ps_reg_file_i + (idx * 4), data, cpy); } // if } // MOJOSHADER_glSetPixelShaderUniformI @@ -688,7 +688,7 @@ if (idx < maxregs) { GLint *wptr = ctx->ps_reg_file_b + idx; - GLint *endptr = wptr + maxuint(maxregs - idx, bcount); + GLint *endptr = wptr + minuint(maxregs - idx, bcount); while (wptr != endptr) *(wptr++) = *(data++) ? 1 : 0; } // if