VTK  9.6.20260422
vtkWebGPUCellToPrimitiveConverter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
22
23#ifndef vtkWebGPUCellToPrimitiveConverter_h
24#define vtkWebGPUCellToPrimitiveConverter_h
25
26#include "vtkObject.h"
27
28#include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_7_0
29#include "vtkProperty.h" // for VTK_SURFACE
30#include "vtkRenderingWebGPUModule.h" // for export macro
31#include "vtkSmartPointer.h" // for vtkSmartPointer
32#include "vtkTimeStamp.h" // for vtkTimeStamp
33
34#include "vtk_wgpu.h" // for wgpu::Buffer
35
36#include <array> // for std::array
37#include <utility> // for std::pair
38
39VTK_ABI_NAMESPACE_BEGIN
41class vtkPolyData;
42class vtkCellArray;
45
46class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUCellToPrimitiveConverter : public vtkObject
47{
48public:
51 void PrintSelf(ostream& os, vtkIndent indent) override;
52
59
65 {
66 // Used to draw VTK_VERTEX and VTK_POLY_VERTEX cell types
68 // Used to draw VTK_LINE and VTK_POLY_LINE cell types.
70 // Used to draw only the points of each line segment.
71 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
73 // Used to draw VTK_QUAD, VTK_TRIANGLE and VTK_POLYGON cell types.
75 // Used to draw only the corner points of each face.
76 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
78 // Used to draw only the edges of each face.
79 // Activated when `vtkProperty::Representation` == `VTK_WIREFRAME`
82 };
83
85
95 VTK_DEPRECATED_IN_9_7_0("Use DispatchMeshToPrimitiveComputePipeline() that accepts const "
96 "std::array<T*, N> parameters instead.")
98 vtkPolyData* mesh, int representation, vtkTypeUInt32* vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES],
99 wgpu::Buffer* connectivityBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
100 wgpu::Buffer* cellIdBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
101 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
102 wgpu::Buffer* cellIdOffsetUniformBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
104 vtkPolyData* mesh, int representation,
105 const std::array<vtkTypeUInt32*, NUM_TOPOLOGY_SOURCE_TYPES>& vertexCounts,
106 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& connectivityBuffers,
107 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& cellIdBuffers,
108 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& edgeArrayBuffers,
109 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& cellIdOffsetUniformBuffers);
111
123 std::vector<vtkPolyData*> meshes, int representation,
124 std::vector<std::pair<vtkTypeUInt32, vtkTypeUInt32>>*
125 vertexOffsetAndCounts[NUM_TOPOLOGY_SOURCE_TYPES],
126 std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& connectivityBuffers,
127 std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& cellIdBuffers,
128 std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& edgeArrayBuffers);
129
138 VTK_DEPRECATED_IN_9_7_0("Use DispatchCellArrayToPrimitiveComputePipeline() instead.")
140 vtkCellArray* cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset,
141 vtkTypeUInt32* vertexCount, wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer,
142 wgpu::Buffer* edgeArrayBuffer, wgpu::Buffer* cellIdOffsetUniformBuffer);
143
153 vtkCellArray* cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset,
154 vtkTypeUInt32* vertexCount, wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer,
155 wgpu::Buffer* edgeArrayBuffer, wgpu::Buffer* cellIdOffsetUniformBuffer);
156
168 const std::vector<vtkCellArray*>& cellArrays, int representation, int cellType,
169 const std::vector<vtkIdType>& numberOfPoints,
170 std::vector<std::pair<vtkTypeUInt32, vtkTypeUInt32>>* vertexOffsetAndCounts,
171 wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer, wgpu::Buffer* edgeArrayBuffer);
172
180
186
195
199 static const char* GetTopologySourceTypeAsString(TopologySourceType topologySourceType);
200
204 static const char* GetCellTypeAsString(int cellType);
205
210 static const char* GetTessellatedPrimitiveTypeAsString(TopologySourceType topologySourceType);
211
215 static std::size_t GetTessellatedPrimitiveSize(TopologySourceType topologySourceType);
216
221 int cellType, int representation = VTK_SURFACE);
222
223protected:
226
227private:
229 void operator=(const vtkWebGPUCellToPrimitiveConverter&) = delete;
230
237 CreateCellToPrimitiveComputePassForCellType(
238 vtkSmartPointer<vtkWebGPUConfiguration> wgpuConfiguration,
239 TopologySourceType topologySourceType);
240
241 // Timestamps help reuse previous resources as much as possible.
243 // compute pass speeds up cell to primitive conversions.
246 // compute pipeline to execute the compute pass.
249};
250
251VTK_ABI_NAMESPACE_END
252
253#endif
object to represent cell connectivity
a simple class to control print indentation
Definition vtkIndent.h:108
concrete dataset represents vertices, lines, polygons, and triangle strips
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
static vtkIdType GetTessellatedPrimitiveSizeOffsetForCellType(int cellType)
Query the integer that, when subtracted from the no.
static const char * GetTopologySourceTypeAsString(TopologySourceType topologySourceType)
Get the name of the topology source type as a string.
bool GetNeedToRebuildCellToPrimitiveComputePipeline(vtkCellArray *cells, vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType)
Get whether the Cell-to-Primitive compute pipeline needs rebuilt.
bool DispatchCellArraysToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, const std::vector< vtkCellArray * > &cellArrays, int representation, int cellType, const std::vector< vtkIdType > &numberOfPoints, std::vector< std::pair< vtkTypeUInt32, vtkTypeUInt32 > > *vertexOffsetAndCounts, wgpu::Buffer *connectivityBuffer, wgpu::Buffer *cellIdBuffer, wgpu::Buffer *edgeArrayBuffer)
Tessellates the a collection of cell arrays into graphics primitives.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool DispatchMeshesToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, std::vector< vtkPolyData * > meshes, int representation, std::vector< std::pair< vtkTypeUInt32, vtkTypeUInt32 > > *vertexOffsetAndCounts[NUM_TOPOLOGY_SOURCE_TYPES], std::array< wgpu::Buffer *, NUM_TOPOLOGY_SOURCE_TYPES > &connectivityBuffers, std::array< wgpu::Buffer *, NUM_TOPOLOGY_SOURCE_TYPES > &cellIdBuffers, std::array< wgpu::Buffer *, NUM_TOPOLOGY_SOURCE_TYPES > &edgeArrayBuffers)
Tessellates the cells in a collection of meshes into graphics primitives.
static TopologySourceType GetTopologySourceTypeForCellType(int cellType, int representation=VTK_SURFACE)
A convenient method to get the relevant TopologyRenderInfo instance for a cellType.
static const char * GetTessellatedPrimitiveTypeAsString(TopologySourceType topologySourceType)
Get the name of the sub primitive of a VTK cell type as a string.
void UpdateCellToPrimitiveComputePipelineTimestamp(vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType)
Brings the build timestamp of the compute pipeline associated with cellType up to date.
bool DispatchCellToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, vtkCellArray *cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset, vtkTypeUInt32 *vertexCount, wgpu::Buffer *connectivityBuffer, wgpu::Buffer *cellIdBuffer, wgpu::Buffer *edgeArrayBuffer, wgpu::Buffer *cellIdOffsetUniformBuffer)
Tessellates each cell into primitives.
void ReleaseGraphicsResources(vtkWindow *)
Release any graphics resources that are being consumed by this mapper.
static const char * GetCellTypeAsString(int cellType)
Get the name of the VTK cell type as a string.
bool DispatchMeshToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, vtkPolyData *mesh, int representation, vtkTypeUInt32 *vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *connectivityBuffers[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *cellIdBuffers[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *cellIdOffsetUniformBuffers[NUM_TOPOLOGY_SOURCE_TYPES])
Tessellates the cells in a mesh into graphics primitives.
bool DispatchCellArrayToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, vtkCellArray *cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset, vtkTypeUInt32 *vertexCount, wgpu::Buffer *connectivityBuffer, wgpu::Buffer *cellIdBuffer, wgpu::Buffer *edgeArrayBuffer, wgpu::Buffer *cellIdOffsetUniformBuffer)
Tessellates each cell into primitives.
TopologySourceType
All supported types of topology.
static std::size_t GetTessellatedPrimitiveSize(TopologySourceType topologySourceType)
Get the number of points in the sub primitive of a VTK cell type.
static vtkWebGPUCellToPrimitiveConverter * New()
A compute pass is an abstraction for offloading computation from the CPU onto the GPU using WebGPU co...
A compute pipeline is the orchestrator of a collection of compute passes.
Create a webgpu device for use in rendering and compute pipelines.
window superclass for vtkRenderWindow
Definition vtkWindow.h:61
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_SURFACE
int vtkIdType
Definition vtkType.h:363