Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-09-02 01:10:05 +0300
committerHans Goudey <h.goudey@me.com>2022-09-02 01:10:05 +0300
commit0a85288462def15bf8fedb04aaa6872a2c4dfd33 (patch)
tree3b5f18f8a3fed0d2892ed888d18b9d3b8a47d01e /source/blender/gpu/intern/gpu_vertex_format.cc
parentaf4e62a0205e6bd566ab453fa706d2e2de9686e7 (diff)
Fix build error after recent Metal GPU commit
These definitions were in the patch but didn't make it to the commit.
Diffstat (limited to 'source/blender/gpu/intern/gpu_vertex_format.cc')
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.cc23
1 files changed, 23 insertions, 0 deletions
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) {