glsl: don't lose uniform values when falling back to full compile

Here we skip the recreation of uniform storage if we are relinking
after a cache miss. This is improtant because uniform values may
have already been set by the application and we don't want to reset
them.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Timothy Arceri
2016-04-27 15:41:19 +10:00
committed by Timothy Arceri
parent 0e9991f957
commit 794f7326bc
2 changed files with 25 additions and 10 deletions

View File

@@ -1213,11 +1213,17 @@ link_assign_uniform_storage(struct gl_context *ctx,
unsigned int boolean_true = ctx->Const.UniformBooleanTrue;
prog->data->UniformStorage = rzalloc_array(prog, struct gl_uniform_storage,
prog->data->NumUniformStorage);
union gl_constant_value *data = rzalloc_array(prog->data->UniformStorage,
union gl_constant_value,
num_data_slots);
union gl_constant_value *data;
if (prog->data->UniformStorage == NULL) {
prog->data->UniformStorage = rzalloc_array(prog,
struct gl_uniform_storage,
prog->data->NumUniformStorage);
data = rzalloc_array(prog->data->UniformStorage,
union gl_constant_value, num_data_slots);
} else {
data = prog->data->UniformDataSlots;
}
#ifndef NDEBUG
union gl_constant_value *data_end = &data[num_data_slots];
#endif
@@ -1252,6 +1258,13 @@ link_assign_uniform_storage(struct gl_context *ctx,
sizeof(prog->_LinkedShaders[i]->Program->sh.SamplerTargets));
}
/* If this is a fallback compile for a cache miss we already have the
* correct uniform mappings and we don't want to reinitialise uniforms so
* just return now.
*/
if (prog->data->cache_fallback)
return;
#ifndef NDEBUG
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
assert(prog->data->UniformStorage[i].storage != NULL ||
@@ -1276,9 +1289,11 @@ void
link_assign_uniform_locations(struct gl_shader_program *prog,
struct gl_context *ctx)
{
ralloc_free(prog->data->UniformStorage);
prog->data->UniformStorage = NULL;
prog->data->NumUniformStorage = 0;
if (!prog->data->cache_fallback) {
ralloc_free(prog->data->UniformStorage);
prog->data->UniformStorage = NULL;
prog->data->NumUniformStorage = 0;
}
if (prog->UniformHash != NULL) {
prog->UniformHash->clear();