X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fspirv.cpp;h=07d4eb072c0989eb1745405aae0c85ea2ae59fc7;hb=145fcb8a11096f3db31e938d14196cc8ade6aa7b;hp=7f99ebb3d9ecc61b737739542feed5a72994633f;hpb=0d5ff7918d50092d8cf2e1b8f7af1d7d29b6eb9b;p=libs%2Fgl.git diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 7f99ebb3..07d4eb07 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -338,10 +338,10 @@ bool SpirVGenerator::is_scalar_type(Id type_id, BasicTypeDeclaration::Kind kind) return (i!=standard_type_ids.end() && i->second==type_id); } -SpirVGenerator::Id SpirVGenerator::get_array_type_id(TypeDeclaration &base_type, Id size_id) +SpirVGenerator::Id SpirVGenerator::get_array_type_id(TypeDeclaration &base_type, Id size_id, bool extended_align) { Id base_type_id = get_id(base_type); - Id &array_type_id = array_type_ids[TypeKey(base_type_id, size_id)]; + Id &array_type_id = array_type_ids[TypeKey(base_type_id, extended_align*0x400000 | size_id)]; if(!array_type_id) { array_type_id = next_id++; @@ -351,6 +351,8 @@ SpirVGenerator::Id SpirVGenerator::get_array_type_id(TypeDeclaration &base_type, writer.write_op(content.globals, OP_TYPE_RUNTIME_ARRAY, array_type_id, base_type_id); unsigned stride = MemoryRequirementsCalculator().apply(base_type).stride; + if(extended_align) + stride = (stride+15)&~15U; writer.write_op_decorate(array_type_id, DECO_ARRAY_STRIDE, stride); } @@ -383,7 +385,7 @@ SpirVGenerator::Id SpirVGenerator::get_variable_type_id(const VariableDeclaratio } else size_id = get_constant_id(get_standard_type_id(BasicTypeDeclaration::INT, 1), 1); - return get_array_type_id(*basic->base_type, size_id); + return get_array_type_id(*basic->base_type, size_id, true); } return get_id(*var.type_declaration); @@ -1683,7 +1685,7 @@ void SpirVGenerator::visit(InterfaceBlock &iface) StorageClass storage = (push_const ? STORAGE_PUSH_CONSTANT : get_interface_storage(iface.interface, true)); Id type_id; if(iface.array) - type_id = get_array_type_id(*iface.struct_declaration, 0); + type_id = get_array_type_id(*iface.struct_declaration, 0, true); else type_id = get_id(*iface.struct_declaration); Id ptr_type_id = get_pointer_type_id(type_id, storage);