/*
* Mesa 3-D graphics library
- * Version: 6.5.2
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* store all the values (in blocks of 4).
*
* \param paramList the list to add the parameter to
+ * \param type type of parameter, such as
* \param name the parameter name, will be duplicated/copied!
- * \param values initial parameter value, up to 4 GLfloats
* \param size number of elements in 'values' vector (1..4, or more)
- * \param type type of parameter, such as
+ * \param values initial parameter value, up to 4 GLfloats, or NULL
+ * \param state state indexes, or NULL
* \return index of new parameter in the list, or -1 if error (out of mem)
*/
GLint
_mesa_add_parameter(struct gl_program_parameter_list *paramList,
- const char *name, const GLfloat *values, GLuint size,
- enum register_file type)
+ enum register_file type, const char *name,
+ GLuint size, const GLfloat *values,
+ const gl_state_index state[STATE_LENGTH])
{
const GLuint oldNum = paramList->NumParameters;
const GLuint sz4 = (size + 3) / 4; /* no. of new param slots needed */
}
size -= 4;
}
+
+ if (state) {
+ for (i = 0; i < STATE_LENGTH; i++)
+ paramList->Parameters[oldNum].StateIndexes[i] = state[i];
+ }
+
return (GLint) oldNum;
}
}
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4])
{
- return _mesa_add_parameter(paramList, name, values, 4, PROGRAM_NAMED_PARAM);
+ return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name,
+ 4, values, NULL);
+
}
}
#endif
size = 4; /** XXX fix */
- return _mesa_add_parameter(paramList, name, values, size, PROGRAM_CONSTANT);
+ return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name,
+ size, values, NULL);
+
}
size, &pos, &swizzle)) {
return pos;
}
- return _mesa_add_parameter(paramList, NULL, values, size, PROGRAM_CONSTANT);
+ return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL,
+ size, values, NULL);
+
}
return i;
}
else {
- i = _mesa_add_parameter(paramList, name, NULL, size, PROGRAM_UNIFORM);
+ i = _mesa_add_parameter(paramList, PROGRAM_UNIFORM, name,
+ size, NULL, NULL);
+
return i;
}
}
}
else {
const GLint size = 1;
- i = _mesa_add_parameter(paramList, name, NULL, size, PROGRAM_SAMPLER);
+ i = _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name,
+ size, NULL, NULL);
return i;
}
}
}
else {
assert(size == 4);
- i = _mesa_add_parameter(paramList, name, NULL, size, PROGRAM_VARYING);
+ i = _mesa_add_parameter(paramList, PROGRAM_VARYING, name,
+ size, NULL, NULL);
return i;
}
}
/**
* Add parameter representing a vertex program attribute.
+ * \param size size of attribute (in floats), may be -1 if unknown
+ * \param attrib the attribute index, or -1 if unknown
*/
GLint
_mesa_add_attribute(struct gl_program_parameter_list *paramList,
- const char *name, GLint attrib)
+ const char *name, GLint size, GLint attrib)
{
- GLint size = 4; /* XXX ok? */
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
if (i >= 0) {
/* replace */
ASSERT(paramList->Parameters[i].StateIndexes[0] == STATE_USER_ATTRIB);
+ if (attrib < 0)
+ attrib = i;
paramList->Parameters[i].StateIndexes[1] = attrib;
}
else {
/* add */
- i = _mesa_add_parameter(paramList, name, NULL, size, PROGRAM_INPUT);
- if (i >= 0) {
- paramList->Parameters[i].StateIndexes[0] = STATE_USER_ATTRIB;
- paramList->Parameters[i].StateIndexes[1] = attrib;
- }
+ gl_state_index state[STATE_LENGTH];
+ state[0] = STATE_USER_ATTRIB;
+ state[1] = attrib;
+ i = _mesa_add_parameter(paramList, PROGRAM_INPUT, name,
+ size, NULL, state);
}
return i;
}
* PARAM ambient = state.material.front.ambient;
*
* \param paramList the parameter list
- * \param state an array of 6 state tokens
+ * \param state an array of 6 (STATE_LENGTH) state tokens
* \return index of the new parameter.
*/
GLint
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
- const GLint *stateTokens)
+ const GLint stateTokens[STATE_LENGTH])
{
const GLuint size = 4; /* XXX fix */
const char *name;
break;
}
}
- if (match == 6) {
+ if (match == STATE_LENGTH) {
/* this state reference is already in the parameter list */
return index;
}
}
name = _mesa_program_state_string(stateTokens);
- index = _mesa_add_parameter(paramList, name, NULL, size, PROGRAM_STATE_VAR);
+ index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
+ size, NULL, NULL);
+
if (index >= 0) {
GLuint i;
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < STATE_LENGTH; i++) {
paramList->Parameters[index].StateIndexes[i]
= (gl_state_index) stateTokens[i];
}
for (i = 0; i < list->NumParameters; i++) {
struct gl_program_parameter *p = list->Parameters + i;
GLuint size = MIN2(p->Size, 4);
- GLint j = _mesa_add_parameter(clone, p->Name, list->ParameterValues[i],
- size, p->Type);
+ GLint j = _mesa_add_parameter(clone, p->Type, p->Name,
+ size, list->ParameterValues[i], NULL);
ASSERT(j >= 0);
/* copy state indexes */
if (p->Type == PROGRAM_STATE_VAR) {
GLint k;
struct gl_program_parameter *q = clone->Parameters + j;
- for (k = 0; k < 6; k++) {
+ for (k = 0; k < STATE_LENGTH; k++) {
q->StateIndexes[k] = p->StateIndexes[k];
}
}
/*
* Mesa 3-D graphics library
- * Version: 6.5.2
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#define PROG_PARAMETER_H
#include "mtypes.h"
+#include "prog_statevars.h"
/**
/**
* A sequence of STATE_* tokens and integers to identify GL state.
*/
- GLuint StateIndexes[6];
+ GLuint StateIndexes[STATE_LENGTH];
};
extern GLint
_mesa_add_parameter(struct gl_program_parameter_list *paramList,
- const char *name, const GLfloat *values, GLuint size,
- enum register_file type);
+ enum register_file type, const char *name,
+ GLuint size, const GLfloat *values,
+ const gl_state_index state[STATE_LENGTH]);
extern GLint
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
extern GLint
_mesa_add_attribute(struct gl_program_parameter_list *paramList,
- const char *name, GLint attrib);
+ const char *name, GLint size, GLint attrib);
extern GLint
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
- const GLint *stateTokens);
+ const GLint stateTokens[STATE_LENGTH]);
extern GLfloat *
_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
const char *Name;
const GLuint NumRows; /** for matrices */
const GLuint Swizzle;
- const GLint Indexes[6];
+ const GLint Indexes[STATE_LENGTH];
};
static const struct state_info state[] = {
{ "gl_ModelViewMatrix", 4, SWIZZLE_NOOP,
if (state[i].NumRows > 1) {
/* a matrix */
GLuint j;
- GLint pos[4], indexesCopy[6];
+ GLint pos[4], indexesCopy[STATE_LENGTH];
/* make copy of state tokens */
- for (j = 0; j < 6; j++)
+ for (j = 0; j < STATE_LENGTH; j++)
indexesCopy[j] = state[i].Indexes[j];
/* load rows */
for (j = 0; j < state[i].NumRows; j++) {
if (prog) {
/* user-defined vertex attribute */
const GLint size = _slang_sizeof_type_specifier(&var->type.specifier);
- GLint index = _mesa_add_parameter(prog->Attributes, varName,
- NULL, size, PROGRAM_INPUT);
+ const GLint attr = -1; /* unknown */
+ GLint index = _mesa_add_attribute(prog->Attributes, varName,
+ size, attr);
assert(index >= 0);
store = _slang_new_ir_storage(PROGRAM_INPUT,
VERT_ATTRIB_GENERIC0 + index, size);