[Mesa-dev] [PATCH 21/77] glsl: add shader cache support for samplers

Timothy Arceri timothy.arceri at collabora.com
Mon Oct 3 06:04:40 UTC 2016


---
 src/compiler/glsl/shader_cache.cpp | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index abbd696..4903980 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -154,6 +154,8 @@ write_uniforms(struct blob *metadata, struct gl_shader_program *prog)
                         prog->UniformStorage[i].top_level_array_size);
       blob_write_uint32(metadata,
                         prog->UniformStorage[i].top_level_array_stride);
+      blob_write_bytes(metadata, prog->UniformStorage[i].opaque,
+                       sizeof(prog->UniformStorage[i].opaque));
    }
 }
 
@@ -194,6 +196,10 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
       uniforms[i].top_level_array_size = blob_read_uint32(metadata);
       uniforms[i].top_level_array_stride = blob_read_uint32(metadata);
       prog->UniformHash->put(i, uniforms[i].name);
+
+      memcpy(uniforms[i].opaque,
+             blob_read_bytes(metadata, sizeof(uniforms[i].opaque)),
+             sizeof(uniforms[i].opaque));
    }
 }
 
@@ -484,10 +490,20 @@ write_shader_metadata(struct blob *metadata, gl_linked_shader *shader)
       /* Use the lowest bit to indicate that there is shader_metadata here. */
       blob_write_uint64(metadata, glprog->InputsRead << 1 | 1);
       blob_write_uint64(metadata, glprog->OutputsWritten);
+
+      blob_write_uint32(metadata, glprog->UsesGather);
       blob_write_bytes(metadata, glprog->TexturesUsed,
                        sizeof(glprog->TexturesUsed));
-      blob_write_uint64(metadata, glprog->SamplersUsed);
-      blob_write_uint64(metadata, shader->num_samplers);
+      blob_write_bytes(metadata, glprog->SamplerUnits,
+                       sizeof(glprog->SamplerUnits));
+      blob_write_bytes(metadata, shader->SamplerUnits,
+                       sizeof(shader->SamplerUnits));
+      blob_write_bytes(metadata, shader->SamplerTargets,
+                       sizeof(shader->SamplerTargets));
+      blob_write_uint32(metadata, glprog->SamplersUsed);
+      blob_write_uint32(metadata, glprog->ShadowSamplers);
+      blob_write_uint32(metadata, shader->num_samplers);
+      blob_write_uint32(metadata, shader->active_samplers);
 
       write_shader_parameters(metadata, glprog->Parameters);
 
@@ -509,10 +525,20 @@ read_shader_metadata(struct blob_reader *metadata,
    if (has_shader) {
       glprog->InputsRead = has_shader >> 1;
       glprog->OutputsWritten = blob_read_uint64(metadata);
+
+      glprog->UsesGather = blob_read_uint32(metadata);
       blob_copy_bytes(metadata, (uint8_t *) glprog->TexturesUsed,
                       sizeof(glprog->TexturesUsed));
-      glprog->SamplersUsed = blob_read_uint64(metadata);
-      linked->num_samplers = blob_read_uint64(metadata);
+      blob_copy_bytes(metadata, (uint8_t *) glprog->SamplerUnits,
+                      sizeof(glprog->SamplerUnits));
+      blob_copy_bytes(metadata, (uint8_t *) linked->SamplerUnits,
+                      sizeof(linked->SamplerUnits));
+      blob_copy_bytes(metadata, (uint8_t *) linked->SamplerTargets,
+                      sizeof(linked->SamplerTargets));
+      glprog->SamplersUsed = blob_read_uint32(metadata);
+      glprog->ShadowSamplers = blob_read_uint32(metadata);
+      linked->num_samplers = blob_read_uint32(metadata);
+      linked->active_samplers = blob_read_uint32(metadata);
 
       glprog->Parameters = _mesa_new_parameter_list();
 
-- 
2.7.4



More information about the mesa-dev mailing list