VTK  9.5.20250607
vtkWebGPUBatchedPolyDataMapper.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
3
11#ifndef vtkWebGPUBatchedPolyDataMapper_h
12#define vtkWebGPUBatchedPolyDataMapper_h
13
15
16#include "vtkRenderingWebGPUModule.h" // for export macro
17#include "vtkWebGPUCompositePolyDataMapperDelegator.h" // for struct BatchElement
18
19#include <cstdint> // for std::uintptr_t
20#include <memory> // for unique_ptr
21
22VTK_ABI_NAMESPACE_BEGIN
24class vtkPolyData;
25
26class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUBatchedPolyDataMapper : public vtkWebGPUPolyDataMapper
27{
28public:
31 void PrintSelf(ostream& os, vtkIndent indent) override;
32
34
38 void AddBatchElement(unsigned int flatIndex, BatchElement&& batchElement);
42
46 std::vector<vtkPolyData*> GetRenderedList() const;
48
52 void RenderPiece(vtkRenderer* renderer, vtkActor* actor) override;
55
60
67
68protected:
71
72 // Reference to CPDM
73 vtkCompositePolyDataMapper* Parent = nullptr;
74 // Maps an address of a vtkPolyData to its rendering attributes.
75 std::map<std::uintptr_t, std::unique_ptr<BatchElement>> VTKPolyDataToBatchElement;
76 std::map<unsigned int, std::uintptr_t> FlatIndexToPolyData;
77
78 // Upload timestamp of override colors.
80 bool LastBlockVisibility = true;
81 bool LastUseNanColor = false;
82
84 {
85 vtkTypeUInt32 ApplyOverrideColors = 0;
86 vtkTypeFloat32 Opacity = 0;
87 vtkTypeUInt32 CompositeId = 0;
88 vtkTypeUInt32 Pickable = 1;
89 vtkTypeFloat32 Ambient[3] = {};
90 vtkTypeUInt32 Pad = 0;
91 vtkTypeFloat32 Diffuse[3] = {};
92 };
94
95 std::vector<wgpu::BindGroupLayoutEntry> GetMeshBindGroupLayoutEntries() override;
96 std::vector<wgpu::BindGroupEntry> GetMeshBindGroupEntries() override;
97
99 bool applyOverrides, double overrideOpacity, const vtkColor3d& overrideAmbientColor,
100 const vtkColor3d& overrideDiffuseColor, vtkTypeUInt32 compositeId, bool pickable);
101
103 GraphicsPipelineType pipelineType, std::string& vss, std::string& fss) override;
105 GraphicsPipelineType pipelineType, std::string& vss, std::string& fss) override;
106
107 void ReplaceVertexShaderPicking(GraphicsPipelineType pipelineType, std::string& vss) override;
108
109 void ReplaceFragmentShaderColors(GraphicsPipelineType pipelineType, std::string& fss) override;
110 void ReplaceFragmentShaderPicking(GraphicsPipelineType pipelineType, std::string& fss) override;
111
112private:
114 void operator=(const vtkWebGPUBatchedPolyDataMapper&) = delete;
115};
116
117VTK_ABI_NAMESPACE_END
118#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a class that renders hierarchical polygonal data
a simple class to control print indentation
Definition vtkIndent.h:108
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract specification for renderers
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
A WebGPU mapper for batched rendering of vtkPolyData.
void ReplaceShaderCustomDef(GraphicsPipelineType pipelineType, std::string &vss, std::string &fss) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RenderPiece(vtkRenderer *renderer, vtkActor *actor) override
Implemented by sub classes.
BatchElement * GetBatchElement(vtkPolyData *polydata)
API to add and query a BatchElement instance per vtkPolyData.
std::map< std::uintptr_t, std::unique_ptr< BatchElement > > VTKPolyDataToBatchElement
void ReplaceFragmentShaderColors(GraphicsPipelineType pipelineType, std::string &fss) override
std::vector< vtkPolyData * > GetRenderedList() const
Accessor to the ordered list of PolyData that we last drew.
void ReplaceVertexShaderPicking(GraphicsPipelineType pipelineType, std::string &vss) override
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
std::vector< wgpu::BindGroupEntry > GetMeshBindGroupEntries() override
vtkMTimeType GetMTime() override
Returns the maximum of our and Parent vtkCompositePolyDataMapper's MTime.
~vtkWebGPUBatchedPolyDataMapper() override
static vtkWebGPUBatchedPolyDataMapper * New()
std::vector< wgpu::BindGroupLayoutEntry > GetMeshBindGroupLayoutEntries() override
void UploadCompositeDataProperties(vtkSmartPointer< vtkWebGPUConfiguration > wgpuConfiguration, bool applyOverrides, double overrideOpacity, const vtkColor3d &overrideAmbientColor, const vtkColor3d &overrideDiffuseColor, vtkTypeUInt32 compositeId, bool pickable)
void ReplaceFragmentShaderPicking(GraphicsPipelineType pipelineType, std::string &fss) override
std::map< unsigned int, std::uintptr_t > FlatIndexToPolyData
void ClearBatchElements()
API to add and query a BatchElement instance per vtkPolyData.
void AddBatchElement(unsigned int flatIndex, BatchElement &&batchElement)
API to add and query a BatchElement instance per vtkPolyData.
void SetParent(vtkCompositePolyDataMapper *parent)
void ReplaceShaderCustomBindings(GraphicsPipelineType pipelineType, std::string &vss, std::string &fss) override
vtkCompositePolyDataMapperDelegator::BatchElement BatchElement
GraphicsPipelineType
This mapper uses different wgpu::RenderPipeline to render a list of primitives.
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287