diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index c9796f86..0705e378 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -7567,7 +7567,7 @@ bool CompilerGLSL::remove_unity_swizzle(uint32_t base, string &op) auto &type = expression_type(base); // Sanity checking ... - assert(type.columns == 1 && type.array.empty()); + assert(type.columns == 1); // && type.array.empty() if (type.vecsize == final_swiz.size()) op.erase(pos, string::npos); diff --git a/spirv_msl.cpp b/spirv_msl.cpp index ce575b1c..b7e0b048 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -8014,7 +8014,7 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ SPIRType row_major_physical_type; const SPIRType *declared_type = &physical_type; - if (member_is_packed_physical_type(type, index)) + if (member_is_packed_physical_type(type, index) && validate_member_packing_rules_msl(type, index)) { // If we're packing a matrix, output an appropriate typedef if (physical_type.basetype == SPIRType::Struct) @@ -11941,7 +11941,15 @@ std::string CompilerMSL::access_chain_internal(uint32_t base, const uint32_t *in else if (ir.meta[base].decoration.builtin_type != BuiltInSampleMask) /* UE Change End: Sample mask input for Metal is not an array */ { - append_index(index); + if (is_packed) + { + if (!remove_duplicate_swizzle(expr)) + remove_unity_swizzle(base, expr); + append_index(index); + expr = unpack_expression_type(expr, *type, physical_type, is_packed, true); + } + else + append_index(index); } type_id = type->parent_type;