From 0a85288462def15bf8fedb04aaa6872a2c4dfd33 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 1 Sep 2022 17:10:05 -0500 Subject: Fix build error after recent Metal GPU commit These definitions were in the patch but didn't make it to the commit. --- source/blender/gpu/intern/gpu_vertex_format.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/blender/gpu/intern') 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) { -- cgit v1.2.3