mesa: Track the packing mode of a UBO in gl_uniform_buffer
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 13 Dec 2012 10:13:30 +0000 (02:13 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 25 Jan 2013 14:07:33 +0000 (09:07 -0500)
This allows the next patch to verify that two uniform blocks match
without first calculating the locations of the fields.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ast_to_hir.cpp
src/mesa/main/mtypes.h

index e76544a2c4c94e3ad550a1214605e74a33f5a18b..b73e620590552604fcfb2674ea0b8b4bca8a28c2 100644 (file)
@@ -4136,6 +4136,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) {
index d37e6c4c04d79d865c1aa4121666b6ce0dc58c19..4c7cc6099cab6aa60c1473940a5852b5bf212c99 100644 (file)
@@ -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;
 };
 
 /**