From c234d0b25f622a7bdd3c40bc72fdbd59d8494c7c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Aug 2010 17:00:12 -0700 Subject: ir_to_mesa: Add support for sampler arrays. Support for samplers in general is still incomplete -- anything in a uniform struct will still be broken. But that doesn't appear to be any different from master. Fixes: glsl-fs-uniform-sampler-array.shader_test --- src/mesa/program/prog_parameter.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/mesa/program/prog_parameter.c') diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index ddbfe95c15..fa5deaf127 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -344,18 +344,19 @@ _mesa_use_uniform(struct gl_program_parameter_list *paramList, */ GLint _mesa_add_sampler(struct gl_program_parameter_list *paramList, - const char *name, GLenum datatype) + const char *name, GLenum datatype, int array_length) { 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].Size == 4 * array_length); ASSERT(paramList->Parameters[i].DataType == datatype); /* already in list */ return (GLint) paramList->ParameterValues[i][0]; } else { GLuint i; - const GLint size = 1; /* a sampler is basically a texture unit number */ + /* One integer texture unit number goes in each parameter location. */ + const GLint size = 4 * array_length; GLfloat value[4]; GLint numSamplers = 0; for (i = 0; i < paramList->NumParameters; i++) { -- cgit v1.2.3 From ea2231ff5e4ced36bdb65ccdd02a1008fb8bfce7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 24 Aug 2010 16:47:09 -0700 Subject: mesa: Remove the "Used" flag in gl_program_parameter. This was in place for uniform handling, but nothing actually needs the value now, since presence in a parameter list indicates that the uniform was used as far as the linker was concerned. --- src/mesa/program/ir_to_mesa.cpp | 5 ----- src/mesa/program/prog_parameter.c | 22 ---------------------- src/mesa/program/prog_parameter.h | 7 +------ 3 files changed, 1 insertion(+), 33 deletions(-) (limited to 'src/mesa/program/prog_parameter.c') diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index fc145b475e..4429b7468d 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1427,11 +1427,6 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) loc = add_uniform(ir->var->name, ir->var->type); - /* Always mark the uniform used at this point. If it isn't - * used, dead code elimination should have nuked the decl already. - */ - this->prog->Parameters->Parameters[loc].Used = GL_TRUE; - entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_UNIFORM, loc); this->variables.push_tail(entry); break; diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index fa5deaf127..7e01f675d3 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -314,27 +314,6 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList, } -/** - * Mark the named uniform as 'used'. - */ -void -_mesa_use_uniform(struct gl_program_parameter_list *paramList, - const char *name) -{ - GLuint i; - for (i = 0; i < paramList->NumParameters; i++) { - struct gl_program_parameter *p = paramList->Parameters + i; - if ((p->Type == PROGRAM_UNIFORM || p->Type == PROGRAM_SAMPLER) && - strcmp(p->Name, name) == 0) { - p->Used = GL_TRUE; - /* Note that large uniforms may occupy several slots so we're - * not done searching yet. - */ - } - } -} - - /** * Add a sampler to the parameter list. * \param name uniform's name @@ -658,7 +637,6 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list) list->ParameterValues[i], NULL, 0x0); ASSERT(j >= 0); pCopy = clone->Parameters + j; - pCopy->Used = p->Used; pCopy->Flags = p->Flags; /* copy state indexes */ if (p->Type == PROGRAM_STATE_VAR) { diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h index 1860f31287..5381a6dc0f 100644 --- a/src/mesa/program/prog_parameter.h +++ b/src/mesa/program/prog_parameter.h @@ -64,8 +64,7 @@ struct gl_program_parameter * The next program parameter's Size will be Size-4 of this parameter. */ GLuint Size; - GLboolean Used; /**< Helper flag for GLSL uniform tracking */ - GLboolean Initialized; /**< Has the ParameterValue[] been set? */ + GLboolean Initialized; /**< debug: Has the ParameterValue[] been set? */ GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ /** * A sequence of STATE_* tokens and integers to identify GL state. @@ -136,10 +135,6 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList, const char *name, GLuint size, GLenum datatype, const GLfloat *values); -extern void -_mesa_use_uniform(struct gl_program_parameter_list *paramList, - const char *name); - extern GLint _mesa_add_sampler(struct gl_program_parameter_list *paramList, const char *name, GLenum datatype, int array_length); -- cgit v1.2.3 From 9ab1332d749e8e7eda2896c25725e245fd0f8444 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 24 Aug 2010 21:02:22 -0700 Subject: mesa: Remove now-unused _mesa_add_uniform. We had to inline it to avoid doing a double-lookup in the process of adding assertion checks. --- src/mesa/program/prog_parameter.c | 30 ------------------------------ src/mesa/program/prog_parameter.h | 5 ----- 2 files changed, 35 deletions(-) (limited to 'src/mesa/program/prog_parameter.c') diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 7e01f675d3..b3770f83b5 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -284,36 +284,6 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, return pos; } - -/** - * Add a uniform to the parameter list. - * Note that if the uniform is an array, size may be greater than - * what's implied by the datatype. - * \param name uniform's name - * \param size number of floats to allocate - * \param datatype GL_FLOAT_VEC3, GL_FLOAT_MAT4, etc. - */ -GLint -_mesa_add_uniform(struct gl_program_parameter_list *paramList, - const char *name, GLuint size, GLenum datatype, - const GLfloat *values) -{ - 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, datatype, values, NULL, 0x0); - return i; - } -} - - /** * Add a sampler to the parameter list. * \param name uniform's name diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h index 5381a6dc0f..b3b11a9536 100644 --- a/src/mesa/program/prog_parameter.h +++ b/src/mesa/program/prog_parameter.h @@ -130,11 +130,6 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, const GLfloat values[4], GLuint size, GLuint *swizzleOut); -extern GLint -_mesa_add_uniform(struct gl_program_parameter_list *paramList, - const char *name, GLuint size, GLenum datatype, - const GLfloat *values); - extern GLint _mesa_add_sampler(struct gl_program_parameter_list *paramList, const char *name, GLenum datatype, int array_length); -- cgit v1.2.3 From b5c07b9226d8e7de78f6367b5799b39caf820ef3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 24 Aug 2010 21:45:40 -0700 Subject: mesa: Remove now-unused _mesa_add_sampler(). We do the generation of "what sampler number within Parameters are we" right in ir_to_mesa.cpp, instead of repeatedly walking the existing list to find out. --- src/mesa/program/prog_parameter.c | 37 ------------------------------------- src/mesa/program/prog_parameter.h | 4 ---- 2 files changed, 41 deletions(-) (limited to 'src/mesa/program/prog_parameter.c') diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index b3770f83b5..40dc92cb20 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -284,43 +284,6 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, return pos; } -/** - * Add a sampler to the parameter list. - * \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, int array_length) -{ - GLint i = _mesa_lookup_parameter_index(paramList, -1, name); - if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) { - ASSERT(paramList->Parameters[i].Size == 4 * array_length); - ASSERT(paramList->Parameters[i].DataType == datatype); - /* already in list */ - return (GLint) paramList->ParameterValues[i][0]; - } - else { - GLuint i; - /* One integer texture unit number goes in each parameter location. */ - const GLint size = 4 * array_length; - GLfloat value[4]; - GLint numSamplers = 0; - for (i = 0; i < paramList->NumParameters; i++) { - if (paramList->Parameters[i].Type == PROGRAM_SAMPLER) - numSamplers++; - } - value[0] = (GLfloat) numSamplers; - value[1] = value[2] = value[3] = 0.0F; - (void) _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name, - size, datatype, value, NULL, 0x0); - return numSamplers; - } -} - - /** * Add parameter representing a varying variable. */ diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h index b3b11a9536..10cbbe57a6 100644 --- a/src/mesa/program/prog_parameter.h +++ b/src/mesa/program/prog_parameter.h @@ -130,10 +130,6 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, const GLfloat values[4], GLuint size, GLuint *swizzleOut); -extern GLint -_mesa_add_sampler(struct gl_program_parameter_list *paramList, - const char *name, GLenum datatype, int array_length); - extern GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, const char *name, GLuint size, GLenum datatype, -- cgit v1.2.3 From 128237927d6fa4ffb23e52c59150f57520004c00 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 30 Aug 2010 13:48:21 +0100 Subject: mesa: Fix _mesa_lookup_parameter_constant's return value. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes gcc warning In function ‘_mesa_add_unnamed_constant’: warning: ‘pos’ may be used uninitialized in this function but also what appears to be a bug. --- src/mesa/program/prog_parameter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa/program/prog_parameter.c') diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 40dc92cb20..6bf8a081b0 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -482,8 +482,10 @@ _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, assert(vSize >= 1); assert(vSize <= 4); - if (!list) - return -1; + if (!list) { + *posOut = -1; + return GL_FALSE; + } for (i = 0; i < list->NumParameters; i++) { if (list->Parameters[i].Type == PROGRAM_CONSTANT) { -- cgit v1.2.3