2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2022-10-31 16:01:02 +01:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
#include "GPU_index_buffer.hh"
|
2022-10-31 16:01:02 +01:00
|
|
|
|
2023-02-21 15:03:12 +01:00
|
|
|
#include "vk_buffer.hh"
|
|
|
|
|
|
2022-10-31 16:01:02 +01:00
|
|
|
namespace blender::gpu {
|
|
|
|
|
|
2024-09-26 10:59:45 +02:00
|
|
|
class VKIndexBuffer : public IndexBuf {
|
2023-02-21 15:03:12 +01:00
|
|
|
VKBuffer buffer_;
|
|
|
|
|
|
2022-10-31 16:01:02 +01:00
|
|
|
public:
|
|
|
|
|
void upload_data() override;
|
|
|
|
|
|
|
|
|
|
void bind_as_ssbo(uint binding) override;
|
|
|
|
|
|
2023-02-13 08:34:19 +01:00
|
|
|
void read(uint32_t *data) const override;
|
2022-10-31 16:01:02 +01:00
|
|
|
|
|
|
|
|
void update_sub(uint start, uint len, const void *data) override;
|
|
|
|
|
|
2023-04-26 08:09:28 +02:00
|
|
|
VkBuffer vk_handle() const
|
2023-02-21 15:03:12 +01:00
|
|
|
{
|
2024-06-14 08:46:33 +02:00
|
|
|
return buffer_get().vk_handle();
|
|
|
|
|
}
|
|
|
|
|
VkIndexType vk_index_type() const
|
|
|
|
|
{
|
|
|
|
|
return to_vk_index_type(index_type_);
|
2023-02-21 15:03:12 +01:00
|
|
|
}
|
|
|
|
|
|
2024-09-26 10:59:45 +02:00
|
|
|
void ensure_updated();
|
|
|
|
|
|
2022-10-31 16:01:02 +01:00
|
|
|
private:
|
|
|
|
|
void strip_restart_indices() override;
|
2023-05-04 10:06:48 +02:00
|
|
|
void allocate();
|
2023-11-20 15:48:06 +01:00
|
|
|
VKBuffer &buffer_get();
|
2024-06-14 08:46:33 +02:00
|
|
|
const VKBuffer &buffer_get() const;
|
2022-10-31 16:01:02 +01:00
|
|
|
};
|
|
|
|
|
|
2023-04-26 08:09:28 +02:00
|
|
|
static inline VKIndexBuffer *unwrap(IndexBuf *index_buffer)
|
|
|
|
|
{
|
|
|
|
|
return static_cast<VKIndexBuffer *>(index_buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-31 15:49:04 +11:00
|
|
|
} // namespace blender::gpu
|