[Mesa-dev] [PATCH 59/77] glsl: add shader cache support for geometry shaders

Timothy Arceri timothy.arceri at collabora.com
Mon Oct 3 06:05:18 UTC 2016


---
 src/compiler/glsl/shader_cache.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 9b37155..c26974c 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1040,6 +1040,13 @@ write_shader_metadata(struct blob *metadata, gl_linked_shader *shader)
       blob_write_bytes(metadata, shader->ImageUnits,
                        sizeof(shader->ImageUnits));
 
+      if (shader->Stage == MESA_SHADER_GEOMETRY) {
+         blob_write_uint32(metadata, shader->info.Geom.VerticesOut);
+         blob_write_uint32(metadata, shader->info.Geom.Invocations);
+         blob_write_uint32(metadata, shader->info.Geom.InputType);
+         blob_write_uint32(metadata, shader->info.Geom.OutputType);
+      }
+
       if (shader->Stage == MESA_SHADER_FRAGMENT) {
          struct gl_fragment_program *fprog =
             (struct gl_fragment_program *) glprog;
@@ -1091,6 +1098,13 @@ read_shader_metadata(struct blob_reader *metadata,
       blob_copy_bytes(metadata, (uint8_t *) linked->ImageUnits,
                       sizeof(linked->ImageUnits));
 
+      if (linked->Stage == MESA_SHADER_GEOMETRY) {
+         linked->info.Geom.VerticesOut = blob_read_uint32(metadata);
+         linked->info.Geom.Invocations = blob_read_uint32(metadata);
+         linked->info.Geom.InputType = blob_read_uint32(metadata);
+         linked->info.Geom.OutputType = blob_read_uint32(metadata);
+      }
+
       if (linked->Stage == MESA_SHADER_FRAGMENT) {
          struct gl_fragment_program *fprog =
             (struct gl_fragment_program *) glprog;
@@ -1148,8 +1162,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
    /* We should be able to serialize any valid combinations of shaders, but
     * for now we only support vs and fs.
     */
-   if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY] ||
-       prog->_LinkedShaders[MESA_SHADER_TESS_EVAL] ||
+   if (prog->_LinkedShaders[MESA_SHADER_TESS_EVAL] ||
        prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] ||
        prog->_LinkedShaders[MESA_SHADER_COMPUTE])
       return;
@@ -1215,6 +1228,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
 
    for (unsigned i = 0; i < prog->NumShaders; i++) {
       if (prog->Shaders[i]->Stage != MESA_SHADER_VERTEX &&
+          prog->Shaders[i]->Stage != MESA_SHADER_GEOMETRY &&
           prog->Shaders[i]->Stage != MESA_SHADER_FRAGMENT) {
          compile_shaders(ctx, prog);
          return false;
-- 
2.7.4



More information about the mesa-dev mailing list