[Mesa-dev] [PATCH 33/68] glsl: store subroutine remap table in shader cache
Timothy Arceri
timothy.arceri at collabora.com
Wed Jun 1 06:23:14 UTC 2016
---
src/compiler/glsl/shader_cache.cpp | 53 ++++++++++++++++++++++++++++++++------
1 file changed, 45 insertions(+), 8 deletions(-)
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 35cd99c..61f8bc2 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -277,8 +277,8 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
static void
-write_uniform_remap_table(struct blob *metadata,
- struct gl_shader_program *prog)
+write_uniform_remap_tables(struct blob *metadata,
+ struct gl_shader_program *prog)
{
blob_write_intptr(metadata, (intptr_t) prog->UniformStorage);
blob_write_uint32(metadata, prog->NumUniformRemapTable);
@@ -286,11 +286,23 @@ write_uniform_remap_table(struct blob *metadata,
for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
blob_write_intptr(metadata, (intptr_t) prog->UniformRemapTable[i]);
}
+
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_shader *sh = prog->_LinkedShaders[i];
+ if (sh) {
+ blob_write_uint32(metadata, sh->NumSubroutineUniformRemapTable);
+
+ for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
+ blob_write_intptr(metadata,
+ (intptr_t) sh->SubroutineUniformRemapTable[j]);
+ }
+ }
+ }
}
static void
-read_uniform_remap_table(struct blob_reader *metadata,
- struct gl_shader_program *prog)
+read_uniform_remap_tables(struct blob_reader *metadata,
+ struct gl_shader_program *prog)
{
intptr_t uni_store_base = blob_read_intptr(metadata);
prog->NumUniformRemapTable = blob_read_uint32(metadata);
@@ -309,6 +321,31 @@ read_uniform_remap_table(struct blob_reader *metadata,
prog->UniformRemapTable[i] = prog->UniformStorage + uni_offset;
}
}
+
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_shader *sh = prog->_LinkedShaders[i];
+ if (sh) {
+ sh->NumSubroutineUniformRemapTable = blob_read_uint32(metadata);
+
+ sh->SubroutineUniformRemapTable =
+ rzalloc_array(sh, struct gl_uniform_storage *,
+ sh->NumSubroutineUniformRemapTable);
+
+ for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
+ intptr_t uni_ptr = blob_read_intptr(metadata);
+ if (uni_ptr == (intptr_t) INACTIVE_UNIFORM_EXPLICIT_LOCATION ||
+ uni_ptr == (intptr_t) NULL) {
+ sh->SubroutineUniformRemapTable[j] =
+ (gl_uniform_storage *) uni_ptr;
+ } else {
+ intptr_t uni_offset =
+ (uni_ptr - uni_store_base) / sizeof(gl_uniform_storage);
+ sh->SubroutineUniformRemapTable[j] =
+ prog->UniformStorage + uni_offset;
+ }
+ }
+ }
+ }
}
struct whte_closure
@@ -689,11 +726,11 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
write_hash_tables(metadata, prog);
- write_uniform_remap_table(metadata, prog);
-
write_shader_metadata(metadata, prog->_LinkedShaders[MESA_SHADER_VERTEX]);
write_shader_metadata(metadata, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]);
+ write_uniform_remap_tables(metadata, prog);
+
write_subroutines(metadata, prog);
write_program_resource_list(metadata, prog);
@@ -788,8 +825,6 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
read_hash_tables(&metadata, prog);
- read_uniform_remap_table(&metadata, prog);
-
_mesa_HashLockMutex(ctx->Shared->ShaderObjects);
unsigned name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1);
linked = ctx->Driver.NewShader(ctx, name, GL_VERTEX_SHADER);
@@ -814,6 +849,8 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
_mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
linked);
+ read_uniform_remap_tables(&metadata, prog);
+
read_subroutines(&metadata, prog);
read_program_resource_list(&metadata, prog);
--
2.5.5
More information about the mesa-dev
mailing list