载入中...
搜索中...
未找到
FrameArena.h
浏览该文件的文档.
1#pragma once
2
3#include "vkbuilder.hpp"
4
5#include <vector>
6
7namespace eve::graphics::vulkan {
8
19public:
22
23 FrameArena(const FrameArena &) = delete;
24 FrameArena &operator=(const FrameArena &) = delete;
26 FrameArena() = default;
28 FrameArena(FrameArena &&o) noexcept { *this = std::move(o); }
30 FrameArena &operator=(FrameArena &&o) noexcept;
31
33 struct Alloc {
34 vk::DeviceSize offset = 0;
35 vk::DeviceSize size = 0;
36 void *mapped = nullptr;
37 };
38
40 bool ensure(vkb::Device &device, vk::DeviceSize bytes, vk::BufferUsageFlags usage);
41
43 Alloc alloc(vk::DeviceSize bytes, vk::DeviceSize align = 16);
44
45 void reset();
46
47 vk::Buffer buffer() const;
48 vk::DeviceSize capacity() const { return capacity_; }
49 vk::DeviceSize used() const { return head_; }
50
51private:
52 vkb::GenericBuffer buf_;
53 vkb::Device device_;
54 vk::DeviceSize capacity_ = 0;
55 vk::DeviceSize head_ = 0;
56 void *mapped_ = nullptr;
57};
58
59} // namespace eve::graphics::vulkan
std::string usage
vkb::Device & device
std::uint64_t bytes
Per-frame GPU allocation arena (host-visible coherent).
Definition FrameArena.h:18
FrameArena()=default
Constructs a FrameArena.
bool ensure(vkb::Device &device, vk::DeviceSize bytes, vk::BufferUsageFlags usage)
Allocate or grow (before any recording) so bytes fit.
vk::DeviceSize used() const
Definition FrameArena.h:49
FrameArena(const FrameArena &)=delete
~FrameArena()
Releases FrameArena resources.
Definition FrameArena.cpp:5
Alloc alloc(vk::DeviceSize bytes, vk::DeviceSize align=16)
Allocate bytes (aligned). Returns empty Alloc on capacity overflow.
vk::DeviceSize capacity() const
Definition FrameArena.h:48
FrameArena(FrameArena &&o) noexcept
Constructs a FrameArena.
Definition FrameArena.h:28
FrameArena & operator=(const FrameArena &)=delete