diff options
-rw-r--r-- | src/glsl/ast.h | 1 | ||||
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 21 | ||||
-rw-r--r-- | src/glsl/ast_type.cpp | 2 | ||||
-rw-r--r-- | src/glsl/glsl_parser.yy | 2 | ||||
-rw-r--r-- | src/glsl/glsl_types.h | 3 | ||||
-rw-r--r-- | src/glsl/link_uniform_blocks.cpp | 15 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 3 |
7 files changed, 38 insertions, 9 deletions
diff --git a/src/glsl/ast.h b/src/glsl/ast.h index cca32b334b2..4c314366133 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -491,6 +491,7 @@ struct ast_type_qualifier { /** \name Layout qualifiers for GL_ARB_uniform_buffer_object */ /** \{ */ unsigned std140:1; + unsigned std430:1; unsigned shared:1; unsigned packed:1; unsigned column_major:1; diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 92038a62d81..d6071ef59fc 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2920,11 +2920,13 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, var->data.depth_layout = ir_depth_layout_none; if (qual->flags.q.std140 || + qual->flags.q.std430 || qual->flags.q.packed || qual->flags.q.shared) { _mesa_glsl_error(loc, state, - "uniform block layout qualifiers std140, packed, and " - "shared can only be applied to uniform blocks, not " + "uniform and shader storage block layout qualifiers " + "std140, std430, packed, and shared can only be " + "applied to uniform or shader storage blocks, not " "members"); } @@ -5691,12 +5693,14 @@ ast_process_structure_or_interface_block(exec_list *instructions, const struct ast_type_qualifier *const qual = & decl_list->type->qualifier; if (qual->flags.q.std140 || + qual->flags.q.std430 || qual->flags.q.packed || qual->flags.q.shared) { _mesa_glsl_error(&loc, state, "uniform/shader storage block layout qualifiers " - "std140, packed, and shared can only be applied " - "to uniform/shader storage blocks, not members"); + "std140, std430, packed, and shared can only be " + "applied to uniform/shader storage blocks, not " + "members"); } if (qual->flags.q.constant) { @@ -5908,6 +5912,13 @@ ast_interface_block::hir(exec_list *instructions, this->block_name); } + if (!this->layout.flags.q.buffer && + this->layout.flags.q.std430) { + _mesa_glsl_error(&loc, state, + "std430 storage block layout qualifier is supported " + "only for shader storage blocks"); + } + /* The ast_interface_block has a list of ast_declarator_lists. We * need to turn those into ir_variables with an association * with this uniform block. @@ -5917,6 +5928,8 @@ ast_interface_block::hir(exec_list *instructions, packing = GLSL_INTERFACE_PACKING_SHARED; } else if (this->layout.flags.q.packed) { packing = GLSL_INTERFACE_PACKING_PACKED; + } else if (this->layout.flags.q.std430) { + packing = GLSL_INTERFACE_PACKING_STD430; } else { /* The default layout is std140. */ diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index a4671e203e2..08a4504296b 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -65,6 +65,7 @@ ast_type_qualifier::has_layout() const || this->flags.q.depth_less || this->flags.q.depth_unchanged || this->flags.q.std140 + || this->flags.q.std430 || this->flags.q.shared || this->flags.q.column_major || this->flags.q.row_major @@ -123,6 +124,7 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc, ubo_layout_mask.flags.q.std140 = 1; ubo_layout_mask.flags.q.packed = 1; ubo_layout_mask.flags.q.shared = 1; + ubo_layout_mask.flags.q.std430 = 1; ast_type_qualifier ubo_binding_mask; ubo_binding_mask.flags.i = 0; diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 028974e7eb9..4cb018a5862 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -1199,6 +1199,8 @@ layout_qualifier_id: $$.flags.q.std140 = 1; } else if (match_layout_qualifier($1, "shared", state) == 0) { $$.flags.q.shared = 1; + } else if (match_layout_qualifier($1, "std430", state) == 0) { + $$.flags.q.std430 = 1; } else if (match_layout_qualifier($1, "column_major", state) == 0) { $$.flags.q.column_major = 1; /* "row_major" is a reserved word in GLSL 1.30+. Its token is parsed diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 785f5aa74bf..d58d8189e21 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -77,7 +77,8 @@ enum glsl_sampler_dim { enum glsl_interface_packing { GLSL_INTERFACE_PACKING_STD140, GLSL_INTERFACE_PACKING_SHARED, - GLSL_INTERFACE_PACKING_PACKED + GLSL_INTERFACE_PACKING_PACKED, + GLSL_INTERFACE_PACKING_STD430 }; enum glsl_matrix_layout { diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp index 4df39e200d5..c891d030234 100644 --- a/src/glsl/link_uniform_blocks.cpp +++ b/src/glsl/link_uniform_blocks.cpp @@ -119,8 +119,16 @@ private: v->IndexName = v->Name; } - const unsigned alignment = type->std140_base_alignment(v->RowMajor); - unsigned size = type->std140_size(v->RowMajor); + unsigned alignment = 0; + unsigned size = 0; + + if (v->Type->interface_packing == GLSL_INTERFACE_PACKING_STD430) { + alignment = type->std430_base_alignment(v->RowMajor); + size = type->std430_size(v->RowMajor); + } else { + alignment = type->std140_base_alignment(v->RowMajor); + size = type->std140_size(v->RowMajor); + } this->offset = glsl_align(this->offset, alignment); v->Offset = this->offset; @@ -255,7 +263,8 @@ link_uniform_blocks(void *mem_ctx, == unsigned(ubo_packing_shared)); STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_PACKED) == unsigned(ubo_packing_packed)); - + STATIC_ASSERT(unsigned(GLSL_INTERFACE_PACKING_STD430) + == unsigned(ubo_packing_std430)); hash_table_foreach (block_hash, entry) { const struct link_uniform_block_active *const b = diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 22b1d14636f..d53d99ad843 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2454,7 +2454,8 @@ enum gl_uniform_block_packing { ubo_packing_std140, ubo_packing_shared, - ubo_packing_packed + ubo_packing_packed, + ubo_packing_std430 }; |