VTK  9.5.20250608
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* connectivityBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
94 wgpu::Buffer* cellIdBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
95 wgpu::Buffer* edgeArrayBuffers[NUM_TOPOLOGY_SOURCE_TYPES],
96 wgpu::Buffer* cellIdOffsetUniformBuffers[NUM_TOPOLOGY_SOURCE_TYPES]);
97
107 vtkCellArray* cells, int representation, int cellType, vtkTypeUInt32 cellIdOffset,
108 vtkTypeUInt32* vertexCount, wgpu::Buffer* connectivityBuffer, wgpu::Buffer* cellIdBuffer,
109 wgpu::Buffer* edgeArrayBuffer, wgpu::Buffer* cellIdOffsetUniformBuffer);
110
118
124
133
137 static const char* GetTopologySourceTypeAsString(TopologySourceType topologySourceType);
138
142 static const char* GetCellTypeAsString(int cellType);
143
148 static const char* GetTessellatedPrimitiveTypeAsString(TopologySourceType topologySourceType);
149
153 static std::size_t GetTessellatedPrimitiveSize(TopologySourceType topologySourceType);
154
159 int cellType, int representation = VTK_SURFACE);
160
161protected:
164
165 // Timestamps help reuse previous resources as much as possible.
167 // compute pass speeds up cell to primitive conversions.
170 // compute pipeline to execute the compute pass.
173
174private:
176 void operator=(const vtkWebGPUCellToPrimitiveConverter&) = delete;
177
183 std::pair<vtkSmartPointer<vtkWebGPUComputePass>, vtkSmartPointer<vtkWebGPUComputePipeline>>
184 CreateCellToPrimitiveComputePassForCellType(
186 TopologySourceType topologySourceType);
187};
188
189VTK_ABI_NAMESPACE_END
190
191#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.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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.
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:332