VTK  9.3.20240919
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
vtkWebGPUComputePassBufferStorageInternals Class Reference

This class manages the creation/deletion/recreation/resizing/updating of compute buffers used by a compute pass. More...

#include <vtkWebGPUComputePassBufferStorageInternals.h>

Inheritance diagram for vtkWebGPUComputePassBufferStorageInternals:
[legend]
Collaboration diagram for vtkWebGPUComputePassBufferStorageInternals:
[legend]

Public Types

enum  UpdateBufferStatusCode { SUCCESS = 0 , UP_TO_DATE , BUFFER_NOT_FOUND }
 Enum used by the returned value of UpdateWebGPUBuffer() to indicate what operation was done internally. More...
 
typedef vtkObject Superclass
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class.
 
vtkWebGPUComputePassBufferStorageInternalsNewInstance () const
 
 vtkSetSmartPointerMacro (ParentPassWGPUConfiguration, vtkWebGPUConfiguration)
 Sets the device that will be used by this buffer storage when creating buffers.
 
void SetComputePass (vtkWeakPointer< vtkWebGPUComputePass > parentComputePass)
 Sets the compute pass that uses the buffers of this storage.
 
int AddBuffer (vtkSmartPointer< vtkWebGPUComputeBuffer > buffer)
 Adds a buffer to the pipeline and uploads its data to the device.
 
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 AddRenderBuffer (vtkSmartPointer< vtkWebGPUComputeRenderBuffer > renderBuffer)
 Adds a render texture to the pipeline.
 
unsigned int GetBufferByteSize (std::size_t bufferIndex)
 Returns the size in bytes of a buffer.
 
void ResizeBuffer (std::size_t bufferIndex, vtkIdType newByteSize)
 Resizes a buffer.
 
void RecreateBuffer (std::size_t bufferIndex, vtkIdType newByteSize)
 Destroys and recreates a buffer with the given newByteSize Only the wgpu::Buffer object is recreated so the binding/group of the group doesn't change.
 
void ReadBufferFromGPU (std::size_t bufferIndex, vtkWebGPUComputePass::BufferMapAsyncCallback callback, void *userdata)
 
UpdateBufferStatusCode UpdateWebGPUBuffer (vtkSmartPointer< vtkWebGPUComputeBuffer > buffer, wgpu::Buffer wgpuBuffer, std::size_t &outBufferIndex)
 Updates the wgpu::Buffer reference that a compute buffer is associated to.
 
void WriteBuffer (std::size_t bufferIndex, const void *bytes, std::size_t numBytes)
 Updates the data of a buffer.
 
void WriteBuffer (std::size_t bufferIndex, vtkIdType byteOffset, const void *bytes, std::size_t numBytes)
 
void UpdateBufferData (std::size_t bufferIndex, vtkDataArray *newData)
 Updates the data of a buffer with a vtkDataArray.
 
void UpdateBufferData (std::size_t bufferIndex, vtkIdType byteOffset, vtkDataArray *newData)
 Similar to the overload without offset of this function.
 
bool CheckBufferIndex (std::size_t bufferIndex, const std::string &callerFunctionName)
 Checks if a given index is suitable for indexing a buffer of this storage.
 
bool CheckBufferCorrectness (vtkSmartPointer< vtkWebGPUComputeBuffer > buffer)
 Makes some various (and obvious) checks to ensure that the buffer is ready to be created.
 
void SetupRenderBuffer (vtkSmartPointer< vtkWebGPUComputeRenderBuffer > renderBuffer)
 Binds the buffer to the pipeline at the WebGPU level.
 
void ReleaseResources ()
 Releases the buffers & resources held by this buffer storage.
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on.
 
virtual void DebugOff ()
 Turn debugging output off.
 
bool GetDebug ()
 Get the value of the debug flag.
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag.
 
virtual void Modified ()
 Update the modification time for this object.
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time.
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses.
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
vtkTypeBool InvokeEvent (unsigned long event)
 
vtkTypeBool InvokeEvent (const char *event)
 
