[Mesa-dev] [PATCH 33/37] glsl/mesa: make a copy of FragData bindings in case of cache fallback
Timothy Arceri
t_arceri at yahoo.com.au
Mon Jan 23 23:28:02 UTC 2017
From: Timothy Arceri <timothy.arceri at collabora.com>
If the shader cache falls back to doing a compile and link we need the
original FragData bindings as they could have changed after the program
was first linked.
---
src/compiler/glsl/shader_cache.cpp | 8 ++++++++
src/mesa/main/mtypes.h | 2 ++
src/mesa/main/shaderobj.c | 12 ++++++++++++
3 files changed, 22 insertions(+)
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index bf8f584..bb63da5 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -807,7 +807,11 @@ write_hash_tables(struct blob *metadata, struct gl_shader_program *prog)
hash_table_call_foreach(prog->AttributeBindings->ht, copy_hash_entry,
prog->data->FallbackAttributeBindings);
write_hash_table(metadata, prog->FragDataBindings);
+ hash_table_call_foreach(prog->FragDataBindings->ht, copy_hash_entry,
+ prog->data->FallbackFragDataBindings);
write_hash_table(metadata, prog->FragDataIndexBindings);
+ hash_table_call_foreach(prog->FragDataIndexBindings->ht, copy_hash_entry,
+ prog->data->FallbackFragDataIndexBindings);
}
static void
@@ -817,7 +821,11 @@ read_hash_tables(struct blob_reader *metadata, struct gl_shader_program *prog)
hash_table_call_foreach(prog->AttributeBindings->ht, copy_hash_entry,
prog->data->FallbackAttributeBindings);
read_hash_table(metadata, prog->FragDataBindings);
+ hash_table_call_foreach(prog->FragDataBindings->ht, copy_hash_entry,
+ prog->data->FallbackFragDataBindings);
read_hash_table(metadata, prog->FragDataIndexBindings);
+ hash_table_call_foreach(prog->FragDataIndexBindings->ht, copy_hash_entry,
+ prog->data->FallbackFragDataIndexBindings);
}
static void
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4cca837..3dcc23d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2683,6 +2683,8 @@ struct gl_shader_program_data
* was first linked.
*/
struct string_to_uint_map *FallbackAttributeBindings;
+ struct string_to_uint_map *FallbackFragDataBindings;
+ struct string_to_uint_map *FallbackFragDataIndexBindings;
/** List of all active resources after linking. */
struct gl_program_resource *ProgramResourceList;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 245a0b9..e3004f6 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -278,7 +278,9 @@ init_shader_program(struct gl_shader_program *prog)
prog->AttributeBindings = string_to_uint_map_ctor();
prog->data->FallbackAttributeBindings = string_to_uint_map_ctor();
prog->FragDataBindings = string_to_uint_map_ctor();
+ prog->data->FallbackFragDataBindings = string_to_uint_map_ctor();
prog->FragDataIndexBindings = string_to_uint_map_ctor();
+ prog->data->FallbackFragDataIndexBindings = string_to_uint_map_ctor();
prog->Geom.UsesEndPrimitive = false;
prog->Geom.UsesStreams = false;
@@ -404,11 +406,21 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
shProg->FragDataBindings = NULL;
}
+ if (shProg->data->FallbackFragDataBindings) {
+ string_to_uint_map_dtor(shProg->data->FallbackFragDataBindings);
+ shProg->data->FallbackFragDataBindings = NULL;
+ }
+
if (shProg->FragDataIndexBindings) {
string_to_uint_map_dtor(shProg->FragDataIndexBindings);
shProg->FragDataIndexBindings = NULL;
}
+ if (shProg->data->FallbackFragDataIndexBindings) {
+ string_to_uint_map_dtor(shProg->data->FallbackFragDataIndexBindings);
+ shProg->data->FallbackFragDataIndexBindings = NULL;
+ }
+
/* detach shaders */
for (i = 0; i < shProg->NumShaders; i++) {
_mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
--
2.9.3
More information about the mesa-dev
mailing list