37 std::vector<BrickCensus> bricks;
39 uint64_t sequence = 0;
41 uint32_t packed_slots = 0;
42 uint32_t packed_palettes = 0;
45 uint32_t patched_bricks = 0;
48 std::shared_ptr<const VoxelPackedScene>
mirror;
66 static constexpr size_t k_section_count = 6;
69 VoxelGpuStorage(std::vector<uint64_t> node_rids, std::vector<glm::uvec3> brick_dims);
73 std::vector<uint64_t> node_rids, std::vector<glm::uvec3> brick_dims,
const VoxelGpuStorage& previous,
74 uint64_t patch_sequence
84 auto recordIndexOf(uint64_t node_rid)
const -> std::optional<uint32_t>;
87 auto recordBrickDims(uint32_t index)
const -> glm::uvec3 {
88 return index < m_brick_dims.size() ? m_brick_dims[index] : glm::uvec3(0);
92 auto recordCount() const noexcept -> uint32_t {
93 return static_cast<uint32_t
>(m_node_rids.size());
97 auto buffer(
Section section)
const -> vk::Buffer;
100 auto size(
Section section)
const -> vk::DeviceSize;
104 auto queuePatch(
const VulkanCore& core,
const voxel::gpu::ScenePatch& patch)
const -> std::optional<uint64_t>;
107 void recordPendingPatches(vk::CommandBuffer cmd, std::vector<std::shared_ptr<void>>& retired)
const;
110 auto nodeRid(uint32_t index)
const -> uint64_t {
111 return index < m_node_rids.size() ? m_node_rids[index] : 0;
131 friend class VoxelSceneUpload;
133 std::vector<uint64_t> m_node_rids;
134 std::vector<glm::uvec3> m_brick_dims;
136 std::shared_ptr<VoxelGpuSections> m_sections;
139 uint64_t m_patch_sequence = 0;
141 uint64_t m_generation = 0;
143 VoxelStorageDebugInfo m_debug;
145 VoxelChangeHistory m_history;
150 glm::mat4 world_to_voxel {1.0f};
151 glm::vec3 bounds_center {0.0f};
152 float bounds_radius = 0.0f;
153 uint32_t record_index = 0;
156 std::shared_ptr<const VoxelGpuStorage> storage;
157 std::vector<Volume> volumes;
162 glm::mat4 voxel_to_world {1.0f};
163 glm::mat4 world_to_voxel {1.0f};
164 glm::mat4 previous_voxel_to_world {1.0f};
165 uint32_t record_index = 0;
172static_assert(
sizeof(
VoxelInstanceGpu) == 208,
"VoxelInstanceGpu is mirrored by voxel_dda.slang VoxelInstance");
182auto makeVoxelInstance(
183 const glm::mat4& model,
const glm::mat4& inverse_model,
const glm::mat4& previous_model,
bool has_previous,
184 uint32_t record_index
189void writeVoxelStorageDescriptors(
const vk::raii::Device& device, vk::DescriptorSet set,
const VoxelGpuStorage& storage);
193 VoxelSceneUpload(std::shared_ptr<VoxelGpuStorage> storage, std::shared_ptr<const VoxelPackedScene> packed);
197 void record(vk::CommandBuffer cmd)
override;
201 auto resource() ->
IVulkanResource*
override {
return m_storage.get(); }
204 std::shared_ptr<VoxelGpuStorage> m_storage;
206 std::shared_ptr<const VoxelPackedScene> m_packed;
208 bool m_released =
false;
210 vma::raii::Buffer m_staging =
nullptr;
211 std::array<vk::DeviceSize, VoxelGpuStorage::k_section_count> m_offsets {};
213 std::array<vk::DeviceSize, VoxelGpuStorage::k_section_count> m_bytes {};
Definition vulkan_resource_base.hpp:12
Definition vulkan_resource_base.hpp:48
Regions each published voxel storage brought oldest first.
Definition voxel_change_history.hpp:30
Section buffers shared by every version patched in place since the last full upload.
Definition voxel_gpu_storage.cpp:88
Immutable scene version and versions from small carves share buffers patched in place.
Definition voxel_gpu_storage.hpp:54
Section
In voxel_dda.slang binding order.
Definition voxel_gpu_storage.hpp:57
void setDebugInfo(VoxelStorageDebugInfo info)
Definition voxel_gpu_storage.hpp:115
auto queuePatch(const VulkanCore &core, const voxel::gpu::ScenePatch &patch) const -> std::optional< uint64_t >
Tick thread on a ready storage and nullopt when the pool outgrew the buffers or staging failed.
Definition voxel_gpu_storage.cpp:218
auto generation() const noexcept -> uint64_t
Unique per storage so a cache keyed on it notices every upload.
Definition voxel_gpu_storage.hpp:79
void recordPendingPatches(vk::CommandBuffer cmd, std::vector< std::shared_ptr< void > > &retired) const
Render thread before anything reads the sections and retired must outlive the frame.
Definition voxel_gpu_storage.cpp:222
void setChangeHistory(VoxelChangeHistory history)
Definition voxel_gpu_storage.hpp:123
VoxelGpuStorage(std::vector< uint64_t > node_rids, std::vector< glm::uvec3 > brick_dims)
New section buffers that a VoxelSceneUpload fills.
Definition voxel_gpu_storage.cpp:201
void recordAcquire(sync::BarrierBatch &batch) override
On the consuming queue after the upload fence signalled. No op for an upload that stayed on one queue...
Definition voxel_gpu_storage.cpp:394
Definition vulkan_core.hpp:48
Skips a barrier only when neither side writes and the layout and next read stages are already covered...
Definition gpu_sync.hpp:105
Definition voxel_gpu_storage.hpp:149
Definition voxel_gpu_storage.hpp:148
Mirrors voxel_dda.slang VoxelInstance.
Definition voxel_gpu_storage.hpp:161
uint32_t cell_base
First global coarse cell of this instance in the VoxelPass cell cull.
Definition voxel_gpu_storage.hpp:169
Definition voxel_gpu_storage.hpp:22
Definition voxel_gpu_storage.hpp:29
Immutable once the storage is published.
Definition voxel_gpu_storage.hpp:28
std::shared_ptr< const VoxelPackedScene > mirror
Only kept while a voxel debug view is active.
Definition voxel_gpu_storage.hpp:48
std::vector< std::string > node_names
Per record.
Definition voxel_gpu_storage.hpp:36
Definition gpu_layout.hpp:62
Definition gpu_layout.hpp:76
constexpr uint32_t k_voxel_instance_mirrored
Bit 1 of VoxelInstanceGpu::flags so voxel.slang flips the box winding.
Definition voxel_gpu_storage.hpp:178
constexpr uint32_t k_voxel_instance_no_motion
Bit 0 of VoxelInstanceGpu::flags with the meaning of VulkanRenderer::k_instance_no_motion.
Definition voxel_gpu_storage.hpp:175