[Mesa-dev] [PATCH 16/88] glsl: fix uniform remap table cache when explicit locations used

Timothy Arceri timothy.arceri at collabora.com
Sat Sep 24 05:24:57 UTC 2016


---
 src/compiler/glsl/shader_cache.cpp | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 08927d9..10e94c8 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -173,11 +173,11 @@ static void
 write_uniform_remap_table(struct blob *metadata,
                           struct gl_shader_program *prog)
 {
+   blob_write_intptr(metadata, (intptr_t) prog->UniformStorage);
    blob_write_uint32(metadata, prog->NumUniformRemapTable);
 
    for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
-      blob_write_uint32(metadata,
-                        prog->UniformRemapTable[i] - prog->UniformStorage);
+      blob_write_intptr(metadata, (intptr_t) prog->UniformRemapTable[i]);
    }
 }
 
@@ -185,16 +185,22 @@ static void
 read_uniform_remap_table(struct blob_reader *metadata,
                          struct gl_shader_program *prog)
 {
-   unsigned i;
-
+   intptr_t uni_store_base = blob_read_intptr(metadata);
    prog->NumUniformRemapTable = blob_read_uint32(metadata);
 
-   prog->UniformRemapTable =rzalloc_array(prog, struct gl_uniform_storage *,
-                                          prog->NumUniformRemapTable);
+   prog->UniformRemapTable = rzalloc_array(prog, struct gl_uniform_storage *,
+                                           prog->NumUniformRemapTable);
 
-   for (i = 0; i < prog->NumUniformRemapTable; i++) {
-      prog->UniformRemapTable[i] =
-         prog->UniformStorage + blob_read_uint32(metadata);
+   for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
+      intptr_t uni_ptr = blob_read_intptr(metadata);
+      if (uni_ptr == (intptr_t) INACTIVE_UNIFORM_EXPLICIT_LOCATION ||
+          uni_ptr == (intptr_t) NULL) {
+         prog->UniformRemapTable[i] = (gl_uniform_storage *) uni_ptr;
+      } else {
+         intptr_t uni_offset =
+            (uni_ptr - uni_store_base) / sizeof(gl_uniform_storage);
+         prog->UniformRemapTable[i] = prog->UniformStorage + uni_offset;
+      }
    }
 }
 
-- 
2.7.4



More information about the mesa-dev mailing list