From eadf9d340a2537751d88e394cd21b9ca1b286393 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Wed, 19 Jun 2024 13:56:59 -0400 Subject: [PATCH] MSL: Support a runtime array with dynamic offset in an argument buffer. - Retrieve size of runtime array from get_resource_array_size(). - Move validation assertion to after retrieval of array size. --- spirv_msl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spirv_msl.cpp b/spirv_msl.cpp index ebf5ffe03..251f6883c 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -1361,14 +1361,14 @@ void CompilerMSL::emit_entry_point_declarations() if (is_array(type)) { - if (!type.array[type.array.size() - 1]) - SPIRV_CROSS_THROW("Runtime arrays with dynamic offsets are not supported yet."); - is_using_builtin_array = true; statement(get_argument_address_space(var), " ", type_to_glsl(type), "* ", to_restrict(var_id, true), name, type_to_array_glsl(type, var_id), " ="); - uint32_t array_size = to_array_size_literal(type); + uint32_t array_size = get_resource_array_size(type, var_id); + if (array_size == 0) + SPIRV_CROSS_THROW("Size of runtime array with dynamic offset could not be determined from resource bindings."); + begin_scope(); for (uint32_t i = 0; i < array_size; i++)