summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2019-01-28 17:15:34 +1100
committerEmil Velikov <emil.l.velikov@gmail.com>2019-01-29 17:44:27 +0000
commit3b9e9e4723106dc0e8f3fb049026f3ef66f4f6c0 (patch)
tree2a1e20000319a0926030da55d1a4a23dd4063cba
parent12586d58462aabce553dc09070c95cc6b51e1ce7 (diff)
glsl: use remap location when serialising uniform program resource data
This allows us to avoid expensive string compares since we already have a map to the pointers. These compares were taking ~30 seconds for a single shader compile in Godot due to it using 64,000+ uniforms. Fixes: c4cff5f40254 ("glsl: add basic support for resource list to shader cache") Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109229 (cherry picked from commit fb78a6cb72270de271f75d6f6c9b5ebadba7a898)
-rw-r--r--src/compiler/glsl/serialize.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/compiler/glsl/serialize.cpp b/src/compiler/glsl/serialize.cpp
index 26d8ec4b75b..fdd99ec59da 100644
--- a/src/compiler/glsl/serialize.cpp
+++ b/src/compiler/glsl/serialize.cpp
@@ -764,6 +764,12 @@ get_shader_var_and_pointer_sizes(size_t *s_var_size, size_t *s_var_ptrs,
sizeof(var->name);
}
+enum uniform_type
+{
+ uniform_remapped,
+ uniform_not_remapped
+};
+
static void
write_program_resource_data(struct blob *metadata,
struct gl_shader_program *prog,
@@ -816,12 +822,19 @@ write_program_resource_data(struct blob *metadata,
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
case GL_UNIFORM:
- for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
- if (strcmp(((gl_uniform_storage *)res->Data)->name,
- prog->data->UniformStorage[i].name) == 0) {
- blob_write_uint32(metadata, i);
- break;
+ if (((gl_uniform_storage *)res->Data)->builtin ||
+ res->Type != GL_UNIFORM) {
+ blob_write_uint32(metadata, uniform_not_remapped);
+ for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+ if (strcmp(((gl_uniform_storage *)res->Data)->name,
+ prog->data->UniformStorage[i].name) == 0) {
+ blob_write_uint32(metadata, i);
+ break;
+ }
}
+ } else {
+ blob_write_uint32(metadata, uniform_remapped);
+ blob_write_uint32(metadata, ((gl_uniform_storage *)res->Data)->remap_location);
}
break;
case GL_ATOMIC_COUNTER_BUFFER:
@@ -906,9 +919,15 @@ read_program_resource_data(struct blob_reader *metadata,
case GL_COMPUTE_SUBROUTINE_UNIFORM:
case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
- case GL_UNIFORM:
- res->Data = &prog->data->UniformStorage[blob_read_uint32(metadata)];
+ case GL_UNIFORM: {
+ enum uniform_type type = (enum uniform_type) blob_read_uint32(metadata);
+ if (type == uniform_not_remapped) {
+ res->Data = &prog->data->UniformStorage[blob_read_uint32(metadata)];
+ } else {
+ res->Data = prog->UniformRemapTable[blob_read_uint32(metadata)];
+ }
break;
+ }
case GL_ATOMIC_COUNTER_BUFFER:
res->Data = &prog->data->AtomicBuffers[blob_read_uint32(metadata)];
break;