std::string GetObjectDescription () const override
 The object description printed in messages and PrintSelf output.
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
vtkCommandGetCommand (unsigned long tag)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
void RemoveObserver (vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
void RemoveObservers (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
void RemoveObservers (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object.
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events.
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events.
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method.
 
vtkTypeBool InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not.
 
vtkTypeBool InvokeEvent (const char *event, void *callData)
 This method invokes an event and return whether the event was aborted or not.
 
virtual void SetObjectName (const std::string &objectName)
 Set/get the name of this object for reporting purposes.
 
virtual std::string GetObjectName () const
 Set/get the name of this object for reporting purposes.
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string.
 
virtual std::string GetObjectDescription () const
 The object description printed in messages and PrintSelf output.
 
virtual vtkTypeBool IsA (const char *name)
 Return 1 if this class is the same type of (or a subclass of) the named class.
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class).
 
virtual void Delete ()
 Delete a VTK object.
 
virtual void FastDelete ()
 Delete a reference to this object.
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream.
 
void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object).
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object).
 
int GetReferenceCount ()
 Return the current reference count of this object.
 
void SetReferenceCount (int)
 Sets the reference count.
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space.
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses.
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses.
 
virtual bool UsesGarbageCollector () const
 Indicate whether the class uses vtkGarbageCollector or not.
 

Static Public Member Functions

static vtkWebGPUComputePassBufferStorageInternalsNew ()
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkWebGPUComputePassBufferStorageInternalsSafeDownCast (vtkObjectBase *o)
 
static wgpu::BufferUsage ComputeBufferModeToBufferUsage (vtkWebGPUComputeBuffer::BufferMode mode)
 Internal method used to convert the user friendly BufferMode to the internal enum wgpu::BufferUsage.
 
static wgpu::BufferBindingType ComputeBufferModeToBufferBindingType (vtkWebGPUComputeBuffer::BufferMode mode)
 Internal method used to convert the user friendly BufferMode to the internal enum wgpu::BufferBindingType.
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes.
 
static void SetGlobalWarningDisplay (vtkTypeBool val)
 This is a global flag that controls whether any debug, warning or error messages are displayed.
 
static void GlobalWarningDisplayOn ()
 This is a global flag that controls whether any debug, warning or error messages are displayed.
 
static void GlobalWarningDisplayOff ()
 This is a global flag that controls whether any debug, warning or error messages are displayed.
 
static vtkTypeBool GetGlobalWarningDisplay ()
 This is a global flag that controls whether any debug, warning or error messages are displayed.
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class.
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class).
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within.
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space.
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkWebGPUComputePassBufferStorageInternals ()=default
 
 ~vtkWebGPUComputePassBufferStorageInternals () override
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events.
 
void InternalReleaseFocus ()
 These methods allow a command to exclusively grab all events.
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void RegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
virtual void ObjectFinalize ()
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Friends

class vtkWebGPUComputePassInternals
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
std::string ObjectName
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

This class manages the creation/deletion/recreation/resizing/updating of compute buffers used by a compute pass.

A compute pass delegates calls that want to modify buffers to this class

Definition at line 24 of file vtkWebGPUComputePassBufferStorageInternals.h.

Member Typedef Documentation

◆ Superclass

Definition at line 28 of file vtkWebGPUComputePassBufferStorageInternals.h.

Member Enumeration Documentation

◆ UpdateBufferStatusCode

Enum used by the returned value of UpdateWebGPUBuffer() to indicate what operation was done internally.

SUCCESS: The buffer was successfully updated

UP_TO_DATE: The buffer was already up to date (the given wgpu::Buffer was already being used). No-op.

BUFFER_NOT_FOUND: The given buffer did not belong to this buffer storage. No-op.

Enumerator
SUCCESS 
UP_TO_DATE 
BUFFER_NOT_FOUND 

Definition at line 41 of file vtkWebGPUComputePassBufferStorageInternals.h.

Constructor & Destructor Documentation

◆ vtkWebGPUComputePassBufferStorageInternals()

vtkWebGPUComputePassBufferStorageInternals::vtkWebGPUComputePassBufferStorageInternals ( )
protecteddefault

◆ ~vtkWebGPUComputePassBufferStorageInternals()

