From 9a971ab695d8f3c58a5fb0f359443b6b053f0b97 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 13 Dec 2012 02:13:30 -0800 Subject: mesa: Track the packing mode of a UBO in gl_uniform_buffer 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 Reviewed-by: Chad Versace Reviewed-by: Kenneth Graunke --- src/glsl/ast_to_hir.cpp | 10 ++++++++++ src/mesa/main/mtypes.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index e76544a2c4c..b73e6205905 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -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) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d37e6c4c04d..4c7cc6099ca 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; }; /** -- cgit v1.2.3