5#include "vulkan/vulkan.hpp"
25 explicit SlotLease(std::shared_ptr<std::atomic<uint32_t>> uses)
29 m_uses->fetch_add(1, std::memory_order_relaxed);
37 m_uses->fetch_add(1, std::memory_order_relaxed);
49 m_uses->fetch_add(1, std::memory_order_relaxed);
59 m_uses = std::move(other.m_uses);
66 [[nodiscard]]
explicit operator bool() const noexcept {
return m_uses !=
nullptr; }
72 m_uses->fetch_sub(1, std::memory_order_release);
77 std::shared_ptr<std::atomic<uint32_t>>
m_uses;
119 [[nodiscard]]
size_t acquire();
127 void write(
size_t slot,
const void* data,
size_t size);
132 [[nodiscard]]
SlotLease lease(
size_t slot)
const;
137 [[nodiscard]] vk::DescriptorBufferInfo info(
size_t slot)
const;
146 [[nodiscard]]
const std::shared_ptr<Buffers::VKBuffer>&
buffer() const noexcept {
return m_buffer; }
153 [[nodiscard]] std::shared_ptr<Buffers::VKBuffer> detach();
164 std::vector<std::shared_ptr<std::atomic<uint32_t>>>
m_uses;
Vulkan-backed buffer wrapper used in processing chains.
SlotArena & operator=(SlotArena &&)=delete
std::vector< std::shared_ptr< std::atomic< uint32_t > > > m_uses
SlotArena(const SlotArena &)=delete
size_t slot_bytes() const noexcept
const std::shared_ptr< Buffers::VKBuffer > & buffer() const noexcept
The backing buffer, which changes when the arena grows.
SlotArena & operator=(const SlotArena &)=delete
size_t slot_count() const noexcept
std::shared_ptr< Buffers::VKBuffer > m_buffer
SlotArena(SlotArena &&)=delete
bool is_initialized() const noexcept
SlotLease(std::shared_ptr< std::atomic< uint32_t > > uses)
SlotLease(SlotLease &&other) noexcept=default
SlotLease & operator=(const SlotLease &other)
std::shared_ptr< std::atomic< uint32_t > > m_uses
SlotLease(const SlotLease &other)
SlotLease & operator=(SlotLease &&other) noexcept
A claim on one slot of a SlotArena for as long as the claim exists.
BufferUsageHint
Semantic usage hint for buffer allocation and memory properties.