mesa: support boolean and integer-based parameters in prog_parameter

The functionality is not used by anything yet, and the glUniform functions will
need to be reworked before this can reach its full usefulness.  It is
nonetheless a step towards integer support in the state tracker and classic drivers.
This commit is contained in:
Bryan Cain
2011-05-17 17:13:20 -05:00
parent 17b695e6e7
commit 6d89abadbc
13 changed files with 88 additions and 66 deletions

View File

@@ -875,7 +875,8 @@ static struct ureg register_const4f( struct texenv_fragment_program *p,
values[1] = s1; values[1] = s1;
values[2] = s2; values[2] = s2;
values[3] = s3; values[3] = s3;
idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, idx = _mesa_add_unnamed_constant( p->program->Base.Parameters,
(gl_constant_value *) values, 4,
&swizzle ); &swizzle );
r = make_ureg(PROGRAM_CONSTANT, idx); r = make_ureg(PROGRAM_CONSTANT, idx);
r.swz = swizzle; r.swz = swizzle;

View File

@@ -455,13 +455,13 @@ static struct ureg register_const4f( struct tnl_program *p,
GLfloat s2, GLfloat s2,
GLfloat s3) GLfloat s3)
{ {
GLfloat values[4]; gl_constant_value values[4];
GLint idx; GLint idx;
GLuint swizzle; GLuint swizzle;
values[0] = s0; values[0].f = s0;
values[1] = s1; values[1].f = s1;
values[2] = s2; values[2].f = s2;
values[3] = s3; values[3].f = s3;
idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
&swizzle ); &swizzle );
ASSERT(swizzle == SWIZZLE_NOOP); ASSERT(swizzle == SWIZZLE_NOOP);

View File

