VTK  9.4.20250130
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
23#ifndef vtkWebGPUCellToPrimitiveConverter_h
24#define vtkWebGPUCellToPrimitiveConverter_h
25
26#include "vtkObject.h"
27
28#include "vtkProperty.h" // for VTK_SURFACE
29#include "vtkRenderingWebGPUModule.h" // for export macro
30#include "vtkSmartPointer.h" // for vtkSmartPointer
31
32#include "vtk_wgpu.h" // for wgpu::Buffer
33
34#include <utility> // for std::pair
35
36VTK_ABI_NAMESPACE_BEGIN
38class vtkPolyData;
39class vtkCellArray;
42
43class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUCellToPrimitiveConverter : public vtkObject
44{
45public:
48 void PrintSelf(ostream& os, vtkIndent indent) override;
49
56
62 {
63 // Used to draw VTK_VERTEX and VTK_POLY_VERTEX cell types
64 TOPOLOGY_SOURCE_VERTS = 0,
65 // Used to draw VTK_LINE and VTK_POLY_LINE cell types.
67 // Used to draw only the points of each line segment.
68 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
70 // Used to draw VTK_QUAD, VTK_TRIANGLE and VTK_POLYGON cell types.
72 // Used to draw only the corner points of each face.
73 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
75 // Used to draw only the edges of each face.
76 // Activated when `vtkProperty::Representation` == `VTK_WIREFRAME`
78 NUM_TOPOLOGY_SOURCE_TYPES
79 };
80
92 vtkPolyData* mesh, int representation, vtkTypeUInt32* vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES],
93 wgpu::Buffer* topologyBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
94 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
95
105 vtkCellArray* cells, int representation, int cellType, vtkIdType cellIdOffset,
106 vtkTypeUInt32* vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES],
107 wgpu::Buffer* topologyBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
108 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
109
117
123
132
136 static const char* GetTopologySourceTypeAsString(TopologySourceType topologySourceType);
137
141 static const char* GetCellTypeAsString(int cellType);
142
147 static const char* GetTessellatedPrimitiveTypeAsString(TopologySourceType topologySourceType);
148
152 static std::size_t GetTessellatedPrimitiveSize(TopologySourceType topologySourceType);
153
158 int cellType, int representation = VTK_SURFACE);
159
160protected:
163
164 // Timestamps help reuse previous resources as much as possible.
166 // compute pass speeds up cell to primitive conversions.
169 // compute pipeline to execute the compute pass.
172
173private:
175 void operator=(const vtkWebGPUCellToPrimitiveConverter&) = delete;
176
182 std::pair<vtkSmartPointer<vtkWebGPUComputePass>, vtkSmartPointer<vtkWebGPUComputePipeline>>
183 CreateCellToPrimitiveComputePassForCellType(
185 TopologySourceType topologySourceType);
186};
187
188VTK_ABI_NAMESPACE_END
189
190#endif
object to represent cell connectivity
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
concrete dataset represents vertices, lines, polygons, and triangle strips
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
Converts VTK cell connectivity arrays into webgpu primitives using compute shaders.
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 DispatchCellToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, vtkCellArray *cells, int representation, int cellType, vtkIdType cellIdOffset, vtkTypeUInt32 *vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *topologyBuffers[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES])
Tessellates each cell into primitives.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool DispatchMeshToPrimitiveComputePipeline(vtkWebGPUConfiguration *wgpuConfiguration, vtkPolyData *mesh, int representation, vtkTypeUInt32 *vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *topologyBuffers[NUM_TOPOLOGY_SOURCE_TYPES], wgpu::Buffer *edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES])
Tessellates the cells in a mesh 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.
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.
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:48
#define VTK_SURFACE
int vtkIdType
Definition vtkType.h:315