Toast Engine
Loading...
Searching...
No Matches
gpu_layout.hpp File Reference
#include "brick_pool.hpp"
#include "palette.hpp"
#include "voxel_constants.hpp"
#include "voxel_volume.hpp"
#include <cstddef>
#include <cstdint>
#include <glm/glm.hpp>
#include <span>
#include <toast/export.hpp>
#include <vector>
Include dependency graph for gpu_layout.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  voxel::gpu::VolumeRecord
 Mirrored member for member by voxel_dda.slang so only 4-byte scalars. More...
struct  voxel::gpu::PackedPool
struct  voxel::gpu::SceneVolume
 Neither pointer may be null. More...
struct  voxel::gpu::PackedScene
struct  voxel::gpu::SceneLayout
 A pack minus the per brick arrays. More...
struct  voxel::gpu::PatchRun
 Words replaced in one section of the copy the GPU holds. More...
struct  voxel::gpu::PatchSection
struct  voxel::gpu::TagDelta
struct  voxel::gpu::ScenePatch
struct  voxel::gpu::VolumeDirty
 Grid indices of the bricks of one scene volume that changed since the retained state. More...

Functions

constexpr auto voxel::gpu::gridIndex (glm::uvec3 dims, glm::uvec3 brick) noexcept -> uint32_t
constexpr auto voxel::gpu::coarseDims (glm::uvec3 brick_dims) noexcept -> glm::uvec3
auto voxel::gpu::packPool (const BrickPool &pool) -> PackedPool
 Packs up to the highest slot ever handed out.
void voxel::gpu::packOccupancyWords (const BrickOccupancy &occupancy, uint32_t *out)
constexpr auto voxel::gpu::subBrickBit (glm::uvec3 local) noexcept -> uint32_t
 Bit of local in its sub-brick.
constexpr auto voxel::gpu::subBlockShift (glm::uvec3 local) noexcept -> uint32_t
 k_sub_block_mask shifted by this covers the 2x2x2 block holding local
auto voxel::gpu::packScene (std::span< const SceneVolume > volumes) -> PackedScene
auto voxel::gpu::packLayout (std::span< const SceneVolume > volumes) -> SceneLayout
auto voxel::gpu::layoutMatches (const PackedScene &retained, const SceneLayout &layout) -> bool
 A patch only stands in for a full pack while this holds.
auto voxel::gpu::computePatch (PackedScene &retained, uint32_t retained_pool_slots, const BrickPool &pool, std::span< const SceneVolume > volumes, std::span< const VolumeDirty > dirty, std::span< const uint32_t > appended, uint32_t first_new_palette_word) -> ScenePatch
void voxel::gpu::applyPatch (PackedPool &pool, PackedScene &scene, const ScenePatch &patch)
 Applies a patch the way the GPU copies do.
auto voxel::gpu::patchWords (const ScenePatch &patch) -> size_t
auto voxel::gpu::sampleMaterial (const PackedPool &pool, const PackedScene &scene, uint32_t volume, glm::ivec3 voxel) -> uint8_t
 The sample functions mirror the voxel_dda.slang fetches.
auto voxel::gpu::sampleSolid (const PackedPool &pool, const PackedScene &scene, uint32_t volume, glm::ivec3 voxel) -> bool
auto voxel::gpu::pooledSubBrick (const PackedPool &pool, uint32_t slot, glm::uvec3 local) -> uint64_t
 Sub-brick of pooled slot holding local with bit subBrickBit.
auto voxel::gpu::sampleCoarse (const PackedScene &scene, uint32_t volume, glm::ivec3 cell) -> bool
auto voxel::gpu::samplePaletteEntry (const PackedScene &scene, uint32_t volume, uint8_t index) -> PaletteEntry

Variables

constexpr uint32_t voxel::gpu::k_material_words_per_brick = k_brick_voxel_count / 4
constexpr uint32_t voxel::gpu::k_occupancy_words_per_brick = 16
constexpr uint32_t voxel::gpu::k_coarse_bricks = 4
constexpr uint32_t voxel::gpu::k_palette_words = k_palette_size * 4
constexpr uint64_t voxel::gpu::k_sub_block_mask = 0x0033'0033ull

Detailed Description

Author
dario
Date
13/09/2026

Function Documentation

◆ computePatch()

TOAST_API auto voxel::gpu::computePatch ( PackedScene & retained,
uint32_t retained_pool_slots,
const BrickPool & pool,
std::span< const SceneVolume > volumes,
std::span< const VolumeDirty > dirty,
std::span< const uint32_t > appended = {},
uint32_t first_new_palette_word = UINT32_MAX ) -> ScenePatch
nodiscard

Leaves retained as the GPU holds it afterwards appended records are already in retained with zeroed grid and coarse ranges and palette words from first_new_palette_word on are new

◆ packOccupancyWords()

TOAST_API void voxel::gpu::packOccupancyWords ( const BrickOccupancy & occupancy,
uint32_t * out )

Eight 4x4x4 sub-bricks x fastest each a low then high word with bit x + 4y + 16z

Note
voxel_dda.slang reads this layout and regathers it as z-slices for the meshers