[Bf-blender-cvs] [7f81d18ffec] master: Metal: Fix crash when using `batch_for_shader`.

Jeroen Bakker noreply at git.blender.org
Thu Jan 19 15:11:08 CET 2023


Commit: 7f81d18ffecabffc7dc000117230631e6f433eae
Author: Jeroen Bakker
Date:   Thu Jan 19 15:10:49 2023 +0100
Branches: master
https://developer.blender.org/rB7f81d18ffecabffc7dc000117230631e6f433eae

Metal: Fix crash when using `batch_for_shader`.

`batch_for_shader` is an utility function that creates the correct
vertex buffer based on the given shader. In the shader interface
the `attr_types_` contains the GPUType for each location in the
vertex buffer.

When using Metal, the `attr_types_` was never updated, resulting
in using incorrect or non-existing data types. This patch fixes
this by updating the `attr_types_` when building the shader
interface.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D17042

===================================================================

M	source/blender/gpu/metal/mtl_shader_generator.mm

===================================================================

diff --git a/source/blender/gpu/metal/mtl_shader_generator.mm b/source/blender/gpu/metal/mtl_shader_generator.mm
index 93429800888..006e0fbd9cf 100644
--- a/source/blender/gpu/metal/mtl_shader_generator.mm
+++ b/source/blender/gpu/metal/mtl_shader_generator.mm
@@ -2607,6 +2607,10 @@ MTLShaderInterface *MSLGeneratorInterface::bake_shader_interface(const char *nam
           c_offset);
       c_offset += size;
     }
+
+    /* Used in `GPU_shader_get_attribute_info`. */
+    interface->attr_types_[this->vertex_input_attributes[attribute].layout_location] = uint8_t(
+        this->vertex_input_attributes[attribute].type);
   }
 
   /* Prepare Interface Default Uniform Block. */



More information about the Bf-blender-cvs mailing list