Blender V5.3
vk_index_buffer.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "GPU_index_buffer.hh"
12
13#include "vk_buffer.hh"
14
15namespace blender::gpu {
16
17class VKIndexBuffer : public IndexBuf {
18 VKBuffer buffer_;
19 bool data_uploaded_ = false;
20
21 public:
22 void upload_data() override;
23
24 void bind_as_ssbo(uint binding) override;
25
26 void read(uint32_t *data) const override;
27
28 void update_sub(uint start, uint len, const void *data) override;
29
30 void copy_sub(IndexBuf &source_buf,
31 uint source_first_index,
32 uint dest_first_index,
33 uint index_len) override;
34
35 VkBuffer vk_handle() const
36 {
37 return buffer_get().vk_handle();
38 }
40 {
41 return buffer_get().resource();
42 }
43 inline bool has_device_address() const
44 {
45 return buffer_get().has_device_address();
46 }
47 inline VkDeviceAddress device_address_get() const
48 {
49 return buffer_get().device_address_get();
50 }
51 VkIndexType vk_index_type() const
52 {
54 }
55
56 inline VkDeviceSize allocated_size_get() const
57 {
58 return buffer_get().allocated_size_in_bytes();
59 }
60
61 void ensure_updated();
62
63 private:
64 void strip_restart_indices() override;
65 void allocate();
67 const VKBuffer &buffer_get() const;
68};
69
70static inline VKIndexBuffer *unwrap(IndexBuf *index_buffer)
71{
72 return static_cast<VKIndexBuffer *>(index_buffer);
73}
74
75static inline VKIndexBuffer &unwrap(IndexBuf &index_buffer)
76{
77 return static_cast<VKIndexBuffer &>(index_buffer);
78}
79
80} // namespace blender::gpu
GPUIndexBufType index_type_
void read(uint32_t *data) const override
VkIndexType vk_index_type() const
void update_sub(uint start, uint len, const void *data) override
VkDeviceAddress device_address_get() const
void copy_sub(IndexBuf &source_buf, uint source_first_index, uint dest_first_index, uint index_len) override
Copy part of source index buffer into this index buffer.
const VKResourceWithHandle< VkBuffer > & resource() const
VkDeviceSize allocated_size_get() const
Return the allocated size of the buffer in bytes.
void bind_as_ssbo(uint binding) override
#define buffer_get(create_info, _res)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
static Context * unwrap(GPUContext *ctx)
VkIndexType to_vk_index_type(const GPUIndexBufType index_type)
Definition vk_common.cc:652
unsigned int uint
Definition BKE_text.h:55
unsigned int uint32_t
Definition BKE_text.h:81
BMesh const char void * data