diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2011-11-14 14:32:39 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2012-01-11 12:51:23 -0800 |
commit | f409a710e3562856a53a3b43ed526b877639a27c (patch) | |
tree | 888cdbd4b6e401600acd4cdaa89fc3fe5b708d2b /src/mesa/main/ff_fragment_shader.cpp | |
parent | 151b4f336934d283961e28e111aa30544e3ceb50 (diff) |
mesa: Use uniform interfaces in fixed-function fragment shader code
Poking directly at the backing resources works only by luck. Core
Mesa code should only know about the gl_uniform_storage structure.
Soon other code that looks at samplers will use the gl_uniform_storage
structures instead of the data in the gl_program.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/main/ff_fragment_shader.cpp')
-rw-r--r-- | src/mesa/main/ff_fragment_shader.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 3e736fa1500..49a8af090f5 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -42,6 +42,7 @@ extern "C" { #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" @@ -1498,22 +1499,40 @@ create_new_program(struct gl_context *ctx, struct state_key *key) /* 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); |