Vulkan: Add VKIndexBuffer::update_sub

IndexBuffer::update_sub was never used, and a Vulkan implementation
was never added. !162144 needs it to partial update index buffers.
This PR adds the vulkan implementation

Pull Request: https://projects.blender.org/blender/blender/pulls/162532
This commit is contained in:
Jeroen Bakker 2026-08-10 15:15:37 +02:00
parent 7a3c23b71b
commit 986f55b332

View file

@ -100,9 +100,22 @@ void VKIndexBuffer::read(uint32_t *data) const
}
}
void VKIndexBuffer::update_sub(uint /*start*/, uint /*len*/, const void * /*data*/)
void VKIndexBuffer::update_sub(uint start, uint len, const void *data)
{
NOT_YET_IMPLEMENTED
if (!buffer_.is_allocated()) {
/* Allocating huge buffers can fail, in that case we skip copying data. */
return;
}
BLI_assert_msg(start + len <= buffer_.size_in_bytes(), "Out of bound write to index buffer");
if (buffer_.is_mapped()) {
buffer_.update_sub_immediately(start, len, data);
}
else {
VKContext &context = *VKContext::get();
VKStagingBuffer staging_buffer(buffer_, VKStagingBuffer::Direction::HostToDevice, start, len);
memcpy(staging_buffer.host_buffer_get().mapped_memory_get(), data, len);
staging_buffer.copy_to_device(context);
}
}
void VKIndexBuffer::strip_restart_indices()