From 661d12aef722038d51751741a416b5378559baf2 Mon Sep 17 00:00:00 2001 From: Jason Fielder Date: Mon, 18 Mar 2024 13:38:09 +0100 Subject: [PATCH] Fix #119195: Ensure Metal uses correct attribute conversion mode Resolves custom attribute types for ints and booleans by ensuring conversion mode is correct. Previously, the attribute declarations were assumed to be linear. However, patch ensures the correct attribute index is now fetched, ensuring the conversion mode is correctly specified for non-linear attribute ID's. Authored by Apple: Michael Parkin-White Pull Request: https://projects.blender.org/blender/blender/pulls/119569 --- source/blender/gpu/metal/mtl_shader_generator.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/gpu/metal/mtl_shader_generator.mm b/source/blender/gpu/metal/mtl_shader_generator.mm index d0077cb5a9b..d9b17597364 100644 --- a/source/blender/gpu/metal/mtl_shader_generator.mm +++ b/source/blender/gpu/metal/mtl_shader_generator.mm @@ -3166,10 +3166,11 @@ std::string MSLGeneratorInterface::generate_msl_vertex_attribute_input_populatio &do_attribute_conversion_on_read, this->vertex_input_attributes[attribute].type); if (do_attribute_conversion_on_read) { - out << "\t" << attribute_conversion_func_name << "(MTL_AttributeConvert" << attribute - << ", v_in." << this->vertex_input_attributes[attribute].name << ", " - << shader_stage_inst_name << "." << this->vertex_input_attributes[attribute].name - << ");" << std::endl; + BLI_assert(this->vertex_input_attributes[attribute].layout_location >= 0); + out << "\t" << attribute_conversion_func_name << "(MTL_AttributeConvert" + << this->vertex_input_attributes[attribute].layout_location << ", v_in." + << this->vertex_input_attributes[attribute].name << ", " << shader_stage_inst_name + << "." << this->vertex_input_attributes[attribute].name << ");" << std::endl; } else { out << "\t" << shader_stage_inst_name << "."