@@ -429,7 +429,7 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
for (i = 0; i < rows; i++) { for (i = 0; i < rows; i++) {
const int base = paramPos + offset + i; const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) { for (j = 0; j < cols; j++ ) {
params[k++] = prog->Parameters->ParameterValues[base][j]; params[k++] = prog->Parameters->ParameterValues[base][j].f;
} }
} }
} }
@@ -442,7 +442,7 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
const int base = paramPos + offset + i; const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) { for (j = 0; j < cols; j++ ) {
params[k++] = (GLdouble) params[k++] = (GLdouble)
prog->Parameters->ParameterValues[base][j]; prog->Parameters->ParameterValues[base][j].f;
} }
} }
} }
@@ -455,7 +455,7 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
const int base = paramPos + offset + i; const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) { for (j = 0; j < cols; j++ ) {
params[k++] = (GLint) params[k++] = (GLint)
prog->Parameters->ParameterValues[base][j]; prog->Parameters->ParameterValues[base][j].f;
} }
} }
} }
@@ -468,7 +468,7 @@ get_uniform(struct gl_context *ctx, GLuint program, GLint location,
const int base = paramPos + offset + i; const int base = paramPos + offset + i;
for (j = 0; j < cols; j++ ) { for (j = 0; j < cols; j++ ) {
params[k++] = (GLuint) params[k++] = (GLuint)
prog->Parameters->ParameterValues[base][j]; prog->Parameters->ParameterValues[base][j].f;
} }
} }
} }
@@ -670,7 +670,7 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
/* loop over number of samplers to change */ /* loop over number of samplers to change */
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
GLuint sampler = (GLuint) GLuint sampler = (GLuint)
program->Parameters->ParameterValues[index + offset + i][0]; program->Parameters->ParameterValues[index+offset + i][0].f;
GLuint texUnit = ((GLuint *) values)[i]; GLuint texUnit = ((GLuint *) values)[i];
/* check that the sampler (tex unit index) is legal */ /* check that the sampler (tex unit index) is legal */
@@ -936,7 +936,7 @@ set_program_uniform_matrix(struct gl_context *ctx, struct gl_program *program,
/* Ignore writes beyond the end of (the used part of) an array */ /* Ignore writes beyond the end of (the used part of) an array */
return; return;
} }
v = program->Parameters->ParameterValues[index + offset]; v = (GLfloat *) program->Parameters->ParameterValues[index + offset];
for (row = 0; row < rows; row++) { for (row = 0; row < rows; row++) {
if (transpose) { if (transpose) {
v[row] = values[src + row * cols + col]; v[row] = values[src + row * cols + col];

View File

@@ -599,7 +599,7 @@ ir_to_mesa_visitor::src_reg_for_float(float val)
src_reg src(PROGRAM_CONSTANT, -1, NULL); src_reg src(PROGRAM_CONSTANT, -1, NULL);
src.index = _mesa_add_unnamed_constant(this->prog->Parameters, src.index = _mesa_add_unnamed_constant(this->prog->Parameters,
&val, 1, &src.swizzle); (const gl_constant_value *)&val, 1, &src.swizzle);
return src; return src;
} }
@@ -1798,7 +1798,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir)
src = src_reg(PROGRAM_CONSTANT, -1, NULL); src = src_reg(PROGRAM_CONSTANT, -1, NULL);
src.index = _mesa_add_unnamed_constant(this->prog->Parameters, src.index = _mesa_add_unnamed_constant(this->prog->Parameters,
values, (gl_constant_value *) values,
ir->type->vector_elements, ir->type->vector_elements,
&src.swizzle); &src.swizzle);
emit(ir, OPCODE_MOV, mat_column, src); emit(ir, OPCODE_MOV, mat_column, src);
@@ -1836,7 +1836,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir)
this->result = src_reg(PROGRAM_CONSTANT, -1, ir->type); this->result = src_reg(PROGRAM_CONSTANT, -1, ir->type);
this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters, this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters,
values, (gl_constant_value *) values,
ir->type->vector_elements, ir->type->vector_elements,
&this->result.swizzle); &this->result.swizzle);
} }
@@ -2533,7 +2533,7 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program,
*/ */
if (file == PROGRAM_SAMPLER) { if (file == PROGRAM_SAMPLER) {
for (unsigned int j = 0; j < size / 4; j++) for (unsigned int j = 0; j < size / 4; j++)
prog->Parameters->ParameterValues[index + j][0] = next_sampler++; prog->Parameters->ParameterValues[index + j][0].f = next_sampler++;
} }
/* The location chosen in the Parameters list here (returned /* The location chosen in the Parameters list here (returned

View File

@@ -472,8 +472,9 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number)
const GLfloat *constant; const GLfloat *constant;
if (!Parse_Identifier(parseState, ident)) if (!Parse_Identifier(parseState, ident))
RETURN_ERROR1("Expected an identifier"); RETURN_ERROR1("Expected an identifier");
constant = _mesa_lookup_parameter_value(parseState->parameters, constant = (GLfloat *)_mesa_lookup_parameter_value(parseState->parameters,
-1, (const char *) ident); -1,
(const char *) ident);
/* XXX Check that it's a constant and not a parameter */ /* XXX Check that it's a constant and not a parameter */
if (!constant) { if (!constant) {
RETURN_ERROR1("Undefined symbol"); RETURN_ERROR1("Undefined symbol");
@@ -1039,7 +1040,8 @@ Parse_VectorSrc(struct parse_state *parseState,
if (!Parse_ScalarConstant(parseState, values)) if (!Parse_ScalarConstant(parseState, values))
RETURN_ERROR; RETURN_ERROR;
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
values, 4, NULL); (gl_constant_value *) values,
4, NULL);
srcReg->File = PROGRAM_NAMED_PARAM; srcReg->File = PROGRAM_NAMED_PARAM;
srcReg->Index = paramIndex; srcReg->Index = paramIndex;
} }
@@ -1051,7 +1053,8 @@ Parse_VectorSrc(struct parse_state *parseState,
if (!Parse_VectorConstant(parseState, values)) if (!Parse_VectorConstant(parseState, values))
RETURN_ERROR; RETURN_ERROR;
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
values, 4, NULL); (gl_constant_value *) values,
4, NULL);
srcReg->File = PROGRAM_NAMED_PARAM; srcReg->File = PROGRAM_NAMED_PARAM;
srcReg->Index = paramIndex; srcReg->Index = paramIndex;
} }
@@ -1145,7 +1148,8 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
if (!Parse_VectorConstant(parseState, values)) if (!Parse_VectorConstant(parseState, values))
RETURN_ERROR; RETURN_ERROR;
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
values, 4, NULL); (gl_constant_value *) values,
4, NULL);
srcReg->File = PROGRAM_NAMED_PARAM; srcReg->File = PROGRAM_NAMED_PARAM;
srcReg->Index = paramIndex; srcReg->Index = paramIndex;
} }
@@ -1170,7 +1174,8 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
if (!Parse_ScalarConstant(parseState, values)) if (!Parse_ScalarConstant(parseState, values))
RETURN_ERROR; RETURN_ERROR;
paramIndex = _mesa_add_unnamed_constant(parseState->parameters, paramIndex = _mesa_add_unnamed_constant(parseState->parameters,
values, 4, NULL); (gl_constant_value *) values,
4, NULL);
srcReg->Index = paramIndex; srcReg->Index = paramIndex;
srcReg->File = PROGRAM_NAMED_PARAM; srcReg->File = PROGRAM_NAMED_PARAM;
needSuffix = GL_FALSE; needSuffix = GL_FALSE;
@@ -1296,7 +1301,8 @@ Parse_InstructionSequence(struct parse_state *parseState,
RETURN_ERROR2(id, "already defined"); RETURN_ERROR2(id, "already defined");
} }
_mesa_add_named_parameter(parseState->parameters, _mesa_add_named_parameter(parseState->parameters,
(const char *) id, value); (const char *) id,
(gl_constant_value *) value);
} }
else if (Parse_String(parseState, "DECLARE")) { else if (Parse_String(parseState, "DECLARE")) {
GLubyte id[100]; GLubyte id[100];
@@ -1315,7 +1321,8 @@ Parse_InstructionSequence(struct parse_state *parseState,
RETURN_ERROR2(id, "already declared"); RETURN_ERROR2(id, "already declared");
} }
_mesa_add_named_parameter(parseState->parameters, _mesa_add_named_parameter(parseState->parameters,
(const char *) id, value); (const char *) id,
(gl_constant_value *) value);
} }
else if (Parse_String(parseState, "END")) { else if (Parse_String(parseState, "END")) {
inst->Opcode = OPCODE_END; inst->Opcode = OPCODE_END;

View File

@@ -157,7 +157,7 @@ get_src_register_pointer(const struct prog_src_register *source,
case PROGRAM_NAMED_PARAM: case PROGRAM_NAMED_PARAM:
if (reg >= (GLint) prog->Parameters->NumParameters) if (reg >= (GLint) prog->Parameters->NumParameters)
return ZeroVec; return ZeroVec;
return prog->Parameters->ParameterValues[reg]; return (GLfloat *) prog->Parameters->ParameterValues[reg];
case PROGRAM_SYSTEM_VALUE: case PROGRAM_SYSTEM_VALUE:
assert(reg < Elements(machine->SystemValues)); assert(reg < Elements(machine->SystemValues));

View File

@@ -56,8 +56,8 @@ _mesa_new_parameter_list_sized(unsigned size)
p->Parameters = (struct gl_program_parameter *) p->Parameters = (struct gl_program_parameter *)
calloc(1, size * sizeof(struct gl_program_parameter)); calloc(1, size * sizeof(struct gl_program_parameter));
p->ParameterValues = (GLfloat (*)[4]) p->ParameterValues = (gl_constant_value (*)[4])
_mesa_align_malloc(size * 4 *sizeof(GLfloat), 16); _mesa_align_malloc(size * 4 *sizeof(gl_constant_value), 16);
if ((p->Parameters == NULL) || (p->ParameterValues == NULL)) { if ((p->Parameters == NULL) || (p->ParameterValues == NULL)) {
@@ -101,14 +101,15 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
* \param name the parameter name, will be duplicated/copied! * \param name the parameter name, will be duplicated/copied!
* \param size number of elements in 'values' vector (1..4, or more) * \param size number of elements in 'values' vector (1..4, or more)
* \param datatype GL_FLOAT, GL_FLOAT_VECx, GL_INT, GL_INT_VECx or GL_NONE. * \param datatype GL_FLOAT, GL_FLOAT_VECx, GL_INT, GL_INT_VECx or GL_NONE.
* \param values initial parameter value, up to 4 GLfloats, or NULL * \param values initial parameter value, up to 4 gl_constant_values, or NULL
* \param state state indexes, or NULL * \param state state indexes, or NULL
* \return index of new parameter in the list, or -1 if error (out of mem) * \return index of new parameter in the list, or -1 if error (out of mem)
*/ */
GLint GLint
_mesa_add_parameter(struct gl_program_parameter_list *paramList, _mesa_add_parameter(struct gl_program_parameter_list *paramList,
gl_register_file type, const char *name, gl_register_file type, const char *name,
GLuint size, GLenum datatype, const GLfloat *values, GLuint size, GLenum datatype,
const gl_constant_value *values,
const gl_state_index state[STATE_LENGTH], const gl_state_index state[STATE_LENGTH],
GLbitfield flags) GLbitfield flags)
{ {
@@ -127,10 +128,10 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
oldNum * sizeof(struct gl_program_parameter), oldNum * sizeof(struct gl_program_parameter),
paramList->Size * sizeof(struct gl_program_parameter)); paramList->Size * sizeof(struct gl_program_parameter));
paramList->ParameterValues = (GLfloat (*)[4]) paramList->ParameterValues = (gl_constant_value (*)[4])
_mesa_align_realloc(paramList->ParameterValues, /* old buf */ _mesa_align_realloc(paramList->ParameterValues, /* old buf */
oldNum * 4 * sizeof(GLfloat), /* old size */ oldNum * 4 * sizeof(gl_constant_value),/* old sz */
paramList->Size * 4 *sizeof(GLfloat), /* new sz */ paramList->Size*4*sizeof(gl_constant_value),/*new*/
16); 16);
} }
@@ -142,7 +143,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
return -1; return -1;
} }
else { else {
GLuint i; GLuint i, j;
paramList->NumParameters = oldNum + sz4; paramList->NumParameters = oldNum + sz4;
@@ -163,7 +164,8 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
} }
else { else {
/* silence valgrind */ /* silence valgrind */
ASSIGN_4V(paramList->ParameterValues[oldNum + i], 0, 0, 0, 0); for (j = 0; j < 4; j++)
paramList->ParameterValues[oldNum + i][j].f = 0;
} }
size -= 4; size -= 4;
} }
@@ -184,7 +186,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
*/ */
GLint GLint
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList, _mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4]) const char *name, const gl_constant_value values[4])
{ {
return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name, return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name,
4, GL_NONE, values, NULL, 0x0); 4, GL_NONE, values, NULL, 0x0);
@@ -204,17 +206,17 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
*/ */
GLint GLint
_mesa_add_named_constant(struct gl_program_parameter_list *paramList, _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4], const char *name, const gl_constant_value values[4],
GLuint size) GLuint size)
{ {
/* first check if this is a duplicate constant */ /* first check if this is a duplicate constant */
GLint pos; GLint pos;
for (pos = 0; pos < (GLint)paramList->NumParameters; pos++) { for (pos = 0; pos < (GLint)paramList->NumParameters; pos++) {
const GLfloat *pvals = paramList->ParameterValues[pos]; const gl_constant_value *pvals = paramList->ParameterValues[pos];
if (pvals[0] == values[0] && if (pvals[0].u == values[0].u &&
pvals[1] == values[1] && pvals[1].u == values[1].u &&
pvals[2] == values[2] && pvals[2].u == values[2].u &&
pvals[3] == values[3] && pvals[3].u == values[3].u &&
strcmp(paramList->Parameters[pos].Name, name) == 0) { strcmp(paramList->Parameters[pos].Name, name) == 0) {
/* Same name and value is already in the param list - reuse it */ /* Same name and value is already in the param list - reuse it */
return pos; return pos;
@@ -240,7 +242,7 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
*/ */
GLint GLint
_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
const GLfloat values[4], GLuint size, const gl_constant_value values[4], GLuint size,
GLuint *swizzleOut) GLuint *swizzleOut)
{ {
GLint pos; GLint pos;
@@ -262,7 +264,7 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
struct gl_program_parameter *p = paramList->Parameters + pos; struct gl_program_parameter *p = paramList->Parameters + pos;
if (p->Type == PROGRAM_CONSTANT && p->Size + size <= 4) { if (p->Type == PROGRAM_CONSTANT && p->Size + size <= 4) {
/* ok, found room */ /* ok, found room */
GLfloat *pVal = paramList->ParameterValues[pos]; gl_constant_value *pVal = paramList->ParameterValues[pos];
GLuint swz = p->Size; /* 1, 2 or 3 for Y, Z, W */ GLuint swz = p->Size; /* 1, 2 or 3 for Y, Z, W */
pVal[p->Size] = values[0]; pVal[p->Size] = values[0];
p->Size++; p->Size++;
@@ -401,7 +403,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
* Lookup a parameter value by name in the given parameter list. * Lookup a parameter value by name in the given parameter list.
* \return pointer to the float[4] values. * \return pointer to the float[4] values.
*/ */
GLfloat * gl_constant_value *
_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, _mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
GLsizei nameLen, const char *name) GLsizei nameLen, const char *name)
{ {
@@ -465,7 +467,7 @@ _mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
*/ */
GLboolean GLboolean
_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
const GLfloat v[], GLuint vSize, const gl_constant_value v[], GLuint vSize,
GLint *posOut, GLuint *swizzleOut) GLint *posOut, GLuint *swizzleOut)
{ {
GLuint i; GLuint i;
@@ -484,7 +486,7 @@ _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
/* swizzle not allowed */ /* swizzle not allowed */
GLuint j, match = 0; GLuint j, match = 0;
for (j = 0; j < vSize; j++) { for (j = 0; j < vSize; j++) {
if (v[j] == list->ParameterValues[i][j]) if (v[j].u == list->ParameterValues[i][j].u)
match++; match++;
} }
if (match == vSize) { if (match == vSize) {
@@ -498,7 +500,7 @@ _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
/* look for v[0] anywhere within float[4] value */ /* look for v[0] anywhere within float[4] value */
GLuint j; GLuint j;
for (j = 0; j < list->Parameters[i].Size; j++) { for (j = 0; j < list->Parameters[i].Size; j++) {
if (list->ParameterValues[i][j] == v[0]) { if (list->ParameterValues[i][j].u == v[0].u) {
/* found it */ /* found it */
*posOut = i; *posOut = i;
*swizzleOut = MAKE_SWIZZLE4(j, j, j, j); *swizzleOut = MAKE_SWIZZLE4(j, j, j, j);
@@ -511,13 +513,13 @@ _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
GLuint swz[4]; GLuint swz[4];
GLuint match = 0, j, k; GLuint match = 0, j, k;
for (j = 0; j < vSize; j++) { for (j = 0; j < vSize; j++) {
if (v[j] == list->ParameterValues[i][j]) { if (v[j].u == list->ParameterValues[i][j].u) {
swz[j] = j; swz[j] = j;
match++; match++;
} }
else { else {
for (k = 0; k < list->Parameters[i].Size; k++) { for (k = 0; k < list->Parameters[i].Size; k++) {
if (v[j] == list->ParameterValues[i][k]) { if (v[j].u == list->ParameterValues[i][k].u) {
swz[j] = k; swz[j] = k;
match++; match++;
break; break;

View File

@@ -46,7 +46,15 @@
#define PROG_PARAM_BIT_CYL_WRAP 0x10 /**< XXX gallium debug */ #define PROG_PARAM_BIT_CYL_WRAP 0x10 /**< XXX gallium debug */
/*@}*/ /*@}*/
/**
* Actual data for constant values of parameters.
*/
typedef union gl_constant_value {
GLfloat f;
GLboolean b;
GLint i;
GLuint u;
} gl_constant_value;
/** /**
* Program parameter. * Program parameter.
@@ -81,7 +89,7 @@ struct gl_program_parameter_list
GLuint Size; /**< allocated size of Parameters, ParameterValues */ GLuint Size; /**< allocated size of Parameters, ParameterValues */
GLuint NumParameters; /**< number of parameters in arrays */ GLuint NumParameters; /**< number of parameters in arrays */
struct gl_program_parameter *Parameters; /**< Array [Size] */ struct gl_program_parameter *Parameters; /**< Array [Size] */
GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */ gl_constant_value (*ParameterValues)[4]; /**< Array [Size] of constant[4] */
GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
might invalidate ParameterValues[] */ might invalidate ParameterValues[] */
}; };
@@ -112,22 +120,23 @@ _mesa_num_parameters(const struct gl_program_parameter_list *list)
extern GLint extern GLint
_mesa_add_parameter(struct gl_program_parameter_list *paramList, _mesa_add_parameter(struct gl_program_parameter_list *paramList,
gl_register_file type, const char *name, gl_register_file type, const char *name,
GLuint size, GLenum datatype, const GLfloat *values, GLuint size, GLenum datatype,
const gl_constant_value *values,
const gl_state_index state[STATE_LENGTH], const gl_state_index state[STATE_LENGTH],
GLbitfield flags); GLbitfield flags);
extern GLint extern GLint
_mesa_add_named_parameter(struct gl_program_parameter_list *paramList, _mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4]); const char *name, const gl_constant_value values[4]);
extern GLint extern GLint
_mesa_add_named_constant(struct gl_program_parameter_list *paramList, _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4], const char *name, const gl_constant_value values[4],
GLuint size); GLuint size);
extern GLint extern GLint
_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
const GLfloat values[4], GLuint size, const gl_constant_value values[4], GLuint size,
GLuint *swizzleOut); GLuint *swizzleOut);
extern GLint extern GLint
@@ -143,7 +152,7 @@ extern GLint
_mesa_add_state_reference(struct gl_program_parameter_list *paramList, _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
const gl_state_index stateTokens[STATE_LENGTH]); const gl_state_index stateTokens[STATE_LENGTH]);
extern GLfloat * extern gl_constant_value *
_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, _mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
GLsizei nameLen, const char *name); GLsizei nameLen, const char *name);
@@ -153,7 +162,7 @@ _mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
extern GLboolean extern GLboolean
_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
const GLfloat v[], GLuint vSize, const gl_constant_value v[], GLuint vSize,
GLint *posOut, GLuint *swizzleOut); GLint *posOut, GLuint *swizzleOut);
extern GLuint extern GLuint

View File

@@ -182,7 +182,7 @@ _mesa_layout_parameters(struct asm_parser_state *state)
switch (p->Type) { switch (p->Type) {
case PROGRAM_CONSTANT: { case PROGRAM_CONSTANT: {
const float *const v = const gl_constant_value *const v =
state->prog->Parameters->ParameterValues[idx]; state->prog->Parameters->ParameterValues[idx];
inst->Base.SrcReg[i].Index = inst->Base.SrcReg[i].Index =

View File

@@ -985,7 +985,7 @@ _mesa_fprint_parameter_list(FILE *f,
fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags);
for (i = 0; i < list->NumParameters; i++){ for (i = 0; i < list->NumParameters; i++){
struct gl_program_parameter *param = list->Parameters + i; struct gl_program_parameter *param = list->Parameters + i;
const GLfloat *v = list->ParameterValues[i]; const GLfloat *v = (GLfloat *) list->ParameterValues[i];
fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}",
i, param->Size, i, param->Size,
_mesa_register_file_name(list->Parameters[i].Type), _mesa_register_file_name(list->Parameters[i].Type),

View File

@@ -1030,7 +1030,8 @@ _mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog)
GLuint i; GLuint i;
GLuint whiteSwizzle; GLuint whiteSwizzle;
GLint whiteIndex = _mesa_add_unnamed_constant(prog->Parameters, GLint whiteIndex = _mesa_add_unnamed_constant(prog->Parameters,
white, 4, &whiteSwizzle); (gl_constant_value *) white,
4, &whiteSwizzle);
(void) whiteIndex; (void) whiteIndex;

View File

@@ -132,6 +132,6 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
index += getname.offset; index += getname.offset;
return prog->Parameters->ParameterValues[index][0]; return prog->Parameters->ParameterValues[index][0].f;
} }
} }

View File

@@ -706,9 +706,11 @@ struct st_src_reg
glsl_to_tgsi_visitor::st_src_reg_for_float(float val) glsl_to_tgsi_visitor::st_src_reg_for_float(float val)
{ {
st_src_reg src(PROGRAM_CONSTANT, -1, NULL); st_src_reg src(PROGRAM_CONSTANT, -1, NULL);
union gl_constant_value uval;
uval.f = val;
src.index = _mesa_add_unnamed_constant(this->prog->Parameters, src.index = _mesa_add_unnamed_constant(this->prog->Parameters,
&val, 1, &src.swizzle); &uval, 1, &src.swizzle);
return src; return src;
} }
@@ -1791,7 +1793,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
src = st_src_reg(PROGRAM_CONSTANT, -1, NULL); src = st_src_reg(PROGRAM_CONSTANT, -1, NULL);
src.index = _mesa_add_unnamed_constant(this->prog->Parameters, src.index = _mesa_add_unnamed_constant(this->prog->Parameters,
values, (gl_constant_value *) values,
ir->type->vector_elements, ir->type->vector_elements,
&src.swizzle); &src.swizzle);
emit(ir, TGSI_OPCODE_MOV, mat_column, src); emit(ir, TGSI_OPCODE_MOV, mat_column, src);
@@ -1829,7 +1831,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
this->result = st_src_reg(PROGRAM_CONSTANT, -1, ir->type); this->result = st_src_reg(PROGRAM_CONSTANT, -1, ir->type);
this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters, this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters,
values, (gl_constant_value *) values,
ir->type->vector_elements, ir->type->vector_elements,
&this->result.swizzle); &this->result.swizzle);
} }
@@ -2401,7 +2403,7 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program,
*/ */
if (file == PROGRAM_SAMPLER) { if (file == PROGRAM_SAMPLER) {
for (unsigned int j = 0; j < size / 4; j++) for (unsigned int j = 0; j < size / 4; j++)
prog->Parameters->ParameterValues[index + j][0] = next_sampler++; prog->Parameters->ParameterValues[index + j][0].f = next_sampler++;
} }
/* The location chosen in the Parameters list here (returned /* The location chosen in the Parameters list here (returned
@@ -3762,7 +3764,7 @@ st_translate_program(
else else
t->constants[i] = t->constants[i] =
ureg_DECL_immediate( ureg, ureg_DECL_immediate( ureg,
proginfo->Parameters->ParameterValues[i], (GLfloat *) proginfo->Parameters->ParameterValues[i],
4 ); 4 );
break; break;
default: default: