[Mesa-dev] [PATCH 14/40] glsl: store subroutine remap table in shader cache
Timothy Arceri
tarceri at itsqueeze.com
Tue Feb 7 03:42:18 UTC 2017
From: Timothy Arceri <timothy.arceri at collabora.com>
---
src/compiler/glsl/shader_cache.cpp | 57 ++++++++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 6 deletions(-)
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 7d651bc..deabc2a 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -423,8 +423,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_uint32(metadata, prog->NumUniformRemapTable);
@@ -444,11 +444,31 @@ write_uniform_remap_table(struct blob *metadata,
blob_write_uint32(metadata, offset);
}
}
+
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
+ if (sh) {
+ struct gl_program *glprog = sh->Program;
+ blob_write_uint32(metadata, glprog->sh.NumSubroutineUniformRemapTable);
+
+ for (unsigned j = 0; j < glprog->sh.NumSubroutineUniformRemapTable; j++) {
+ struct gl_uniform_storage *sr =
+ glprog->sh.SubroutineUniformRemapTable[j];
+
+ blob_write_uint64(metadata, ptr_to_uint64_t(sr));
+
+ if (sr != INACTIVE_UNIFORM_EXPLICIT_LOCATION && sr != NULL) {
+ uint32_t offset = sr - prog->data->UniformStorage;
+ blob_write_uint32(metadata, offset);
+ }
+ }
+ }
+ }
}
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)
{
prog->NumUniformRemapTable = blob_read_uint32(metadata);
@@ -465,6 +485,31 @@ read_uniform_remap_table(struct blob_reader *metadata,
prog->UniformRemapTable[i] = prog->data->UniformStorage + uni_offset;
}
}
+
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
+ if (sh) {
+ struct gl_program *glprog = sh->Program;
+ glprog->sh.NumSubroutineUniformRemapTable = blob_read_uint32(metadata);
+
+ glprog->sh.SubroutineUniformRemapTable =
+ rzalloc_array(glprog, struct gl_uniform_storage *,
+ glprog->sh.NumSubroutineUniformRemapTable);
+
+ for (unsigned j = 0; j < glprog->sh.NumSubroutineUniformRemapTable; j++) {
+ uint64_t uni_ptr = blob_read_uint64(metadata);
+ if (uni_ptr == (uint64_t) INACTIVE_UNIFORM_EXPLICIT_LOCATION ||
+ uni_ptr == (uint64_t) NULL) {
+ glprog->sh.SubroutineUniformRemapTable[j] =
+ (gl_uniform_storage *) uni_ptr;
+ } else {
+ uint32_t uni_offset = blob_read_uint32(metadata);
+ glprog->sh.SubroutineUniformRemapTable[j] =
+ prog->data->UniformStorage + uni_offset;
+ }
+ }
+ }
+ }
}
struct whte_closure
@@ -898,7 +943,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
write_xfb(metadata, prog);
- write_uniform_remap_table(metadata, prog);
+ write_uniform_remap_tables(metadata, prog);
write_subroutines(metadata, prog);
@@ -1015,7 +1060,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
read_xfb(&metadata, prog);
- read_uniform_remap_table(&metadata, prog);
+ read_uniform_remap_tables(&metadata, prog);
read_subroutines(&metadata, prog);
--
2.9.3
More information about the mesa-dev
mailing list