vtkWebGPUComputePassBufferStorageInternals::~vtkWebGPUComputePassBufferStorageInternals ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkWebGPUComputePassBufferStorageInternals * vtkWebGPUComputePassBufferStorageInternals::New ( )
static

◆ IsTypeOf()

static vtkTypeBool vtkWebGPUComputePassBufferStorageInternals::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkWebGPUComputePassBufferStorageInternals::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

static vtkWebGPUComputePassBufferStorageInternals * vtkWebGPUComputePassBufferStorageInternals::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkWebGPUComputePassBufferStorageInternals::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkWebGPUComputePassBufferStorageInternals * vtkWebGPUComputePassBufferStorageInternals::NewInstance ( ) const

◆ vtkSetSmartPointerMacro()

vtkWebGPUComputePassBufferStorageInternals::vtkSetSmartPointerMacro ( ParentPassWGPUConfiguration  ,
vtkWebGPUConfiguration   
)

Sets the device that will be used by this buffer storage when creating buffers.

This device must be the one used by the parent compute pass.

◆ SetComputePass()

void vtkWebGPUComputePassBufferStorageInternals::SetComputePass ( vtkWeakPointer< vtkWebGPUComputePass parentComputePass)

Sets the compute pass that uses the buffers of this storage.

◆ AddBuffer()

int vtkWebGPUComputePassBufferStorageInternals::AddBuffer ( vtkSmartPointer< vtkWebGPUComputeBuffer buffer)

Adds a buffer to the pipeline and uploads its data to the device.

Returns the index of the buffer that can for example be used as input to the ReadBufferFromGPU() function.

◆ GetWGPUBuffer()

wgpu::Buffer vtkWebGPUComputePassBufferStorageInternals::GetWGPUBuffer ( std::size_t  bufferIndex)

Returns the wgpu::Buffer object for a buffer in this compute pass buffer storage given its index.

◆ AddRenderBuffer()

void vtkWebGPUComputePassBufferStorageInternals::AddRenderBuffer ( vtkSmartPointer< vtkWebGPUComputeRenderBuffer renderBuffer)

Adds a render texture to the pipeline.

A render texture can be obtained from vtkWebGPUPolyDataMapper::AcquirePointXXXXRenderBuffer() or vtkWebGPUPolyDataMapper::AcquireCellXXXXRenderBuffer()

◆ GetBufferByteSize()

unsigned int vtkWebGPUComputePassBufferStorageInternals::GetBufferByteSize ( std::size_t  bufferIndex)

Returns the size in bytes of a buffer.

◆ ResizeBuffer()

void vtkWebGPUComputePassBufferStorageInternals::ResizeBuffer ( std::size_t  bufferIndex,
vtkIdType  newByteSize 
)

Resizes a buffer.

Warning
: After the resize, the data of the buffer is undefined and should be updated by a call to UpdateBufferData()

◆ RecreateBuffer()

void vtkWebGPUComputePassBufferStorageInternals::RecreateBuffer ( std::size_t  bufferIndex,
vtkIdType  newByteSize 
)

Destroys and recreates a buffer with the given newByteSize Only the wgpu::Buffer object is recreated so the binding/group of the group doesn't change.

◆ ReadBufferFromGPU()

void vtkWebGPUComputePassBufferStorageInternals::ReadBufferFromGPU ( std::size_t  bufferIndex,
vtkWebGPUComputePass::BufferMapAsyncCallback  callback,
void *  userdata 
)

◆ UpdateWebGPUBuffer()

UpdateBufferStatusCode vtkWebGPUComputePassBufferStorageInternals::UpdateWebGPUBuffer ( vtkSmartPointer< vtkWebGPUComputeBuffer buffer,
wgpu::Buffer  wgpuBuffer,
std::size_t &  outBufferIndex 
)

Updates the wgpu::Buffer reference that a compute buffer is associated to.

Useful when a compute buffer has been recreated and the associated wgpu::Buffer needs to be updated with the newly created buffer.

Also recreates the bind group of the buffer.

Returns the status of the operation. The index of the buffer that was modified (basically the index of 'buffer' within Buffers) is stored in the outBufferIndex parameter.

◆ WriteBuffer() [1/2]

