diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-01-06 12:33:17 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-01-06 12:33:17 +0300 |
commit | ab9200ffdff1e485a8c398995afb291137a14c99 (patch) | |
tree | 3e7009bee841c4bf9007df41bf928527961389f2 | |
parent | df4f8ef8fef36d8a4d4ff3f041a00939e48f0851 (diff) |
MSL: Don't flatten builtin arrays unless they're part of IO interface.
-rw-r--r-- | reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc | 4 | ||||
-rw-r--r-- | spirv_msl.cpp | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc b/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc index 56f5e40e..4d6e7571 100644 --- a/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc +++ b/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc @@ -48,8 +48,8 @@ struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex { float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position; float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize; - float _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance[1]; - float _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance[1]; + spvUnsafeArray<float, 1> _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + spvUnsafeArray<float, 1> _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; }; struct Verts diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 9c2852a7..12ec2db5 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -9906,7 +9906,14 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ physical_type.basetype != SPIRType::SampledImage) { BuiltIn builtin = BuiltInMax; - if (is_member_builtin(type, index, &builtin)) + + // Special handling. In [[stage_out]] or [[stage_in]] blocks, + // we need flat arrays, but if we're somehow declaring gl_PerVertex for constant array reasons, we want + // template array types to be declared. + bool is_ib_in_out = + ((stage_out_var_id && get_stage_out_struct_type().self == type.self) || + (stage_in_var_id && get_stage_in_struct_type().self == type.self)); + if (is_ib_in_out && is_member_builtin(type, index, &builtin)) is_using_builtin_array = true; array_type = type_to_array_glsl(physical_type); } |