mesa: Rewrite the way uniforms are tracked and handled

Switch all of the code in ir_to_mesa, st_glsl_to_tgsi, glUniform*,
glGetUniform, glGetUniformLocation, and glGetActiveUniforms to use the
gl_uniform_storage structures in the gl_shader_program.

A couple of notes:

 * Like most rewrite-the-world patches, this should be reviewed by
   applying the patch and examining the modified functions.

 * This leaves a lot of dead code around in linker.cpp and
   uniform_query.cpp.  This will be deleted in the next patches.

v2: Update the comment block (previously a FINISHME) in _mesa_uniform
about generating GL_INVALID_VALUE when an out-of-range sampler index
is specified.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
Ian Romanick
2011-10-18 16:01:49 -07:00
parent 143d20c16a
commit 719909698c
10 changed files with 519 additions and 255 deletions

View File

@@ -51,6 +51,7 @@
#include "ralloc.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
#include "../glsl/ir_uniform.h"
/** Define this to enable shader substitution (see below) */
#define SHADER_SUBST 0
@@ -572,13 +573,24 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
*params = _mesa_longest_attribute_name_length(shProg);
break;
case GL_ACTIVE_UNIFORMS:
*params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0;
*params = shProg->NumUserUniformStorage;
break;
case GL_ACTIVE_UNIFORM_MAX_LENGTH:
*params = _mesa_longest_uniform_name(shProg->Uniforms);
if (*params > 0)
(*params)++; /* add one for terminating zero */
case GL_ACTIVE_UNIFORM_MAX_LENGTH: {
unsigned i;
GLint max_len = 0;
for (i = 0; i < shProg->NumUserUniformStorage; i++) {
/* Add one for the terminating NUL character.
*/
const GLint len = strlen(shProg->UniformStorage[i].name) + 1;
if (len > max_len)
max_len = len;
}
*params = max_len;
break;
}
case GL_PROGRAM_BINARY_LENGTH_OES:
*params = 0;
break;