[Bf-blender-cvs] [0a85288462d] master: Fix build error after recent Metal GPU commit

Hans Goudey noreply at git.blender.org
Fri Sep 2 00:10:13 CEST 2022


Commit: 0a85288462def15bf8fedb04aaa6872a2c4dfd33
Author: Hans Goudey
Date:   Thu Sep 1 17:10:05 2022 -0500
Branches: master
https://developer.blender.org/rB0a85288462def15bf8fedb04aaa6872a2c4dfd33

Fix build error after recent Metal GPU commit

These definitions were in the patch but didn't make it to the commit.

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

M	source/blender/gpu/intern/gpu_vertex_format.cc

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

diff --git a/source/blender/gpu/intern/gpu_vertex_format.cc b/source/blender/gpu/intern/gpu_vertex_format.cc
index 5c21bc313eb..897e80293bf 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.cc
+++ b/source/blender/gpu/intern/gpu_vertex_format.cc
@@ -345,6 +345,29 @@ static void VertexFormat_pack_impl(GPUVertFormat *format, uint minimum_stride)
   format->packed = true;
 }
 
+void VertexFormat_pack(GPUVertFormat *format)
+{
+  /* Perform standard vertex packing, ensuring vertex format satisfies
+   * minimum stride requirements for vertex assembly. */
+  VertexFormat_pack_impl(format, GPU_minimum_per_vertex_stride());
+}
+
+void VertexFormat_texture_buffer_pack(GPUVertFormat *format)
+{
+  /* Validates packing for vertex formats used with texture buffers.
+   * In these cases, there must only be a single vertex attribute.
+   * This attribute should be tightly packed without padding, to ensure
+   * it aligns with the backing texture data format, skipping
+   * minimum per-vertex stride, which mandates 4-byte alignment in Metal.
+   * This additional alignment padding caused smaller data types, e.g. U16,
+   * to mis-align. */
+  BLI_assert_msg(format->attr_len == 1,
+                 "Texture buffer mode should only use a single vertex attribute.");
+
+  /* Pack vertex format without minimum stride, as this is not required by texture buffers. */
+  VertexFormat_pack_impl(format, 1);
+}
+
 static uint component_size_get(const Type gpu_type)
 {
   switch (gpu_type) {



More information about the Bf-blender-cvs mailing list