1#ifndef LIBSBX_GRAPHICS_BUFFERS_BUFFER_HPP_
2#define LIBSBX_GRAPHICS_BUFFERS_BUFFER_HPP_
8#include <vulkan/vulkan.hpp>
10#include <libsbx/utility/noncopyable.hpp>
12#include <libsbx/memory/observer_ptr.hpp>
14namespace sbx::graphics {
20 using size_type = VkDeviceSize;
26 auto handle()
const noexcept ->
const VkBuffer&;
28 operator const VkBuffer&()
const noexcept;
30 auto memory()
const noexcept ->
const VkDeviceMemory&;
32 virtual auto size()
const noexcept -> size_type;
46 VkDeviceMemory _memory{};
50template<
typename Type, VkBufferUsageFlags Usage, VkMemoryPropertyFlags Properties>
57 using value_type = Type;
58 using size_type = base_type::size_type;
60 basic_buffer(std::span<const Type> elements, VkMemoryPropertyFlags properties = 0, VkBufferUsageFlags usage = 0u)
61 :
base_type{elements.size() *
sizeof(Type), (usage | Usage) , (properties | Properties), elements.data()} { }
63 basic_buffer(size_type size, VkMemoryPropertyFlags properties = 0, VkBufferUsageFlags usage = 0u)
64 :
base_type{size *
sizeof(Type), (usage | Usage) , (properties | Properties),
nullptr} { }
68 auto size()
const noexcept -> VkDeviceSize
override {
69 return size_in_bytes() /
sizeof(Type);
72 auto size_in_bytes()
const noexcept -> VkDeviceSize {
73 return base_type::size();
78using staging_buffer =
basic_buffer<std::uint8_t, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)>;
Definition: buffer.hpp:51
Definition: buffer.hpp:16
A non-owning pointer that can be used to observe the value of a pointer.
Definition: observer_ptr.hpp:27
Definition: noncopyable.hpp:6