VTK  9.4.20241218
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
20#ifndef vtkWebGPUCellToPrimitiveConverter_h
21#define vtkWebGPUCellToPrimitiveConverter_h
22
23#include "vtkObject.h"
24
25#include "vtkProperty.h" // for VTK_SURFACE
26#include "vtkRenderingWebGPUModule.h" // for export macro
27#include "vtkSmartPointer.h" // for vtkSmartPointer
28
29#include "vtk_wgpu.h" // for wgpu::Buffer
30
31#include <utility> // for std::pair
32
33VTK_ABI_NAMESPACE_BEGIN
35class vtkPolyData;
36class vtkCellArray;
39
40class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUCellToPrimitiveConverter : public vtkObject
41{
42public:
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
53
59 {
60 // Used to draw VTK_VERTEX and VTK_POLY_VERTEX cell types
61 TOPOLOGY_SOURCE_VERTS = 0,
62 // Used to draw VTK_LINE and VTK_POLY_LINE cell types.
64 // Used to draw only the points of each line segment.
65 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
67 // Used to draw VTK_QUAD, VTK_TRIANGLE and VTK_POLYGON cell types.
69 // Used to draw only the corner points of each face.
70 // Activated when `vtkProperty::Representation` == `VTK_POINTS`
72 // Used to draw only the edges of each face.
73 // Activated when `vtkProperty::Representation` == `VTK_WIREFRAME`
75 NUM_TOPOLOGY_SOURCE_TYPES
76 };
77
89 vtkPolyData* mesh, int representation, vtkTypeUInt32* vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES],
90 wgpu::Buffer* topologyBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
91 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
92
102 vtkCellArray* cells, int representation, int cellType, vtkIdType cellIdOffset,
103 vtkTypeUInt32* vertexCounts[NUM_TOPOLOGY_SOURCE_TYPES],
104 wgpu::Buffer* topologyBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
105 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
106
114
120
129
133 static const char* GetTopologySourceTypeAsString(TopologySourceType topologySourceType);
134
138 static const char* GetCellTypeAsString(int cellType);
139
144 static const char* GetTessellatedPrimitiveTypeAsString(TopologySourceType topologySourceType);
145
149 static std::size_t GetTessellatedPrimitiveSize(TopologySourceType topologySourceType);
150
155 int cellType, int representation = VTK_SURFACE);
156
157protected:
160
161 // Timestamps help reuse previous resources as much as possible.
163 // compute pass speeds up cell to primitive conversions.
166 // compute pipeline to execute the compute pass.
169
170private:
172 void operator=(const vtkWebGPUCellToPrimitiveConverter&) = delete;
173
179 std::pair<vtkSmartPointer<vtkWebGPUComputePass>, vtkSmartPointer<vtkWebGPUComputePipeline>>
180 CreateCellToPrimitiveComputePassForCellType(
182 TopologySourceType topologySourceType);
183};
184
185VTK_ABI_NAMESPACE_END
186
187#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