i965/fs: Reference the core GL uniform storage for non-builtin uniforms.
There's no reason to use an external copy if the relayout in the external copy isn't serving us. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
bd326623ef
commit
c0d1f508d6
|
@ -792,55 +792,41 @@ fs_visitor::import_uniforms(fs_visitor *v)
|
||||||
* get stored, rather than in some global gl_shader_program uniform
|
* get stored, rather than in some global gl_shader_program uniform
|
||||||
* store.
|
* store.
|
||||||
*/
|
*/
|
||||||
int
|
void
|
||||||
fs_visitor::setup_uniform_values(int loc, const glsl_type *type)
|
fs_visitor::setup_uniform_values(ir_variable *ir)
|
||||||
{
|
{
|
||||||
unsigned int offset = 0;
|
int namelen = strlen(ir->name);
|
||||||
|
|
||||||
if (type->is_matrix()) {
|
/* The data for our (non-builtin) uniforms is stored in a series of
|
||||||
const glsl_type *column = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
* gl_uniform_driver_storage structs for each subcomponent that
|
||||||
type->vector_elements,
|
* glGetUniformLocation() could name. We know it's been set up in the same
|
||||||
1);
|
* order we'd walk the type, so walk the list of storage and find anything
|
||||||
|
* with our name, or the prefix of a component that starts with our name.
|
||||||
|
*/
|
||||||
|
unsigned params_before = c->prog_data.nr_params;
|
||||||
|
for (unsigned u = 0; u < prog->NumUserUniformStorage; u++) {
|
||||||
|
struct gl_uniform_storage *storage = &prog->UniformStorage[u];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < type->matrix_columns; i++) {
|
if (strncmp(ir->name, storage->name, namelen) != 0 ||
|
||||||
offset += setup_uniform_values(loc + offset, column);
|
(storage->name[namelen] != 0 &&
|
||||||
|
storage->name[namelen] != '.' &&
|
||||||
|
storage->name[namelen] != '[')) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
unsigned slots = storage->type->component_slots();
|
||||||
|
if (storage->array_elements)
|
||||||
|
slots *= storage->array_elements;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < slots; i++) {
|
||||||
|
c->prog_data.param[c->prog_data.nr_params++] =
|
||||||
|
&storage->storage[i].f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type->base_type) {
|
/* Make sure we actually initialized the right amount of stuff here. */
|
||||||
case GLSL_TYPE_FLOAT:
|
assert(params_before + ir->type->component_slots() ==
|
||||||
case GLSL_TYPE_UINT:
|
c->prog_data.nr_params);
|
||||||
case GLSL_TYPE_INT:
|
|
||||||
case GLSL_TYPE_BOOL:
|
|
||||||
for (unsigned int i = 0; i < type->vector_elements; i++) {
|
|
||||||
c->prog_data.param[c->prog_data.nr_params++] =
|
|
||||||
&fp->Base.Parameters->ParameterValues[loc][i].f;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
case GLSL_TYPE_STRUCT:
|
|
||||||
for (unsigned int i = 0; i < type->length; i++) {
|
|
||||||
offset += setup_uniform_values(loc + offset,
|
|
||||||
type->fields.structure[i].type);
|
|
||||||
}
|
|
||||||
return offset;
|
|
||||||
|
|
||||||
case GLSL_TYPE_ARRAY:
|
|
||||||
for (unsigned int i = 0; i < type->length; i++) {
|
|
||||||
offset += setup_uniform_values(loc + offset, type->fields.array);
|
|
||||||
}
|
|
||||||
return offset;
|
|
||||||
|
|
||||||
case GLSL_TYPE_SAMPLER:
|
|
||||||
/* The sampler takes up a slot, but we don't use any values from it. */
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(!"not reached");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -407,7 +407,7 @@ public:
|
||||||
fs_reg get_timestamp();
|
fs_reg get_timestamp();
|
||||||
|
|
||||||
struct brw_reg interp_reg(int location, int channel);
|
struct brw_reg interp_reg(int location, int channel);
|
||||||
int setup_uniform_values(int loc, const glsl_type *type);
|
void setup_uniform_values(ir_variable *ir);
|
||||||
void setup_builtin_uniform_values(ir_variable *ir);
|
void setup_builtin_uniform_values(ir_variable *ir);
|
||||||
int implied_mrf_writes(fs_inst *inst);
|
int implied_mrf_writes(fs_inst *inst);
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ fs_visitor::visit(ir_variable *ir)
|
||||||
if (!strncmp(ir->name, "gl_", 3)) {
|
if (!strncmp(ir->name, "gl_", 3)) {
|
||||||
setup_builtin_uniform_values(ir);
|
setup_builtin_uniform_values(ir);
|
||||||
} else {
|
} else {
|
||||||
setup_uniform_values(ir->location, ir->type);
|
setup_uniform_values(ir);
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = new(this->mem_ctx) fs_reg(UNIFORM, param_index);
|
reg = new(this->mem_ctx) fs_reg(UNIFORM, param_index);
|
||||||
|
|
Loading…
Reference in New Issue