Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
skinned_blas_pool.hpp
Go to the documentation of this file.
1
6
7
#pragma once
8
9
#include "vulkan_common.hpp"
10
11
#include <cstdint>
12
#include <optional>
13
#include <unordered_map>
14
15
namespace
renderer {
16
class
VulkanCore
;
17
class
VulkanMesh
;
18
19
class
SkinnedBlasPool {
20
public
:
21
explicit
SkinnedBlasPool(
const
VulkanCore
& core);
22
23
void
beginFrame();
24
25
auto
recordFor(
26
vk::CommandBuffer cmd, uint64_t node_rid,
const
VulkanMesh
& mesh, vk::Buffer posed_vertices, uint32_t posed_vertex_offset
27
) -> vk::DeviceAddress;
28
29
void
endFrame();
30
31
[[nodiscard]]
32
auto
addressFor(uint64_t node_rid)
const
-> vk::DeviceAddress;
33
34
[[nodiscard]]
35
auto
getRecordedCount()
const
noexcept
-> uint32_t {
36
return
m_recorded;
37
}
38
39
private
:
40
static
constexpr
uint64_t k_retire_frames = 8;
41
42
struct
Entry {
43
const
VulkanMesh
* mesh =
nullptr
;
44
uint32_t vertex_count = 0;
45
uint32_t primitive_count = 0;
46
47
std::optional<vma::raii::Buffer> blas_buffer;
48
std::optional<vma::raii::Buffer> scratch;
49
vk::raii::AccelerationStructureKHR blas =
nullptr
;
50
vk::DeviceAddress address = 0;
51
vk::DeviceAddress scratch_address = 0;
52
53
bool
built =
false
;
54
uint64_t last_used_frame = 0;
55
};
56
57
auto
ensureEntry(uint64_t node_rid,
const
VulkanMesh
& mesh) -> Entry*;
58
59
const
VulkanCore
* m_core =
nullptr
;
60
std::unordered_map<uint64_t, Entry> m_entries;
61
62
uint64_t m_frame = 0;
63
uint32_t m_recorded = 0;
64
66
PFN_vkCmdBuildAccelerationStructuresKHR m_build_acceleration_structures =
nullptr
;
67
};
68
69
}
renderer::VulkanCore
Definition
vulkan_core.hpp:48
renderer::VulkanMesh
Definition
vulkan_mesh.hpp:26
engine
src
toast
renderer
skinned_blas_pool.hpp
Generated by
1.17.0