Blender V5.0
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#include "vk_data_conversion.hh"
16
17namespace blender::gpu {
18
19class VKVertexBuffer : public VertBuf {
20 VKBuffer buffer_;
22 VkBufferView vk_buffer_view_ = VK_NULL_HANDLE;
23
24 bool data_uploaded_ = false;
25
26 public:
28
29 void bind_as_ssbo(uint binding) override;
30 void bind_as_texture(uint binding) override;
31 void wrap_handle(uint64_t handle) override;
32
33 void update_sub(uint start, uint len, const void *data) override;
34 void read(void *data) const override;
35
36 VkBuffer vk_handle() const
37 {
38 return buffer_.vk_handle();
39 }
40
41 inline VkDeviceAddress device_address_get() const
42 {
43 return buffer_.device_address_get();
44 }
45
46 VkBufferView vk_buffer_view_get() const
47 {
48 BLI_assert(vk_buffer_view_ != VK_NULL_HANDLE);
49 return vk_buffer_view_;
50 }
51
52 void ensure_updated();
53 void ensure_buffer_view();
54
55 inline VkFormat to_vk_format()
56 {
58 }
59
60 protected:
61 void acquire_data() override;
62 void resize_data() override;
63 void release_data() override;
64 void upload_data() override;
65
66 private:
67 void allocate();
68
69 void upload_data_direct(const VKBuffer &host_buffer);
70 void upload_data_via_staging_buffer(VKContext &context);
71
72 /* VKTexture requires access to `buffer_` to convert a vertex buffer to a texture. */
73 friend class VKTexture;
74};
75
77{
78 return static_cast<VKVertexBuffer *>(vertex_buffer);
79}
80
81} // namespace blender::gpu
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_INLINE
unsigned int uint
unsigned long long int uint64_t
VkDeviceAddress device_address_get() const
void update_sub(uint start, uint len, const void *data) override
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
MutableSpan< T > data()
static Context * unwrap(GPUContext *ctx)
VkFormat to_vk_format(const TextureFormat format)
Definition vk_common.cc:136
constexpr TextureFormat to_texture_format(TextureTargetFormat format)
uint len