2022-10-31 16:01:02 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2022 Blender Foundation. All rights reserved. */
|
|
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "vk_index_buffer.hh"
|
2023-02-21 15:03:12 +01:00
|
|
|
#include "vk_shader.hh"
|
|
|
|
|
#include "vk_shader_interface.hh"
|
2022-10-31 16:01:02 +01:00
|
|
|
|
|
|
|
|
namespace blender::gpu {
|
|
|
|
|
|
|
|
|
|
void VKIndexBuffer::upload_data()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 15:03:12 +01:00
|
|
|
void VKIndexBuffer::bind_as_ssbo(uint binding)
|
2022-10-31 16:01:02 +01:00
|
|
|
{
|
2023-02-21 15:03:12 +01:00
|
|
|
VKContext &context = *VKContext::get();
|
|
|
|
|
if (!buffer_.is_allocated()) {
|
|
|
|
|
allocate(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VKShader *shader = static_cast<VKShader *>(context.shader);
|
|
|
|
|
const VKShaderInterface &shader_interface = shader->interface_get();
|
2023-02-22 14:42:01 +01:00
|
|
|
const VKDescriptorSet::Location location = shader_interface.descriptor_set_location(
|
2023-02-21 15:03:12 +01:00
|
|
|
shader::ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER, binding);
|
2023-02-22 14:42:01 +01:00
|
|
|
shader->pipeline_get().descriptor_set_get().bind_as_ssbo(*this, location);
|
2022-10-31 16:01:02 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-21 15:03:12 +01:00
|
|
|
void VKIndexBuffer::read(uint32_t *data) const
|
2022-10-31 16:01:02 +01:00
|
|
|
{
|
2023-02-21 15:03:12 +01:00
|
|
|
VKContext &context = *VKContext::get();
|
|
|
|
|
VKCommandBuffer &command_buffer = context.command_buffer_get();
|
|
|
|
|
command_buffer.submit();
|
|
|
|
|
|
2023-03-09 09:27:42 +01:00
|
|
|
buffer_.read(data);
|
2022-10-31 16:01:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VKIndexBuffer::update_sub(uint /*start*/, uint /*len*/, const void * /*data*/)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VKIndexBuffer::strip_restart_indices()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 15:03:12 +01:00
|
|
|
void VKIndexBuffer::allocate(VKContext &context)
|
|
|
|
|
{
|
|
|
|
|
GPUUsageType usage = data_ == nullptr ? GPU_USAGE_DEVICE_ONLY : GPU_USAGE_STATIC;
|
|
|
|
|
buffer_.create(context,
|
|
|
|
|
size_get(),
|
|
|
|
|
usage,
|
|
|
|
|
static_cast<VkBufferUsageFlagBits>(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
|
|
|
|
|
VK_BUFFER_USAGE_INDEX_BUFFER_BIT));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-31 15:49:04 +11:00
|
|
|
} // namespace blender::gpu
|