Blender V5.3
vk_vertex_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_vertex_buffer.hh"
12
13#include "vk_buffer.hh"
14#include "vk_common.hh"
15
16namespace blender::gpu {
17
18class VKVertexBuffer : public VertBuf {
19 VKBuffer buffer_;
21 VkBufferView vk_buffer_view_ = VK_NULL_HANDLE;
22
23 bool data_uploaded_ = false;
24
25 public:
27
28 void bind_as_ssbo(uint binding) override;
29 void bind_as_texture(uint binding) override;
30 void wrap_handle(uint64_t handle) override;
31
32 void update_sub(uint start_offset, uint data_size_in_bytes, const void *data) override;
33 void copy_sub(VertBuf &source_buf,
34 uint source_first_vertex,
35 uint dest_first_vertex,
36 uint vertex_len) override;
37
38 void read(void *data) const override;
39
40 VkBuffer vk_handle() const
41 {
42 return buffer_.vk_handle();
43 }
45 {
46 return buffer_.resource();
47 }
48
49 inline bool has_device_address() const
50 {
51 return buffer_.has_device_address();
52 }
53
54 inline VkDeviceAddress device_address_get() const
55 {
56 return buffer_.device_address_get();
57 }
58
59 VkBufferView vk_buffer_view_get() const
60 {
61 BLI_assert(vk_buffer_view_ != VK_NULL_HANDLE);
62 return vk_buffer_view_;
63 }
64
65 void ensure_updated();
66 void ensure_buffer_view();
67
68 VkFormat to_vk_format()
69 {
71 }
72
73 protected:
74 void acquire_data() override;
75 void resize_data() override;
76 void release_data() override;
77 void upload_data() override;
78
79 private:
80 void allocate();
81
82 void upload_data_direct(const VKBuffer &host_buffer);
83 void upload_data_via_staging_buffer(VKContext &context);
84
85 /* VKTexture requires access to `buffer_` to convert a vertex buffer to a texture. */
86 friend class VKTexture;
87};
88
90{
91 return static_cast<VKVertexBuffer *>(vertex_buffer);
92}
94{
95 return static_cast<VKVertexBuffer &>(vertex_buffer);
96}
97
98} // namespace blender::gpu
#define BLI_INLINE
VkDeviceAddress device_address_get() const
void copy_sub(VertBuf &source_buf, uint source_first_vertex, uint dest_first_vertex, uint vertex_len) override
Copy from part of source vertex buffer into the vertex buffer.
const VKResourceWithHandle< VkBuffer > & resource() const
VkBufferView vk_buffer_view_get() const
void wrap_handle(uint64_t handle) override
void bind_as_ssbo(uint binding) override
void bind_as_texture(uint binding) override
void update_sub(uint start_offset, uint data_size_in_bytes, const void *data) override
void read(void *data) const override
MutableSpan< T > data()
static Context * unwrap(GPUContext *ctx)
VkFormat to_vk_format(const TextureFormat format)
Definition vk_common.cc:157
constexpr TextureFormat to_texture_format(TextureTargetFormat format)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
Definition BKE_text.h:91
unsigned int uint
Definition BKE_text.h:55