4#ifndef vtkWebGPUComputePass_h
5#define vtkWebGPUComputePass_h
9#include "vtkRenderingWebGPUModule.h"
26VTK_ABI_NAMESPACE_BEGIN
67 vtkGetMacro(ShaderSource, std::string);
68 vtkSetMacro(ShaderSource, std::string);
77 vtkGetMacro(ShaderEntryPoint, std::string);
78 vtkSetMacro(ShaderEntryPoint, std::string);
87 vtkGetMacro(Label, std::string&);
259 template <typename T, std::enable_if_t<std::is_arithmetic<T>::value,
bool> =
true>
262 this->WriteBufferData(bufferIndex, 0, newData.data(), newData.size() *
sizeof(T));
270 template <typename T, std::enable_if_t<std::is_arithmetic<T>::value,
bool> =
true>
273 this->WriteBufferData(bufferIndex, byteOffset, data.data(), data.size() *
sizeof(T));
299 template <typename T, std::enable_if_t<std::is_arithmetic<T>::value,
bool> =
true>
302 this->WriteTextureData(textureIndex, data.data(), data.size() *
sizeof(T));
332 void WriteBufferData(
333 int bufferIndex,
vtkIdType byteOffset,
const void* data, std::size_t numBytes);
335 void WriteTextureData(
int textureIndex,
const void* data, std::size_t numBytes);
348 std::string ShaderSource;
349 std::string ShaderEntryPoint;
352 unsigned int GroupsX = 0, GroupsY = 0, GroupsZ = 0;
355 std::string Label =
"WebGPU compute pass";
358 std::string WGPUCommandEncoderLabel =
"WebGPU command encoder \"" + this->Label +
"\"";
359 std::string WGPUComputePipelineLabel =
"WebGPU pipeline \"" + this->Label +
"\"";
abstract superclass for arrays of numeric data
a simple class to control print indentation
abstract base class for most VTK objects
Hold a reference to a vtkObjectBase instance.
Represents the set of parameters that will be used to create a compute shader buffer on the device wh...
This class manages the creation/deletion/recreation/resizing/updating of compute buffers used by a co...
Internals of the vtkWebGPUComputePass.
This class manages the creation/deletion/recreation/ of compute textures used by a compute pass.
A compute pass is an abstraction for offloading computation from the CPU onto the GPU using WebGPU co...
void AddRenderBuffer(vtkSmartPointer< vtkWebGPUComputeRenderBuffer > renderBuffer)
Adds a render buffer to the pass.
std::function< void(const void *, void *)> BufferMapAsyncCallback
void ReleaseResources()
Releases the resources used by this compute pass.
static vtkWebGPUComputePass * New()
Note to the VTK user: A compute pass should always be acquired through vtkWebGPUComputePipeline::Crea...
~vtkWebGPUComputePass() override
void DeleteTextureViews(int textureIndex)
Deletes all the texture views of a given texture (given by its index)
int AddTextureView(vtkSmartPointer< vtkWebGPUComputeTextureView > textureView)
Adds a texture view to the compute pass and returns its index.
void UpdateBufferData(int bufferIndex, const std::vector< T > &newData)
Updates the data of a buffer.
vtkSmartPointer< vtkWebGPUComputeTexture > GetComputeTexture(int textureIndex)
Retrieves the compute texture associated with the given texture index.
std::function< void(const void *, int, void *)> TextureMapAsyncCallback
int AddTexture(vtkSmartPointer< vtkWebGPUComputeTexture > texture)
Adds a texture to the pass and upload its data to the device.
void UpdateBufferData(int bufferIndex, vtkIdType byteOffset, const std::vector< T > &data)
Similar to the overload without offset of this function.
void SetLabel(const std::string &label)
Set/get the label of the compute pass.
void UpdateTextureData(int textureIndex, const std::vector< T > &data)
Uploads the given data to the texture starting at pixel (0, 0)
int AddRenderTexture(vtkSmartPointer< vtkWebGPUComputeRenderTexture > renderTexture)
Adds a render texture to the pass.
void UpdateBufferData(int bufferIndex, vtkDataArray *newData)
Updates the data of a buffer with a vtkDataArray.
int AddBuffer(vtkSmartPointer< vtkWebGPUComputeBuffer > buffer)
Adds a buffer to the pass and uploads its data to the device.
void RecreateTextureView(int textureViewIndex)
Recreates a compute texture view.
void ResizeBuffer(int bufferIndex, vtkIdType newByteSize)
Resizes a buffer of the pass.
void ReadBufferFromGPU(int bufferIndex, BufferMapAsyncCallback callback, void *userdata)
vtkSmartPointer< vtkWebGPUComputeTextureView > GetTextureView(int textureViewIndex)
Retrieves the texture view associated with the given texture view index.
void UpdateBufferData(int bufferIndex, vtkIdType byteOffset, vtkDataArray *newData)
Similar to the overload without offset of this function.
void RecreateComputeTexture(int textureIndex)
Recreates a compute texture.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Dispatch()
Dispatch the compute pass with (X, Y, Z) = (groupX, groupsY, groupZ) groups.
vtkSmartPointer< vtkWebGPUComputeTextureView > CreateTextureView(int textureIndex)
Returns a new texture view on the given texture (given by the index) that can be configured and then ...
unsigned int GetBufferByteSize(int bufferIndex)
Returns the size in bytes of a buffer.
void RebindTextureView(int group, int binding, int textureViewIndex)
This function allows the usage of multiple texture views on a single binding point (group / binding c...
void SetWorkgroups(int groupsX, int groupsY, int groupsZ)
void SetShaderSourceFromPath(const char *shaderFilePath)
void ReadTextureFromGPU(int textureIndex, int mipLevel, TextureMapAsyncCallback callback, void *userdata)
This function maps the texture into a linear memory block, making it accessible to the CPU.
A compute pipeline is the orchestrator of a collection of compute passes.
Render buffers are returned by calls to vtkWebGPUPolyDataMapper::AcquirePointAttributeComputeRenderBu...
Render textures are returned by calls to vtkWebGPUPolyDataMapper::AcquireXXXXRenderTexture() and repr...
Represents the set of parameters that will be used to create a compute shader texture on the device w...
Internal implementation details of vtkWebGPUPointCloudMapper.