#include "program/programopt.h"
#include "texenvprogram.h"
}
+#include "main/uniforms.h"
#include "../glsl/glsl_types.h"
#include "../glsl/ir.h"
#include "../glsl/glsl_symbol_table.h"
/* Set the sampler uniforms, and relink to get them into the linked
* program.
*/
- struct gl_program *fp;
- fp = p.shader_program->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+ struct gl_shader *const fs =
+ p.shader_program->_LinkedShaders[MESA_SHADER_FRAGMENT];
+ struct gl_program *const fp = fs->Program;
+
+ _mesa_generate_parameters_list_for_uniforms(p.shader_program, fs,
+ fp->Parameters);
+
+ _mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters);
for (unsigned int i = 0; i < MAX_TEXTURE_UNITS; i++) {
char *name = ralloc_asprintf(p.mem_ctx, "sampler_%d", i);
int loc = _mesa_get_uniform_location(ctx, p.shader_program, name);
if (loc != -1) {
+ unsigned base;
+ unsigned idx;
+
/* Avoid using _mesa_uniform() because it flags state
* updates, so if we're generating this shader_program in a
* state update, we end up recursing. Instead, just set the
* value, which is picked up at re-link.
*/
- loc = (loc & 0xffff) + (loc >> 16);
- int sampler = fp->Parameters->ParameterValues[loc][0].f;
+ _mesa_uniform_split_location_offset(loc, &base, &idx);
+ assert(idx == 0);
+
+ struct gl_uniform_storage *const storage =
+ &p.shader_program->UniformStorage[base];
- fp->SamplerUnits[sampler] = i;
+ /* Update the storage, the SamplerUnits in the shader program, and
+ * the SamplerUnits in the assembly shader.
+ */
+ storage->storage[idx].i = i;
+ fp->SamplerUnits[storage->sampler] = i;
+ p.shader_program->SamplerUnits[storage->sampler] = i;
+ _mesa_propagate_uniforms_to_driver_storage(storage, 0, 1);
}
}
_mesa_update_shader_textures_used(fp);