summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/shader_cache.cpp
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-04-12 17:20:49 +1000
committerTimothy Arceri <[email protected]>2017-02-17 11:18:42 +1100
commit3c45d8f4642b86eeecd7b8c30b4e6225d4e9ebdc (patch)
treed411f61f3af3e0d179bffcb96e120bc1de836bd2 /src/compiler/glsl/shader_cache.cpp
parenta01973a78450573ab5bc66bbabd2bcd50a783a8e (diff)
glsl: fix uniform remap table cache when explicit locations used
V2: don't store pointers use an enum instead to flag what should be restored. Also do the work in a helper that we will later use for the subroutine remap table. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler/glsl/shader_cache.cpp')
-rw-r--r--src/compiler/glsl/shader_cache.cpp56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index b0f8e025668..cc34ef1de8e 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -57,7 +57,7 @@
#include "main/core.h"
#include "nir.h"
#include "program.h"
-#include "util/disk_cache.h"
+#include "shader_cache.h"
#include "util/mesa-sha1.h"
#include "util/string_to_uint_map.h"
@@ -275,6 +275,29 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
}
}
+enum uniform_remap_type
+{
+ remap_type_inactive_explicit_location,
+ remap_type_null_ptr,
+ remap_type_uniform_offset
+};
+
+static void
+write_uniform_remap_table_entry(struct blob *metadata,
+ gl_uniform_storage *uniform_storage,
+ gl_uniform_storage *entry)
+{
+ if (entry == INACTIVE_UNIFORM_EXPLICIT_LOCATION) {
+ blob_write_uint32(metadata, remap_type_inactive_explicit_location);
+ } else if (entry == NULL) {
+ blob_write_uint32(metadata, remap_type_null_ptr);
+ } else {
+ blob_write_uint32(metadata, remap_type_uniform_offset);
+
+ uint32_t offset = entry - uniform_storage;
+ blob_write_uint32(metadata, offset);
+ }
+}
static void
write_uniform_remap_table(struct blob *metadata,
@@ -283,8 +306,24 @@ 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->data->UniformStorage);
+ write_uniform_remap_table_entry(metadata, prog->data->UniformStorage,
+ prog->UniformRemapTable[i]);
+ }
+}
+
+static void
+read_uniform_remap_table_entry(struct blob_reader *metadata,
+ gl_uniform_storage *uniform_storage,
+ gl_uniform_storage **entry,
+ enum uniform_remap_type type)
+{
+ if (type == remap_type_inactive_explicit_location) {
+ *entry = INACTIVE_UNIFORM_EXPLICIT_LOCATION;
+ } else if (type == remap_type_null_ptr) {
+ *entry = NULL;
+ } else {
+ uint32_t uni_offset = blob_read_uint32(metadata);
+ *entry = uniform_storage + uni_offset;
}
}
@@ -294,12 +333,15 @@ read_uniform_remap_table(struct blob_reader *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 (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
- prog->UniformRemapTable[i] =
- prog->data->UniformStorage + blob_read_uint32(metadata);
+ enum uniform_remap_type type =
+ (enum uniform_remap_type) blob_read_uint32(metadata);
+
+ read_uniform_remap_table_entry(metadata, prog->data->UniformStorage,
+ &prog->UniformRemapTable[i], type);
}
}