-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex_buffer.cppm
More file actions
60 lines (45 loc) · 1.95 KB
/
index_buffer.cppm
File metadata and controls
60 lines (45 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module;
#include <vulkan/vulkan.h>
#include <span>
export module vk:index_buffer;
export import :types;
export import :utilities;
export import :command_buffer;
export import :buffer_streams32;
export namespace vk {
inline namespace v1 {
class index_buffer {
public:
index_buffer() = default;
index_buffer(const VkDevice& p_device,
const index_params& p_info) : m_device(p_device) {
m_indices_count = p_info.indices.size();
buffer_parameters index_params = {
.device_size = p_info.indices.size_bytes(),
.physical_memory_properties = p_info.phsyical_memory_properties,
.property_flags = static_cast<memory_property>(memory_property::host_visible_bit | memory_property::host_cached_bit),
.usage = static_cast<VkBufferUsageFlags>(buffer_usage::index_buffer_bit),
.debug_name = p_info.debug_name.c_str(),
.vkSetDebugUtilsObjectNameEXT = p_info.vkSetDebugUtilsObjectNameEXT
};
m_index_buffer = buffer_stream32(m_device, index_params);
m_index_buffer.write(p_info.indices);
}
[[nodiscard]] bool alive() const { return m_index_buffer; }
[[nodiscard]] uint32_t size() const { return m_indices_count; }
void bind(const VkCommandBuffer& p_current, uint64_t p_offset = 0) {
vkCmdBindIndexBuffer(
p_current, m_index_buffer, p_offset, VK_INDEX_TYPE_UINT32);
}
operator VkBuffer() const { return m_index_buffer; }
operator VkBuffer() { return m_index_buffer; }
void destroy() {
m_index_buffer.destroy();
}
private:
VkDevice m_device = nullptr;
uint32_t m_indices_count = 0;
buffer_stream32 m_index_buffer{};
};
};
};