[Mesa-dev] [PATCH 2/3] mesa: Map program UBOs and SSBOs to Interface Blocks

Jordan Justen jordan.l.justen at intel.com
Tue Oct 27 22:38:22 PDT 2015


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Cc: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Cc: Iago Toral Quiroga <itoral at igalia.com>
---
 src/glsl/linker.cpp                 | 14 ++++++++++++++
 src/glsl/standalone_scaffolding.cpp |  5 +++++
 src/mesa/main/mtypes.h              |  7 +++++++
 3 files changed, 26 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3db2fd3..d925393 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -4448,6 +4448,20 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
                         &prog->ShaderStorageBlocks,
                         &prog->NumShaderStorageBlocks);
 
+   prog->UboInterfaceBlockIndex =
+      ralloc_array(prog, int, prog->NumUniformBlocks);
+   prog->SsboInterfaceBlockIndex =
+      ralloc_array(prog, int, prog->NumShaderStorageBlocks);
+   for (unsigned i = 0, u = 0, s = 0;
+        i < prog->NumBufferInterfaceBlocks;
+        i++) {
+      if (prog->BufferInterfaceBlocks[i].IsShaderStorage) {
+         prog->SsboInterfaceBlockIndex[s++] = i;
+      } else {
+         prog->UboInterfaceBlockIndex[u++] = i;
+      }
+   }
+
    /* FINISHME: Assign fragment shader output locations. */
 
 done:
diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
index fe1d820..5c76295 100644
--- a/src/glsl/standalone_scaffolding.cpp
+++ b/src/glsl/standalone_scaffolding.cpp
@@ -124,6 +124,11 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
       shProg->InterfaceBlockStageIndex[i] = NULL;
    }
 
+   ralloc_free(shProg->UboInterfaceBlockIndex);
+   shProg->UboInterfaceBlockIndex = NULL;
+   ralloc_free(shProg->SsboInterfaceBlockIndex);
+   shProg->SsboInterfaceBlockIndex = NULL;
+
    ralloc_free(shProg->AtomicBuffers);
    shProg->AtomicBuffers = NULL;
    shProg->NumAtomicBuffers = 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index cce959e..c1cbe96 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2725,6 +2725,13 @@ struct gl_shader_program
    int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
 
    /**
+    * Indices into the BufferInterfaceBlocks[] array for Uniform Buffer
+    * Objects and Shader Storage Buffer Objects.
+    */
+   int *UboInterfaceBlockIndex;
+   int *SsboInterfaceBlockIndex;
+
+   /**
     * Map of active uniform names to locations
     *
     * Maps any active uniform that is not an array element to a location.
-- 
2.5.1



More information about the mesa-dev mailing list