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>
diff --git a/src/mesa/program/sampler.cpp b/src/mesa/program/sampler.cpp
index 3b459d5..e3641aa 100644
--- a/src/mesa/program/sampler.cpp
+++ b/src/mesa/program/sampler.cpp
@@ -27,6 +27,8 @@
#include "glsl_types.h"
#include "ir_visitor.h"
#include "../glsl/program.h"
+#include "program/hash_table.h"
+#include "ir_uniform.h"
extern "C" {
#include "main/compiler.h"
@@ -110,17 +112,13 @@
sampler->accept(&getname);
- GLint index = _mesa_lookup_parameter_index(prog->Parameters, -1,
- getname.name);
-
- if (index < 0) {
+ unsigned location;
+ if (!shader_program->UniformHash->get(location, getname.name)) {
linker_error(shader_program,
"failed to find sampler named %s.\n", getname.name);
return 0;
}
- index += getname.offset;
-
- return prog->Parameters->ParameterValues[index][0].f;
+ return shader_program->UniformStorage[location].sampler + getname.offset;
}
}