ir_to_mesa: Add _mesa_associate_uniform_storage
Connects all of the gl_program_parameter structures with the correct gl_uniform_storage structures. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
@@ -2698,6 +2698,77 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_mesa_associate_uniform_storage(struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *shader_program,
|
||||||
|
struct gl_program_parameter_list *params)
|
||||||
|
{
|
||||||
|
/* After adding each uniform to the parameter list, connect the storage for
|
||||||
|
* the parameter with the tracking structure used by the API for the
|
||||||
|
* uniform.
|
||||||
|
*/
|
||||||
|
unsigned last_location = unsigned(~0);
|
||||||
|
for (unsigned i = 0; i < params->NumParameters; i++) {
|
||||||
|
if (params->Parameters[i].Type != PROGRAM_UNIFORM)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
unsigned location;
|
||||||
|
const bool found =
|
||||||
|
shader_program->UniformHash->get(location, params->Parameters[i].Name);
|
||||||
|
assert(found);
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (location != last_location) {
|
||||||
|
struct gl_uniform_storage *storage =
|
||||||
|
&shader_program->UniformStorage[location];
|
||||||
|
enum gl_uniform_driver_format format = uniform_native;
|
||||||
|
|
||||||
|
unsigned columns = 0;
|
||||||
|
switch (storage->type->base_type) {
|
||||||
|
case GLSL_TYPE_UINT:
|
||||||
|
assert(ctx->Const.NativeIntegers);
|
||||||
|
format = uniform_native;
|
||||||
|
columns = 1;
|
||||||
|
break;
|
||||||
|
case GLSL_TYPE_INT:
|
||||||
|
format =
|
||||||
|
(ctx->Const.NativeIntegers) ? uniform_native : uniform_int_float;
|
||||||
|
columns = 1;
|
||||||
|
break;
|
||||||
|
case GLSL_TYPE_FLOAT:
|
||||||
|
format = uniform_native;
|
||||||
|
columns = storage->type->matrix_columns;
|
||||||
|
break;
|
||||||
|
case GLSL_TYPE_BOOL:
|
||||||
|
if (ctx->Const.NativeIntegers) {
|
||||||
|
format = (ctx->Const.UniformBooleanTrue == 1)
|
||||||
|
? uniform_bool_int_0_1 : uniform_bool_int_0_not0;
|
||||||
|
} else {
|
||||||
|
format = uniform_bool_float;
|
||||||
|
}
|
||||||
|
columns = 1;
|
||||||
|
break;
|
||||||
|
case GLSL_TYPE_SAMPLER:
|
||||||
|
format = uniform_native;
|
||||||
|
columns = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(!"Should not get here.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_mesa_uniform_attach_driver_storage(storage,
|
||||||
|
4 * sizeof(float) * columns,
|
||||||
|
4 * sizeof(float),
|
||||||
|
format,
|
||||||
|
¶ms->ParameterValues[i]);
|
||||||
|
last_location = location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
|
set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
|
||||||
struct gl_shader_program *shader_program,
|
struct gl_shader_program *shader_program,
|
||||||
|
@@ -45,4 +45,9 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
|
|||||||
struct gl_shader *sh,
|
struct gl_shader *sh,
|
||||||
struct gl_program_parameter_list
|
struct gl_program_parameter_list
|
||||||
*params);
|
*params);
|
||||||
|
void
|
||||||
|
_mesa_associate_uniform_storage(struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *shader_program,
|
||||||
|
struct gl_program_parameter_list *params);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user