It is recommended to map buffers once and not each time the mapped memory is needed. This patch will map the buffer when created and unmap the buffer when the buffer is freed. This patch will reduce the overhead where the Vulkan driver or the virtual memory manager needs to be accessed. Pull Request: blender/blender#105588
44 lines
764 B
C++
44 lines
764 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2022 Blender Foundation. All rights reserved. */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#include "vk_uniform_buffer.hh"
|
|
#include "vk_context.hh"
|
|
|
|
namespace blender::gpu {
|
|
|
|
void VKUniformBuffer::update(const void *data)
|
|
{
|
|
if (!buffer_.is_allocated()) {
|
|
VKContext &context = *VKContext::get();
|
|
allocate(context);
|
|
}
|
|
buffer_.update(data);
|
|
}
|
|
|
|
void VKUniformBuffer::allocate(VKContext &context)
|
|
{
|
|
buffer_.create(context, size_in_bytes_, GPU_USAGE_STATIC, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
|
}
|
|
|
|
void VKUniformBuffer::clear_to_zero()
|
|
{
|
|
}
|
|
|
|
void VKUniformBuffer::bind(int /*slot*/)
|
|
{
|
|
}
|
|
|
|
void VKUniformBuffer::bind_as_ssbo(int /*slot*/)
|
|
{
|
|
}
|
|
|
|
void VKUniformBuffer::unbind()
|
|
{
|
|
}
|
|
|
|
} // namespace blender::gpu
|