From aa3ffca8dc97c381f31968b4798a0802ed8cb275 Mon Sep 17 00:00:00 2001 From: laurynas Date: Tue, 12 Mar 2024 15:01:10 +0100 Subject: [PATCH] Fix #119247: Curves: Extra point in evaluated spline of Curves geometry In bf17fc8d79 after extending buffer to multiple of 4 there appeared trailing space in buffer not covered by shader's `for` loop. Pull Request: https://projects.blender.org/blender/blender/pulls/119346 --- source/blender/gpu/intern/gpu_index_buffer.cc | 7 +------ source/blender/gpu/metal/mtl_index_buffer.mm | 4 +++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc index a57c17d5cd3..2b8070770df 100644 --- a/source/blender/gpu/intern/gpu_index_buffer.cc +++ b/source/blender/gpu/intern/gpu_index_buffer.cc @@ -270,12 +270,7 @@ GPUIndexBuf *GPU_indexbuf_build_curves_on_device(GPUPrimType prim_type, tris ? GPU_SHADER_INDEXBUF_TRIS : (lines ? GPU_SHADER_INDEXBUF_LINES : GPU_SHADER_INDEXBUF_POINTS)); GPU_shader_bind(shader); - int index_len = curves_num * dispatch_x_dim; - /* Buffer's size in bytes is required to be multiple of 16. - * Here is made an assumption that buffer's index_type is GPU_INDEX_U32. - * This will make buffer size multiple of 16 after multiplying by sizeof(uint32_t). */ - int multiple_of_4 = ceil_to_multiple_u(index_len, 4); - GPUIndexBuf *ibo = GPU_indexbuf_build_on_device(multiple_of_4); + GPUIndexBuf *ibo = GPU_indexbuf_build_on_device(curves_num * dispatch_x_dim); int resolution; if (tris) { resolution = 6; diff --git a/source/blender/gpu/metal/mtl_index_buffer.mm b/source/blender/gpu/metal/mtl_index_buffer.mm index bb09086d93f..93b25e7a071 100644 --- a/source/blender/gpu/metal/mtl_index_buffer.mm +++ b/source/blender/gpu/metal/mtl_index_buffer.mm @@ -55,7 +55,9 @@ void MTLIndexBuf::bind_as_ssbo(uint32_t binding) /* Create MTLStorageBuffer to wrap this resource and use conventional binding. */ if (ssbo_wrapper_ == nullptr) { - ssbo_wrapper_ = new MTLStorageBuf(this, alloc_size_); + /* Buffer's size in bytes is required to be multiple of 16. */ + int multiple_of_16 = ceil_to_multiple_u(alloc_size_, 16); + ssbo_wrapper_ = new MTLStorageBuf(this, multiple_of_16); } ssbo_wrapper_->bind(binding); }