4#ifndef vtkWebGPUComputePassBufferStorageInternals_h
5#define vtkWebGPUComputePassBufferStorageInternals_h
16VTK_ABI_NAMESPACE_BEGIN
124 wgpu::Buffer wgpuBuffer, std::size_t& outBufferIndex);
138 void WriteBuffer(std::size_t bufferIndex,
const void* bytes, std::size_t numBytes)
144 if (givenSize > byteSize)
147 "void* data given to UpdateBufferData with index "
148 << bufferIndex <<
" is too big. " << givenSize
149 <<
"bytes were given but the buffer is only " << byteSize
150 <<
" bytes long. No data was updated by this call.");
155 wgpu::Buffer wgpuBuffer = this->WebGPUBuffers[bufferIndex];
156 this->ParentPassWGPUConfiguration->
WriteBuffer(wgpuBuffer, 0, bytes, numBytes);
160 std::size_t bufferIndex,
vtkIdType byteOffset,
const void* bytes, std::size_t numBytes)
166 if (givenSize + byteOffset > byteSize)
169 "void* data given to WriteBuffer with index "
170 << bufferIndex <<
" and offset " << byteOffset <<
" is too big. " << givenSize
171 <<
"bytes and offset " << byteOffset <<
" were given but the buffer is only " << byteSize
172 <<
" bytes long. No data was updated by this call.");
177 wgpu::Buffer wgpuBuffer = this->WebGPUBuffers[bufferIndex];
178 this->ParentPassWGPUConfiguration->
WriteBuffer(wgpuBuffer, byteOffset, bytes, numBytes);
261 std::vector<vtkSmartPointer<vtkWebGPUComputeBuffer>> Buffers;
263 std::vector<wgpu::Buffer> WebGPUBuffers;
abstract superclass for arrays of numeric data
abstract base class for most VTK objects
Hold a reference to a vtkObjectBase instance.
a weak reference to a vtkObject.
Represents the set of parameters that will be used to create a compute shader buffer on the device wh...
virtual vtkIdType GetByteSize()
Get/set the size in bytes of the data passed in via SetData().
This class manages the creation/deletion/recreation/resizing/updating of compute buffers used by a co...
bool CheckBufferCorrectness(vtkSmartPointer< vtkWebGPUComputeBuffer > buffer)
Makes some various (and obvious) checks to ensure that the buffer is ready to be created.
bool CheckBufferIndex(std::size_t bufferIndex, const std::string &callerFunctionName)
Checks if a given index is suitable for indexing a buffer of this storage.
static wgpu::BufferUsage ComputeBufferModeToBufferUsage(vtkWebGPUComputeBuffer::BufferMode mode)
Internal method used to convert the user friendly BufferMode to the internal enum wgpu::BufferUsage.
unsigned int GetBufferByteSize(std::size_t bufferIndex)
Returns the size in bytes of a buffer.
void ReleaseResources()
Releases the buffers & resources held by this buffer storage.
vtkSetSmartPointerMacro(ParentPassWGPUConfiguration, vtkWebGPUConfiguration)
Sets the device that will be used by this buffer storage when creating buffers.
void UpdateBufferData(std::size_t bufferIndex, vtkDataArray *newData)
Updates the data of a buffer with a vtkDataArray.
int AddBuffer(vtkSmartPointer< vtkWebGPUComputeBuffer > buffer)
Adds a buffer to the pipeline and uploads its data to the device.
void AddRenderBuffer(vtkSmartPointer< vtkWebGPUComputeRenderBuffer > renderBuffer)
Adds a render texture to the pipeline.
vtkWebGPUComputePassBufferStorageInternals()=default
void RecreateBuffer(std::size_t bufferIndex, vtkIdType newByteSize)
Destroys and recreates a buffer with the given newByteSize Only the wgpu::Buffer object is recreated ...
void ReadBufferFromGPU(std::size_t bufferIndex, vtkWebGPUComputePass::BufferMapAsyncCallback callback, void *userdata)
wgpu::Buffer GetWGPUBuffer(std::size_t bufferIndex)
Returns the wgpu::Buffer object for a buffer in this compute pass buffer storage given its index.
void WriteBuffer(std::size_t bufferIndex, const void *bytes, std::size_t numBytes)
Updates the data of a buffer.
void SetupRenderBuffer(vtkSmartPointer< vtkWebGPUComputeRenderBuffer > renderBuffer)
Binds the buffer to the pipeline at the WebGPU level.
void UpdateBufferData(std::size_t bufferIndex, vtkIdType byteOffset, vtkDataArray *newData)
Similar to the overload without offset of this function.
static wgpu::BufferBindingType ComputeBufferModeToBufferBindingType(vtkWebGPUComputeBuffer::BufferMode mode)
Internal method used to convert the user friendly BufferMode to the internal enum wgpu::BufferBinding...
UpdateBufferStatusCode
Enum used by the returned value of UpdateWebGPUBuffer() to indicate what operation was done internall...
void WriteBuffer(std::size_t bufferIndex, vtkIdType byteOffset, const void *bytes, std::size_t numBytes)
void ResizeBuffer(std::size_t bufferIndex, vtkIdType newByteSize)
Resizes a buffer.
static vtkWebGPUComputePassBufferStorageInternals * New()
void SetComputePass(vtkWeakPointer< vtkWebGPUComputePass > parentComputePass)
Sets the compute pass that uses the buffers of this storage.
UpdateBufferStatusCode UpdateWebGPUBuffer(vtkSmartPointer< vtkWebGPUComputeBuffer > buffer, wgpu::Buffer wgpuBuffer, std::size_t &outBufferIndex)
Updates the wgpu::Buffer reference that a compute buffer is associated to.
~vtkWebGPUComputePassBufferStorageInternals() override
Internals of the vtkWebGPUComputePass.
std::function< void(const void *, void *)> BufferMapAsyncCallback
Create a webgpu device for use in rendering and compute pipelines.
void WriteBuffer(const wgpu::Buffer &buffer, unsigned long offset, const void *data, unsigned long sizeBytes, const char *description=nullptr)
Convenient method used to write data into an existing buffer.
#define vtkLog(verbosity_name, x)
Add to log given the verbosity level.