[Mesa-dev] [PATCH 02/32] mesa: Track the packing mode of a UBO in gl_uniform_buffer

Ian Romanick idr at freedesktop.org
Tue Jan 22 00:51:53 PST 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/ast_to_hir.cpp | 10 ++++++++++
 src/mesa/main/mtypes.h  | 14 ++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e016ccf..c432369 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4134,6 +4134,16 @@ ast_uniform_block::hir(exec_list *instructions,
                        "the current scope.\n", ubo->Name);
    }
 
+   if (this->layout.flags.q.shared) {
+      ubo->_Packing = ubo_packing_shared;
+   } else if (this->layout.flags.q.packed) {
+      ubo->_Packing = ubo_packing_packed;
+   } else {
+      /* The default layout is std140.
+       */
+      ubo->_Packing = ubo_packing_std140;
+   }
+
    unsigned int num_variables = 0;
    foreach_list_typed(ast_declarator_list, decl_list, link, &declarations) {
       foreach_list_const(node, &decl_list->declarations) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ead75d5..1808717 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2278,6 +2278,12 @@ struct gl_uniform_buffer_variable
    GLboolean RowMajor;
 };
 
+enum gl_uniform_block_packing {
+   ubo_packing_std140,
+   ubo_packing_shared,
+   ubo_packing_packed
+};
+
 struct gl_uniform_block
 {
    /** Declared name of the uniform block */
@@ -2299,6 +2305,14 @@ struct gl_uniform_block
     * (GL_UNIFORM_BLOCK_DATA_SIZE).
     */
    GLuint UniformBufferSize;
+
+   /**
+    * Layout specified in the shader
+    *
+    * This isn't accessible through the API, but it is used while
+    * cross-validating uniform blocks.
+    */
+   enum gl_uniform_block_packing _Packing;
 };
 
 /**
-- 
1.7.11.7



More information about the mesa-dev mailing list