9#ifndef vtkWebGPUContextDevice2DPrivate_h
10#define vtkWebGPUContextDevice2DPrivate_h
15#include <unordered_map>
16#include <webgpu/webgpu.h>
18VTK_ABI_NAMESPACE_BEGIN
35 if (this->CurrentBuffer)
37 for (WGPUBuffer buf : this->StaleBuffers)
46 this->CurrentOffset = 0;
48 for (WGPUBuffer buf : this->StaleBuffers)
52 this->StaleBuffers.clear();
68 uint64_t alignedSize = (sizeInBytes + 3) & ~3ull;
70 if (!this->CurrentBuffer || this->CurrentOffset + alignedSize > this->Capacity)
72 if (this->CurrentBuffer)
74 this->StaleBuffers.push_back(this->CurrentBuffer);
78 std::max({ this->Capacity * 2, alignedSize,
static_cast<uint64_t
>(4194304) });
81 this->Capacity, usage | WGPUBufferUsage_CopyDst,
false, this->Label.c_str());
83 this->CurrentOffset = 0;
86 uint64_t allocatedOffset = this->CurrentOffset;
87 this->CurrentOffset += alignedSize;
88 return allocatedOffset;
95 WGPUBuffer
GetBuffer()
const {
return this->CurrentBuffer; }
99 WGPUBuffer CurrentBuffer =
nullptr;
100 uint64_t Capacity = 0;
101 uint64_t CurrentOffset = 0;
102 std::vector<WGPUBuffer> StaleBuffers;
135 WGPUTextureView
View =
nullptr;
172 std::unordered_map<std::string, CachedTexture>
TextCache;
Hold a reference to a vtkObjectBase instance.
Create a webgpu device for use in rendering and compute pipelines.
WGPUBuffer CreateBuffer(std::uint64_t sizeBytes, WGPUBufferUsage usage, bool mappedAtCreation=false, const char *label=nullptr)
Convenient methods used to create webgpu buffers.
Container for vtkWebGPUContextDevice2D internal state.
vtkWebGPURenderPipelineCache * PipelineCache
std::unordered_map< vtkImageData *, CachedTexture > ImageCache
WGPURenderPipeline TexturedPipeline
vtkWebGPUConfiguration * Config
WGPUBuffer MatrixUniformBuffer
std::vector< float > BatchedVertices
WGPUPipelineLayout PipelineLayout
WGPURenderPipeline LinePipeline
WGPUBindGroup TransformBindGroup
std::unordered_map< std::string, CachedTextData > TextImageCache
WGPUVertexBufferLayout VertexBufferLayout
WGPURenderPipeline TrianglePipeline
WGPURenderPipeline CurrentBatchPipeline
WGPUBindGroup CurrentBatchBindGroup
WGPUBindGroup ActiveTextureBindGroup
WGPUTextureView DummyTextureView
std::unordered_map< std::string, CachedTexture > TextCache
vtkWebGPULinearAllocator VertexAllocator
WGPUSampler DefaultSampler
WGPUBindGroupLayout BindGroupLayout
Linear allocator for dynamic WebGPU buffers.
void Reset()
Resets the internal offset and releases all stale buffers.
uint64_t Allocate(vtkWebGPUConfiguration *config, uint64_t sizeInBytes, WGPUBufferUsage usage)
Reserves a contiguous block of memory in the current WebGPU buffer.
WGPUBuffer GetBuffer() const
Gets the active WebGPU buffer object.
~vtkWebGPULinearAllocator()
vtkWebGPULinearAllocator(const std::string &label)
Class to create and retrieve render pipelines based on a given key.
Stores rasterized text images and their bounding box dimensions.
vtkSmartPointer< vtkImageData > Image
Holds WebGPU texture resources and metadata for caching images and text.
vtkMTimeType ModifiedTime
Configuration parameters for creating or retrieving WebGPU render pipelines.
vtkWebGPU::RenderPipeline * outPipeline
WGPUPrimitiveTopology topology
vtkTypeUInt32 vtkMTimeType
Reference-counted ownership for WebGPU C API handles.
#define wgpuBufferRelease