Files
test2/source/blender/gpu/vulkan/vk_index_buffer.hh
Jeroen Bakker 66d361bd29 Vulkan: Add support for descriptor buffers
Descriptor sets/pools are known to be troublesome as it doesn't match
how GPUs work, or how application want to work, adding more complexity
than needed. This results is quite an overhead allocating and
deallocating descriptor sets.

This PR will use descriptor buffers when they are available. Most platforms
support descriptor buffers. When not available descriptor pools/sets
will be used.

Although this is a feature I would like to land it in 4.5 due to the API changes.
This makes it easier to fix issues when 4.5 is released.
The feature can easily be disabled by setting the feature to false if it has
to many problems.

Pull Request: https://projects.blender.org/blender/blender/pulls/138266
2025-06-06 10:20:36 +02:00

58 lines
1.1 KiB
C++

/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup gpu
*/
#pragma once
#include "GPU_index_buffer.hh"
#include "vk_buffer.hh"
namespace blender::gpu {
class VKIndexBuffer : public IndexBuf {
VKBuffer buffer_;
bool data_uploaded_ = false;
public:
void upload_data() override;
void bind_as_ssbo(uint binding) override;
void read(uint32_t *data) const override;
void update_sub(uint start, uint len, const void *data) override;
VkBuffer vk_handle() const
{
return buffer_get().vk_handle();
}
inline VkDeviceAddress device_address_get() const
{
return buffer_get().device_address_get();
}
VkIndexType vk_index_type() const
{
return to_vk_index_type(index_type_);
}
void ensure_updated();
private:
void strip_restart_indices() override;
void allocate();
VKBuffer &buffer_get();
const VKBuffer &buffer_get() const;
};
static inline VKIndexBuffer *unwrap(IndexBuf *index_buffer)
{
return static_cast<VKIndexBuffer *>(index_buffer);
}
} // namespace blender::gpu