summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/shader/prog_parameter.c31
-rw-r--r--src/mesa/shader/prog_parameter.h7
-rw-r--r--src/mesa/shader/shader_api.c9
-rw-r--r--src/mesa/shader/slang/slang_codegen.c7
-rw-r--r--src/mesa/shader/slang/slang_link.c4
5 files changed, 31 insertions, 27 deletions
diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c
index e2f1047463..7f17be74f7 100644
--- a/src/mesa/shader/prog_parameter.c
+++ b/src/mesa/shader/prog_parameter.c
@@ -81,7 +81,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
GLint
_mesa_add_parameter(struct gl_program_parameter_list *paramList,
enum register_file type, const char *name,
- GLuint size, const GLfloat *values,
+ GLuint size, GLenum datatype, const GLfloat *values,
const gl_state_index state[STATE_LENGTH])
{
const GLuint oldNum = paramList->NumParameters;
@@ -126,6 +126,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
p->Name = name ? _mesa_strdup(name) : NULL;
p->Type = type;
p->Size = size;
+ p->DataType = datatype;
if (values) {
COPY_4V(paramList->ParameterValues[oldNum + i], values);
values += 4;
@@ -156,7 +157,7 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
const char *name, const GLfloat values[4])
{
return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name,
- 4, values, NULL);
+ 4, GL_NONE, values, NULL);
}
@@ -187,7 +188,7 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
#endif
size = 4; /** XXX fix */
return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name,
- size, values, NULL);
+ size, GL_NONE, values, NULL);
}
@@ -239,7 +240,7 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
/* add a new parameter to store this constant */
pos = _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL,
- size, values, NULL);
+ size, GL_NONE, values, NULL);
if (pos >= 0 && swizzleOut) {
if (size == 1)
*swizzleOut = SWIZZLE_XXXX;
@@ -252,16 +253,19 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
GLint
_mesa_add_uniform(struct gl_program_parameter_list *paramList,
- const char *name, GLuint size)
+ const char *name, GLuint size, GLenum datatype)
{
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
+ ASSERT(datatype != GL_NONE);
if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_UNIFORM) {
+ ASSERT(paramList->Parameters[i].Size == size);
+ ASSERT(paramList->Parameters[i].DataType == datatype);
/* already in list */
return i;
}
else {
i = _mesa_add_parameter(paramList, PROGRAM_UNIFORM, name,
- size, NULL, NULL);
+ size, datatype, NULL, NULL);
return i;
}
@@ -270,7 +274,7 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList,
GLint
_mesa_add_sampler(struct gl_program_parameter_list *paramList,
- const char *name)
+ const char *name, GLenum datatype)
{
GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) {
@@ -280,7 +284,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList,
else {
const GLint size = 1;
i = _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name,
- size, NULL, NULL);
+ size, datatype, NULL, NULL);
return i;
}
}
@@ -301,7 +305,7 @@ _mesa_add_varying(struct gl_program_parameter_list *paramList,
else {
assert(size == 4);
i = _mesa_add_parameter(paramList, PROGRAM_VARYING, name,
- size, NULL, NULL);
+ size, GL_NONE, NULL, NULL);
return i;
}
}
@@ -330,7 +334,7 @@ _mesa_add_attribute(struct gl_program_parameter_list *paramList,
if (size < 0)
size = 4;
i = _mesa_add_parameter(paramList, PROGRAM_INPUT, name,
- size, NULL, state);
+ size, GL_NONE, NULL, state);
}
return i;
}
@@ -396,7 +400,8 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
name = _mesa_program_state_string(stateTokens);
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
- size, NULL, (gl_state_index *) stateTokens);
+ size, GL_NONE,
+ NULL, (gl_state_index *) stateTokens);
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
/* free name string here since we duplicated it in add_parameter() */
@@ -565,8 +570,8 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list)
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->Type, p->Name,
- size, list->ParameterValues[i], NULL);
+ GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType,
+ list->ParameterValues[i], NULL);
ASSERT(j >= 0);
/* copy state indexes */
if (p->Type == PROGRAM_STATE_VAR) {
diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h
index 2e0feb972e..09ff851ea7 100644
--- a/src/mesa/shader/prog_parameter.h
+++ b/src/mesa/shader/prog_parameter.h
@@ -46,6 +46,7 @@ struct gl_program_parameter
{
const char *Name; /**< Null-terminated string */
enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
+ GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
GLuint Size; /**< Number of components (1..4) */
/**
* A sequence of STATE_* tokens and integers to identify GL state.
@@ -80,7 +81,7 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list);
extern GLint
_mesa_add_parameter(struct gl_program_parameter_list *paramList,
enum register_file type, const char *name,
- GLuint size, const GLfloat *values,
+ GLuint size, GLenum datatype, const GLfloat *values,
const gl_state_index state[STATE_LENGTH]);
extern GLint
@@ -99,11 +100,11 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
extern GLint
_mesa_add_uniform(struct gl_program_parameter_list *paramList,
- const char *name, GLuint size);
+ const char *name, GLuint size, GLenum datatype);
extern GLint
_mesa_add_sampler(struct gl_program_parameter_list *paramList,
- const char *name);
+ const char *name, GLenum datatype);
extern GLint
_mesa_add_varying(struct gl_program_parameter_list *paramList,
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 74bdef061b..418ef5c723 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -638,12 +638,8 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
GLsizei maxLength, GLsizei *length, GLint *size,
GLenum *type, GLchar *nameOut)
{
- static const GLenum vec_types[] = {
- GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4
- };
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
- GLint sz;
GLuint ind, j;
if (!shProg) {
@@ -664,11 +660,10 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
/* found it */
copy_string(nameOut, maxLength, length,
shProg->Uniforms->Parameters[j].Name);
- sz = shProg->Uniforms->Parameters[j].Size;
if (size)
- *size = sz;
+ *size = shProg->Uniforms->Parameters[j].Size;
if (type)
- *type = vec_types[sz-1]; /* XXX this is a temporary hack */
+ *type = shProg->Uniforms->Parameters[j].DataType;
return;
}
ind++;
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 06bceea7d0..d8c06f064d 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2829,7 +2829,8 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
* store->Index = sampler uniform location
* store->Size = texture type index (1D, 2D, 3D, cube, etc)
*/
- GLint samplerUniform = _mesa_add_sampler(prog->Parameters, varName);
+ GLenum datatype = GL_SAMPLER_2D;
+ GLint samplerUniform = _mesa_add_sampler(prog->Parameters, varName, datatype);
store = _slang_new_ir_storage(PROGRAM_SAMPLER, samplerUniform, texIndex);
if (dbg) printf("SAMPLER ");
}
@@ -2839,7 +2840,9 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
* MAX2(var->array_len, 1);
if (prog) {
/* user-defined uniform */
- GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName, size);
+ GLenum datatype = GL_FLOAT_VEC4; /* XXX */
+ GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
+ size, datatype);
store = _slang_new_ir_storage(PROGRAM_UNIFORM, uniformLoc, size);
}
else {
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 360af0922f..48c0d68375 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -202,10 +202,10 @@ link_uniform_vars(struct gl_shader_program *shProg, struct gl_program *prog)
j = _mesa_add_state_reference(shProg->Uniforms, p->StateIndexes);
break;
case PROGRAM_UNIFORM:
- j = _mesa_add_uniform(shProg->Uniforms, p->Name, p->Size);
+ j = _mesa_add_uniform(shProg->Uniforms, p->Name, p->Size, p->DataType);
break;
case PROGRAM_SAMPLER:
- j = _mesa_add_sampler(shProg->Uniforms, p->Name);
+ j = _mesa_add_sampler(shProg->Uniforms, p->Name, p->DataType);
break;
default:
_mesa_problem(NULL, "bad parameter type in link_uniform_vars()");