Mesa (mesa_7_4_branch): mesa: in mesa_add_named_constant(), avoid adding duplicate constants
Brian Paul
brianp at kemper.freedesktop.org
Tue Apr 7 14:37:40 UTC 2009
Module: Mesa
Branch: mesa_7_4_branch
Commit: 5c47d53924842e2389c31ac0f08f6cff68a9fd3b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c47d53924842e2389c31ac0f08f6cff68a9fd3b
Author: Brian Paul <brianp at vmware.com>
Date: Fri Apr 3 15:42:14 2009 -0600
mesa: in mesa_add_named_constant(), avoid adding duplicate constants
(cherry picked from master, commit 80197a0c1bec48e3731bca975ec451d96f35f62a)
---
src/mesa/shader/prog_parameter.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c
index dc48e84..b8202b5 100644
--- a/src/mesa/shader/prog_parameter.c
+++ b/src/mesa/shader/prog_parameter.c
@@ -178,15 +178,20 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4],
GLuint size)
{
-#if 0 /* disable this for now -- we need to save the name! */
+ /* first check if this is a duplicate constant */
GLint pos;
- GLuint swizzle;
- ASSERT(size == 4); /* XXX future feature */
- /* check if we already have this constant */
- if (_mesa_lookup_parameter_constant(paramList, values, 4, &pos, &swizzle)) {
- return pos;
+ for (pos = 0; pos < paramList->NumParameters; pos++) {
+ const GLfloat *pvals = paramList->ParameterValues[pos];
+ if (pvals[0] == values[0] &&
+ pvals[1] == values[1] &&
+ pvals[2] == values[2] &&
+ pvals[3] == values[3] &&
+ _mesa_strcmp(paramList->Parameters[pos].Name, name) == 0) {
+ /* Same name and value is already in the param list - reuse it */
+ return pos;
+ }
}
-#endif
+ /* not found, add new parameter */
return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name,
size, GL_NONE, values, NULL, 0x0);
}
More information about the mesa-commit
mailing list