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

Timothy Arceri timothy.arceri at collabora.com
Fri Apr 29 13:33:16 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 98015c4..0c9ae9f 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -179,11 +179,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]);
    }
 }
 
@@ -191,16 +191,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.5.5



More information about the mesa-dev mailing list