24#ifndef vtkWebGPUVolumeBrickPool_h
25#define vtkWebGPUVolumeBrickPool_h
29#include "vtkABINamespace.h"
37VTK_ABI_NAMESPACE_BEGIN
69 return this->Owner != other.
Owner ? this->Owner < other.
Owner : this->Brick < other.
Brick;
80 std::size_t wantedSlots, std::uint32_t bytesPerVoxel);
100 void Upload(
Kind kind, std::uint32_t slot,
const void* voxels);
114 const std::uint32_t*
GetSlotGrid()
const {
return this->SlotGrid; }
122 bool IsUsed(
Kind kind)
const {
return this->Textures[
static_cast<int>(kind)] !=
nullptr; }
125 void EnsureTexture(
Kind kind);
126 void SlotOrigin(std::uint32_t slot, std::uint32_t origin[3])
const;
131 std::uint32_t SlotGrid[3] = { 0, 0, 0 };
132 std::uint32_t Capacity = 0;
137 std::uint64_t LastUsed = 0;
138 bool Occupied =
false;
140 std::vector<SlotState> Slots;
141 std::map<Key, std::uint32_t> Residency;
142 std::uint64_t Frame = 0;
144 std::uint32_t NextVictim = 0;
146 static constexpr int KindCount =
static_cast<int>(
Kind::Count);
147 vtkWebGPU::Texture Textures[KindCount];
148 vtkWebGPU::TextureView Views[KindCount];
149 vtkWebGPU::Texture Placeholders[KindCount];
150 vtkWebGPU::TextureView PlaceholderViews[KindCount];
Fixed size 3D texture that holds the resident bricks of every volume in a pass.
WGPUTextureView GetView(Kind kind)
Views of the pool textures. A kind that no volume has used yet is a one voxel placeholder.
void BeginFrame()
Start gathering a frame.
std::uint32_t GetCapacity() const
std::uint32_t Allocate(const Key &key)
Look up a brick, or make room for one.
void Release(const Key &key)
Give a slot back, for when the brick it was allocated for could not be fetched after all.
std::uint32_t Lookup(const Key &key)
Look up a brick, or make room for one.
static constexpr std::uint32_t InvalidSlot
A page whose slot is this is not resident and must not be sampled.
void Configure(vtkWebGPURenderWindow *window, int brickSize, std::size_t budgetBytes, std::size_t wantedSlots, std::uint32_t bytesPerVoxel)
Make room for wantedSlots bricks of brickSize voxels a side within budgetBytes.
const std::uint32_t * GetSlotGrid() const
bool IsUsed(Kind kind) const
Whether kind has been asked for since the pool was configured.
void Forget(const void *owner)
Let go of every slot that owner holds.
Kind
How a volume's scalars are stored.
@ Mask
Two bytes per voxel: whether it is hidden, by a ghost, blanking or a binary mask, and its label for a...
void Upload(Kind kind, std::uint32_t slot, const void *voxels)
Fill a slot.
void ReleaseGraphicsResources()
Identifies one brick of one volume for as long as the volume keeps offering itself.
bool operator<(const Key &other) const
Reference-counted ownership for WebGPU C API handles.