diff --git a/spirv_cpp.cpp b/spirv_cpp.cpp index 9e606998..8802846c 100644 --- a/spirv_cpp.cpp +++ b/spirv_cpp.cpp @@ -251,6 +251,7 @@ string CompilerCPP::compile() backend.basic_uint_type = "uint32_t"; backend.swizzle_is_function = true; backend.shared_is_implied = true; + backend.flexible_member_array_supported = false; uint32_t pass_count = 0; do diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 3b2f6794..d2f4a20d 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -3735,7 +3735,19 @@ string CompilerGLSL::type_to_array_glsl(const SPIRType &type) { res += "["; if (size) + { res += convert_to_string(size); + } + else if (!backend.flexible_member_array_supported) + { + // For runtime-sized arrays, we can work around + // lack of standard support for this by simply having + // a single element array. + // + // Runtime length arrays must always be the last element + // in an interface block. + res += '1'; + } res += "]"; } return res; diff --git a/spirv_glsl.hpp b/spirv_glsl.hpp index e744e54c..bdde7aaa 100644 --- a/spirv_glsl.hpp +++ b/spirv_glsl.hpp @@ -203,6 +203,7 @@ protected: const char *basic_uint_type = "uint"; bool swizzle_is_function = false; bool shared_is_implied = false; + bool flexible_member_array_supported = true; } backend; void emit_struct(const SPIRType &type);