[Mesa-dev] [PATCH 14/77] glsl: fix uniform remap table cache when explicit locations used
Timothy Arceri
timothy.arceri at collabora.com
Mon Oct 3 06:04:33 UTC 2016
---
src/compiler/glsl/shader_cache.cpp | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 08927d9..529ec71 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -44,6 +44,7 @@
#include "util/string_to_uint_map.h"
#include "blob.h"
#include "cache.h"
+#include "shader_cache.h"
extern "C" {
#include "main/shaderobj.h"
@@ -176,8 +177,19 @@ write_uniform_remap_table(struct blob *metadata,
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_uint64(metadata,
+ ptr_to_uint64_t(prog->UniformRemapTable[i]));
+
+ if (prog->UniformRemapTable[i] != INACTIVE_UNIFORM_EXPLICIT_LOCATION &&
+ prog->UniformRemapTable[i] != NULL) {
+
+ /* Here we store the offset rather than calculating it on restore
+ * because gl_uniform_storage may have a different size on the
+ * platform we are restoring the cache on.
+ */
+ uint32_t offset = prog->UniformRemapTable[i] - prog->UniformStorage;
+ blob_write_uint32(metadata, offset);
+ }
}
}
@@ -185,16 +197,20 @@ static void
read_uniform_remap_table(struct blob_reader *metadata,
struct gl_shader_program *prog)
{
- unsigned i;
-
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++) {
+ uint64_t uni_ptr = blob_read_uint64(metadata);
+ if (uni_ptr == (uint64_t) INACTIVE_UNIFORM_EXPLICIT_LOCATION ||
+ uni_ptr == (uint64_t) NULL) {
+ prog->UniformRemapTable[i] = (gl_uniform_storage *) uni_ptr;
+ } else {
+ uint32_t uni_offset = blob_read_uint32(metadata);
+ prog->UniformRemapTable[i] = prog->UniformStorage + uni_offset;
+ }
}
}
--
2.7.4
More information about the mesa-dev
mailing list