VTK  9.6.20260626
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;
43class vtkDataArray;
46
47class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUCellToPrimitiveConverter : public vtkObject
48{
49public:
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
60
66 {
67 // Used to draw VTK_VERTEX and VTK_POLY_VERTEX cell types
69 // Used to draw VTK_LINE and VTK_POLY_LINE cell types.
71 // Used to draw only the points of each line segment.
72 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
74 // Used to draw VTK_QUAD, VTK_TRIANGLE and VTK_POLYGON cell types.
76 // Used to draw only the corner points of each face.
77 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
79 // Used to draw only the edges of each face.
80 // Activated when `vtkProperty::Representation` == `VTK_WIREFRAME`
83 };
84
86
96 VTK_DEPRECATED_IN_9_7_0("Use DispatchMeshToPrimitiveComputePipeline() that accepts const "
97 "std::array<T*, N> parameters instead.")
99 vtkPolyData* mesh, int representation, vtkTypeUInt32* vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES],
100 wgpu::Buffer* connectivityBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
101 wgpu::Buffer* cellIdBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
102 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
103 wgpu::Buffer* cellIdOffsetUniformBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
105 vtkPolyData* mesh, int representation,
106 const std::array<vtkTypeUInt32*, NUM_TOPOLOGY_SOURCE_TYPES>& vertexCounts,
107 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& connectivityBuffers,
108 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& cellIdBuffers,
109 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& edgeArrayBuffers,
110 const std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& cellIdOffsetUniformBuffers);
112
124 std::vector<vtkPolyData*> meshes, int representation,
125 std::vector<std::pair<vtkTypeUInt32, vtkTypeUInt32>>*
126 vertexOffsetAndCounts[NUM_TOPOLOGY_SOURCE_TYPES],
127 std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& connectivityBuffers,
128 std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& cellIdBuffers,
129 std::array<wgpu::Buffer*, NUM_TOPOLOGY_SOURCE_TYPES>& edgeArrayBuffers);
130
139 VTK_DEPRECATED_IN_9_7_0("Use DispatchCellArrayToPrimitiveComputePipeline() instead.")
141 vtkCellArray* cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset,
142 vtkTypeUInt32* vertexCount, wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer,
143 wgpu::Buffer* edgeArrayBuffer, wgpu::Buffer* cellIdOffsetUniformBuffer);
144
154 vtkCellArray* cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset,
155 vtkTypeUInt32* vertexCount, wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer,
156 wgpu::Buffer* edgeArrayBuffer, wgpu::Buffer* cellIdOffsetUniformBuffer,
157 vtkDataArray* pointCoordinates = nullptr);
158
170 const std::vector<vtkCellArray*>& cellArrays, int representation, int cellType,
171 const std::vector<vtkIdType>& numberOfPoints,
172 std::vector<std::pair<vtkTypeUInt32, vtkTypeUInt32>>* vertexOffsetAndCounts,
173 wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer, wgpu::Buffer* edgeArrayBuffer,
174 const std::vector<vtkDataArray*>& pointCoordinates = {});
175
183
189
198
202 static const char* GetTopologySourceTypeAsString(TopologySourceType topologySourceType);
203
207 static const char* GetCellTypeAsString(int cellType);
208
213 static const char* GetTessellatedPrimitiveTypeAsString(TopologySourceType topologySourceType);
214
218 static std::size_t GetTessellatedPrimitiveSize(TopologySourceType topologySourceType);
219
224 int cellType, int representation = VTK_SURFACE);
225
226protected:
229
230private:
232 void operator=(const vtkWebGPUCellToPrimitiveConverter&) = delete;
233
239 std::pair<vtkSmartPointer<vtkWebGPUComputePass>, vtkSmartPointer<vtkWebGPUComputePipeline>>
240 CreateCellToPrimitiveComputePassForCellType(
242 TopologySourceType topologySourceType);
243
244 // Timestamps help reuse previous resources as much as possible.
246 // compute pass speeds up cell to primitive conversions.
249 // compute pipeline to execute the compute pass.
252};
253
254VTK_ABI_NAMESPACE_END
255
256#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.
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.
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, const std::vector< vtkDataArray * > &pointCoordinates={})
Tessellates the a collection of cell arrays into graphics primitives.
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.
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.
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, vtkDataArray *pointCoordinates=nullptr)
Tessellates each cell into primitives.
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 vtkDataArray
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_SURFACE
int vtkIdType
Definition vtkType.h:363