void vtkWebGPUComputePassBufferStorageInternals::WriteBuffer ( std::size_t  bufferIndex,
const void *  bytes,
std::size_t  numBytes 
)
inline

Updates the data of a buffer.

The given data is expected to be at most the size of the buffer. If N bytes are given to update but the buffer size is > N, only the first N bytes will be updated, the rest will remain unchanged. The data is immediately available to the GPU (no call to vtkWebGPUComputePipeline::Update() is necessary for this call to take effect)

Note
: This method can be used even if the buffer was initially configured with std::vector data and the given data can safely be destroyed directly after calling this function.

Definition at line 138 of file vtkWebGPUComputePassBufferStorageInternals.h.

◆ WriteBuffer() [2/2]

void vtkWebGPUComputePassBufferStorageInternals::WriteBuffer ( std::size_t  bufferIndex,
vtkIdType  byteOffset,
const void *  bytes,
std::size_t  numBytes 
)
inline

◆ UpdateBufferData() [1/2]

void vtkWebGPUComputePassBufferStorageInternals::UpdateBufferData ( std::size_t  bufferIndex,
vtkDataArray newData 
)

Updates the data of a buffer with a vtkDataArray.

The given data is expected to be at most the size of the buffer. If N bytes are given to update but the buffer size is > N, only the first N bytes will be updated, the rest will remain unchanged. The data is immediately available to the GPU (no call to vtkWebGPUComputePipeline::Update() is necessary for this call to take effect

Note
: This method can be used even if the buffer was initially configured with std::vector data and the given data can safely be destroyed directly after calling this function.

◆ UpdateBufferData() [2/2]

void vtkWebGPUComputePassBufferStorageInternals::UpdateBufferData ( std::size_t  bufferIndex,
vtkIdType  byteOffset,
vtkDataArray newData 
)

Similar to the overload without offset of this function.

The offset is used to determine where in the buffer to reupload data. Useful when only a portion of the buffer needs to be reuploaded.

◆ CheckBufferIndex()

bool vtkWebGPUComputePassBufferStorageInternals::CheckBufferIndex ( std::size_t  bufferIndex,
const std::string &  callerFunctionName 
)

Checks if a given index is suitable for indexing a buffer of this storage.

Logs an error if the index is negative or greater than the number of buffer of the storage. The callerFunctionName parameter is used to give more information on what function used an invalid buffer index in case of error.

Returns true if the buffer index is valid, false if it's not.

◆ CheckBufferCorrectness()

bool vtkWebGPUComputePassBufferStorageInternals::CheckBufferCorrectness ( vtkSmartPointer< vtkWebGPUComputeBuffer buffer)

Makes some various (and obvious) checks to ensure that the buffer is ready to be created.

Returns true if the buffer is correct. If the buffer is incorrect, returns false.

◆ SetupRenderBuffer()

void vtkWebGPUComputePassBufferStorageInternals::SetupRenderBuffer ( vtkSmartPointer< vtkWebGPUComputeRenderBuffer renderBuffer)

Binds the buffer to the pipeline at the WebGPU level.

To use once the buffer has been properly set up with SetupRenderBuffer.

◆ ReleaseResources()

void vtkWebGPUComputePassBufferStorageInternals::ReleaseResources ( )

Releases the buffers & resources held by this buffer storage.

◆ ComputeBufferModeToBufferUsage()

static wgpu::BufferUsage vtkWebGPUComputePassBufferStorageInternals::ComputeBufferModeToBufferUsage ( vtkWebGPUComputeBuffer::BufferMode  mode)
static

Internal method used to convert the user friendly BufferMode to the internal enum wgpu::BufferUsage.

◆ ComputeBufferModeToBufferBindingType()

static wgpu::BufferBindingType vtkWebGPUComputePassBufferStorageInternals::ComputeBufferModeToBufferBindingType ( vtkWebGPUComputeBuffer::BufferMode  mode)
static

Internal method used to convert the user friendly BufferMode to the internal enum wgpu::BufferBindingType.

Friends And Related Symbol Documentation

◆ vtkWebGPUComputePassInternals

friend class vtkWebGPUComputePassInternals
friend

The documentation for this class was generated from the following file: