aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/prog_parameter.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-05-20 10:59:18 -0600
committerBrian Paul <[email protected]>2008-05-20 10:59:18 -0600
commitb6fb0940c226373ac235a5d327d3fcfd742bc6b9 (patch)
treee7b3b55eb59eacc3128677f58c7d93a9fe8e0657 /src/mesa/shader/prog_parameter.c
parentc6b36e5498cf6593daf001123cacec4ccaf305ca (diff)
fix incorrect sampler numbering/indexing.
All samplers indexes were zero.
Diffstat (limited to 'src/mesa/shader/prog_parameter.c')
-rw-r--r--src/mesa/shader/prog_parameter.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c
index 0b61bac6961..75cf5023df1 100644
--- a/src/mesa/shader/prog_parameter.c
+++ b/src/mesa/shader/prog_parameter.c
@@ -283,25 +283,31 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList,
* \param name uniform's name
* \param datatype GL_SAMPLER_2D, GL_SAMPLER_2D_RECT_ARB, etc.
* \param index the sampler number (as seen in TEX instructions)
+ * \return sampler index (starting at zero) or -1 if error
*/
GLint
_mesa_add_sampler(struct gl_program_parameter_list *paramList,
- const char *name, GLenum datatype, GLuint index)
+ const char *name, GLenum datatype)
{
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) {
ASSERT(paramList->Parameters[i].Size == 1);
ASSERT(paramList->Parameters[i].DataType == datatype);
- ASSERT(paramList->ParameterValues[i][0] == index);
/* already in list */
- return i;
+ return (GLint) paramList->ParameterValues[i][0];
}
else {
- GLfloat indexf = index;
const GLint size = 1; /* a sampler is basically a texture unit number */
- i = _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name,
- size, datatype, &indexf, NULL);
- return i;
+ GLfloat value;
+ GLint numSamplers = 0;
+ for (i = 0; i < paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Type == PROGRAM_SAMPLER)
+ numSamplers++;
+ }
+ value = (GLfloat) numSamplers;
+ (void) _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name,
+ size, datatype, &value, NULL);
+ return numSamplers;
}
}