MSL: Consider changed array types for array-of-constant-bool in struct.

This commit is contained in:
Hans-Kristian Arntzen 2023-06-07 13:54:50 +02:00
parent 8735108609
commit 13e6981cc8
2 changed files with 14 additions and 2 deletions

View File

@ -93,6 +93,6 @@ fragment void main0()
spvUnsafeArray<bool3, 2> c2 = { bool3(t2.c[0]), bool3(t2.c[1]) };
spvUnsafeArray<bool4, 2> d2 = { bool4(t2.d[0]), bool4(t2.d[1]) };
t = Test{ short(true), short2(bool2(true, false)), short3(bool3(true)), short4(bool4(false)) };
t2 = Test2{ spvUnsafeArray<bool, 2>({ short(true), short(true) }), spvUnsafeArray<bool2, 2>({ short2(bool2(true)), short2(bool2(false)) }), spvUnsafeArray<bool3, 2>({ short3(bool3(true)), short3(bool3(false)) }), spvUnsafeArray<bool4, 2>({ short4(bool4(true)), short4(bool4(false)) }), Test{ short(true), short2(bool2(true, false)), short3(bool3(true)), short4(bool4(false)) } };
t2 = Test2{ spvUnsafeArray<short, 2>({ short(true), short(true) }), spvUnsafeArray<short2, 2>({ short2(bool2(true)), short2(bool2(false)) }), spvUnsafeArray<short3, 2>({ short3(bool3(true)), short3(bool3(false)) }), spvUnsafeArray<short4, 2>({ short4(bool4(true)), short4(bool4(false)) }), Test{ short(true), short2(bool2(true, false)), short3(bool3(true)), short4(bool4(false)) } };
}

View File

@ -5737,7 +5737,19 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c,
else if (backend.use_initializer_list && backend.use_typed_initializer_list && backend.array_is_value_type &&
type_is_top_level_array(type) && !array_type_decays)
{
res = type_to_glsl_constructor(type) + "({ ";
const auto *p_type = &type;
SPIRType tmp_type;
if (inside_struct_scope &&
backend.boolean_in_struct_remapped_type != SPIRType::Boolean &&
type.basetype == SPIRType::Boolean)
{
tmp_type = type;
tmp_type.basetype = backend.boolean_in_struct_remapped_type;
p_type = &tmp_type;
}
res = type_to_glsl_constructor(*p_type) + "({ ";
needs_trailing_tracket = true;
}
else if (backend.use_initializer_list)