VTK  9.7.20261128
vtkWebGPUPolyDataMapper.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#ifndef vtkWebGPUPolyDataMapper_h
4#define vtkWebGPUPolyDataMapper_h
5
6#include "vtkPolyDataMapper.h"
7
8#include "vtkProperty.h" // for VTK_SURFACE constants
9#include "vtkRenderingWebGPUModule.h" // for export macro
10#include "vtkWeakPointer.h" // for ivar
11#include "vtkWebGPUCellToPrimitiveConverter.h" // for TopologySourceType
12#include "vtkWebGPUComputePipeline.h" // for ivar
13#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
14#include "vtk_wgpu.h" // for webgpu C API
15
16#include <array> // for ivar
17#include <unordered_set> // for the not set compute render buffers
18#include <utility> // for std::pair
19#include <vector> // for ivar
20
21VTK_ABI_NAMESPACE_BEGIN
22class vtkCellArray;
24class vtkWebGPUActor;
30
31class VTKRENDERINGWEBGPU_EXPORT VTK_MARSHALAUTO vtkWebGPUPolyDataMapper : public vtkPolyDataMapper
32{
33public:
38 void PrintSelf(ostream& os, vtkIndent indent) override;
39
54
65
72 {
73 // Pipeline that renders points, is best suitable for rendering 1-pixel wide points.
76 // Pipeline that renders points using a square or circle shape.
79 // Pipeline that is best suitable for rendering 1-pixel thick line segments
82 // Pipeline that can render lines thicker than 1-pixel. This pipeline does not
83 // create joining geometry between contiguous line segments in a polyline.
86 // Pipeline that renders lines with rounded caps and rounded joins.
89 // Pipeline that renders lines with miter joins.
92 // Pipeline that renders triangles
96 };
97
99
103 void RenderPiece(vtkRenderer* renderer, vtkActor* act) override;
104
111
118 bool GetSupportsSelection() override { return false; }
119
131 void MapDataArrayToVertexAttribute(const char* vertexAttributeName, const char* dataArrayName,
132 int fieldAssociation, int componentno = -1) override;
133
141 void MapDataArrayToMultiTextureAttribute(const char* tname, const char* dataArrayName,
142 int fieldAssociation, int componentno = -1) override;
143
147 void RemoveVertexAttributeMapping(const char* vertexAttributeName) override;
148
153
159 vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override;
160
177 PointDataAttributes attribute, int bufferGroup, int bufferBinding, int uniformsGroup,
178 int uniformsBinding);
179
184 CellDataAttributes attribute, int bufferGroup, int bufferBinding, int uniformsGroup,
185 int uniformsBinding);
186
187protected:
190
196 void ComputeBounds() override;
197
203 vtkRenderer* renderer, vtkActor* actor, const WGPURenderPassEncoder& passEncoder);
205 vtkRenderer* renderer, vtkActor* actor, const WGPURenderBundleEncoder& bundleEncoder);
206
213 vtkRenderer* renderer, vtkActor* actor, const WGPURenderPassEncoder& passEncoder);
215 vtkRenderer* renderer, vtkActor* actor, const WGPURenderBundleEncoder& bundleEncoder);
216
222
227 virtual std::vector<WGPUBindGroupLayoutEntry> GetMeshBindGroupLayoutEntries();
228
233 virtual std::vector<WGPUBindGroupLayoutEntry> GetTopologyBindGroupLayoutEntries(
234 bool homogeneousCellSize, bool useEdgeArray);
235
240 virtual std::vector<WGPUBindGroupEntry> GetMeshBindGroupEntries();
241
246 virtual std::vector<WGPUBindGroupEntry> GetTopologyBindGroupEntries(
248 bool homogeneousCellSize, bool useEdgeArray);
249
253 virtual unsigned long GetPointAttributeByteSize(
255
259 virtual unsigned long GetCellAttributeByteSize(
261
267
281 virtual void UpdateMeshGeometryBuffers(vtkWebGPUConfiguration* wgpuConfiguration);
282
287
292 virtual bool EnsureInput();
293
298 vtkWebGPUConfiguration* wgpuConfiguration, vtkProperty* displayProperty);
299
300 virtual std::vector<WGPUVertexBufferLayout> GetVertexBufferLayouts() { return {}; }
301
302 virtual void SetVertexBuffers(const WGPURenderPassEncoder& vtkNotUsed(passEncoder)) {}
303 virtual void SetVertexBuffers(const WGPURenderBundleEncoder& vtkNotUsed(bundleEncoder)) {}
304
309 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
310
311 virtual bool BuildSlangShaders(vtkWebGPURenderer* renderer, vtkWebGPUActor* actor,
312 GraphicsPipelineType pipelineType, std::string& wgsl);
313
315
316 virtual std::vector<std::pair<std::string, std::string>> GetSlangDefines(
317 vtkWebGPUActor* actor, GraphicsPipelineType pipelineType);
322 std::string SlangCompileError;
323
325 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
327 vtkWebGPUActor* actor, std::string& vss, std::string& fss);
329 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
331 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
332
334 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
336 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
338 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
340 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
342 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
344 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
346 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss, std::string& fss);
347
349 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
351 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
353 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
355 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
357 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
359 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
361 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
363 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
365 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
367 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
369 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
371 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
373 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
375 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
377 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
379 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
381 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& vss);
382
387 static bool UsesDeepFramebuffer(vtkWebGPURenderer* wgpuRenderer, vtkWebGPUActor* wgpuActor);
388
396 static bool ShouldRecordDrawCommands(vtkWebGPURenderer* wgpuRenderer, vtkWebGPUActor* wgpuActor);
397
404 static bool IsSelectingPoints(vtkWebGPURenderer* wgpuRenderer);
405
407 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
408
410 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
412 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
414 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
416 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
418 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
420 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
422 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
424 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
426 vtkWebGPURenderer* renderer, vtkWebGPUActor* actor, std::string& fss);
427
436 virtual bool IsPipelineSupported(GraphicsPipelineType vtkNotUsed(pipelineType)) { return true; }
438
443 {
445 std::vector<vtkWebGPUCellToPrimitiveConverter::TopologySourceType> BindGroupTypes;
446 // Vertices drawn on top of a surface or wireframe use their own draw call arguments.
447 bool DrawAsVertices = false;
448 };
449
454 std::vector<ActivePipeline> CollectActivePipelines(vtkActor* actor, int representation);
455
459 virtual WGPUPrimitiveTopology GetPrimitiveTopologyForPipeline(GraphicsPipelineType pipelineType);
460
462 {
463 std::uint32_t VertexOffset = 0;
464 std::uint32_t VertexCount = 0;
465 std::uint32_t InstanceOffset = 0;
466 std::uint32_t InstanceCount = 0;
467 };
472
477 WGPUBindGroup CreateMeshAttributeBindGroup(const WGPUDevice& device, const std::string& label);
478
484 WGPUBindGroup CreateTopologyBindGroup(const WGPUDevice& device, const std::string& label,
486
488 {
489 WGPUBuffer Buffer = nullptr;
490 uint64_t Size = 0;
491 uint64_t Watermark = 0;
492 bool Touched = false;
493 // What each upload since BeginUpdateMeshGeometryBuffers() wrote, and where. A batched
494 // mapper writes several meshes into one buffer.
495 struct Upload
496 {
497 // Weak, so that an array allocated at the address of a freed one does not compare equal.
499 uint64_t Offset = 0;
500 };
501 std::vector<Upload> Uploads;
502 std::size_t NumberOfUploads = 0;
503
509 bool RecordUpload(vtkDataArray* array, vtkMTimeType buildTime);
510 };
513 struct
514 {
515 vtkTypeFloat32 PlaneEquations[6][4];
516 vtkTypeUInt32 PlaneCount = 0;
517 } ClippingPlanesData;
518 WGPUBuffer ClippingPlanesBuffer = nullptr;
519
525
529 bool SelectingPoints = false;
531 // used by RenderPiece and functions it calls to reduce
532 // calls to get the input and allow for rendering of
533 // other polydata when this mapper is run in batch mode
535 // vtkRenderer culls props to frustum. At that point, it requests
536 // mappers for bounds of the geometry. We cache the vtkAlgorithm output
537 // so that `UpdateMeshGeometryBuffers` can reuse it without climbing up
538 // vtkAlgorithm pipeline.
541
542 // 1 bind group for this polydata's `vtkPoints`, `vtkPointData` and `vtkCellData`
543 WGPUBindGroup MeshAttributeBindGroup = nullptr;
544 std::vector<std::uint32_t> MeshAttributeDynamicOffsets;
545
547 {
548 // buffer for point ids.
549 WGPUBuffer ConnectivityBuffer = nullptr;
550 // buffer for the cell ids.
551 WGPUBuffer CellIdBuffer = nullptr;
552 // buffer for edge array. this lets fragment shader hide internal edges of a polygon
553 // when edge visibility is turned on.
554 WGPUBuffer EdgeArrayBuffer = nullptr;
555 // uniform buffer for cell id offset.
556 WGPUBuffer CellIdOffsetUniformBuffer = nullptr;
557 // bind group for connectivity and cell_id_offset when the cell size is homogeneous,
558 // otherwise for connectivity, cell_ids and, when edges are drawn, edge_array.
559 WGPUBindGroup BindGroup = nullptr;
560 // maximum number of vertices in a cell
561 vtkTypeUInt32 MaxCellSize = 0;
562 // vertexCount for draw call.
563 vtkTypeUInt32 VertexCount = 0;
564 // composite vertex offset and counts for drawing composite data, used instead of the
565 // `VertexCount` above
566 std::vector<std::pair<vtkTypeUInt32, vtkTypeUInt32>> VertexOffsetAndCounts;
567 };
568
569 enum BindingGroup : int
570 {
575 // Clipping planes are bound to the same group as the mesh attributes
576 // because they vary based on the mapper's shift/scale and the actor's
577 // transformation matrix.
581 };
582 static_assert(GROUP_NB_BINDGROUPS <= 4,
583 "Number of bind groups exceeds 4! Most devices can support only up to 4 bind groups");
584 std::array<std::uint32_t, GROUP_NB_BINDGROUPS> NumberOfBindings = {};
590
591private:
593 void operator=(const vtkWebGPUPolyDataMapper&) = delete;
595 friend class vtkWebGPURenderer;
596
601 static vtkTypeUInt32 GetShadingFeatures(vtkActor* actor, vtkRenderer* renderer);
602
607 void ReleaseTopologyBindGroupInfos();
608
612 WGPUBuffer GetPointDataWGPUBuffer(PointDataAttributes attribute)
613 {
614 return this->PointBuffers[attribute].Buffer;
615 }
616
620 WGPUBuffer GetCellDataWGPUBuffer(CellDataAttributes attribute)
621 {
622 return this->CellBuffers[attribute].Buffer;
623 }
624
628 void UploadAttributeToGPUBuffer(vtkWebGPUConfiguration* wgpuConfiguration,
629 vtkDataArray* dataArray, PointDataAttributes attributeType, float denominator = 1.0f);
630 void UploadAttributeToGPUBuffer(vtkWebGPUConfiguration* wgpuConfiguration,
631 vtkDataArray* dataArray, CellDataAttributes attributeType, float denominator = 1.0f);
632
638 bool GetNeedToRebuildGraphicsPipelines(vtkActor* actor, vtkRenderer* renderer);
639
650 bool CacheActorRendererProperties(vtkActor* actor, vtkRenderer* renderer);
651
655 void ResetPointCellAttributeState();
656
660 WGPUBindGroupLayout CreateMeshAttributeBindGroupLayout(
661 const WGPUDevice& device, const std::string& label);
662
666 WGPUBindGroupLayout CreateTopologyBindGroupLayout(const WGPUDevice& device,
667 const std::string& label, bool homogeneousCellSize, bool useEdgeArray);
668
673 unsigned long GetPointAttributeElementSize(
675
680 unsigned long GetCellAttributeElementSize(vtkWebGPUPolyDataMapper::CellDataAttributes attribute);
681
687 unsigned long GetExactPointBufferSize(PointDataAttributes attribute);
688
694 unsigned long GetExactCellBufferSize(CellDataAttributes attribute);
695
699 bool AllocateAttributeBuffers(vtkWebGPUConfiguration* wgpuConfiguration);
700
704 const char* GetGraphicsPipelineTypeAsString(GraphicsPipelineType graphicsPipelineType);
705
710 void SetupGraphicsPipelines(const WGPUDevice& device, vtkRenderer* renderer, vtkActor* actor);
711
715 void UpdateClippingPlanesBuffer(vtkWebGPUConfiguration* wgpuConfiguration, vtkActor* actor);
716
723 std::vector<vtkSmartPointer<vtkWebGPUComputeRenderBuffer>> SetupComputeRenderBuffers;
724
728 std::unordered_set<vtkSmartPointer<vtkWebGPUComputeRenderBuffer>> NotSetupComputeRenderBuffers;
729
733 const PointDataAttributes PointDataAttributesOrder[PointDataAttributes::POINT_NB_ATTRIBUTES] = {
734 PointDataAttributes::POINT_POSITIONS, PointDataAttributes::POINT_COLORS,
735 PointDataAttributes::POINT_NORMALS, PointDataAttributes::POINT_TANGENTS,
736 PointDataAttributes::POINT_UVS, PointDataAttributes::POINT_COLOR_UVS
737 };
738
742 const CellDataAttributes CellDataAttributesOrder[CellDataAttributes::CELL_NB_ATTRIBUTES] = {
743 CellDataAttributes::CELL_COLORS, CellDataAttributes::CELL_NORMALS
744 };
745
746 // Cache these so that subsequent executions of UpdateMeshGeometryBuffers() do not unnecessarily
747 // invoke MapScalars().
748 int LastScalarMode = -1;
749 bool LastScalarVisibility = false;
750 vtkTypeUInt32 LastNumClipPlanes = 0;
751 struct ActorState
752 {
753 bool LastActorBackfaceCulling = false;
754 bool LastActorFrontfaceCulling = false;
755 bool LastVertexVisibility = false;
756 int LastRepresentation = VTK_SURFACE;
757 bool LastHasRenderingTranslucentGeometry = false;
758 bool LastWidePoints = false;
759 bool LastWideLines = false;
761 bool LastSelectingPoints = false;
762 vtkTypeUInt32 LastShadingFeatures = 0;
763 vtkMTimeType LastShaderPropertyMTime = 0;
764 };
765 std::map<std::pair<vtkActor*, vtkRenderer*>, ActorState> CachedActorRendererProperties;
766};
767#define vtkWebGPUPolyDataMapper_OVERRIDE_ATTRIBUTES \
768 vtkWebGPUPolyDataMapper::CreateOverrideAttributes()
769VTK_ABI_NAMESPACE_END
770#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
object to represent cell connectivity
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:168
Attribute for vtkObjectFactory overrides.
std::uintptr_t MapperHashType
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:68
represent surface properties of a geometric object
abstract specification for renderers
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
a weak reference to a vtkObject.
TopologySourceType
All supported types of topology.
Render buffers are returned by calls to vtkWebGPUPolyDataMapper::AcquirePointAttributeComputeRenderBu...
Create a webgpu device for use in rendering and compute pipelines.
vtkTimeStamp PointAttributesBuildTimestamp[POINT_NB_ATTRIBUTES]
Timestamps help reuse previous resources as much as possible.
PointDataAttributes
All the attributes supported by the point data buffer.
virtual unsigned long GetPointAttributeByteSize(vtkWebGPUPolyDataMapper::PointDataAttributes attribute)
Returns the size of the 'sub-buffer' within the whole point data SSBO for the given attribute.
void ProcessSelectorPixelBuffers(vtkHardwareSelector *sel, std::vector< unsigned int > &pixeloffsets, vtkProp *prop) override
allows a mapper to update a selections color buffers Called from a prop which in turn is called from ...
virtual void ReplaceShaderCustomDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
virtual void ReplaceVertexShaderMainEnd(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
void RecordPointSelectionDepthPass(vtkRenderer *renderer, vtkActor *actor, const WGPURenderPassEncoder &passEncoder)
Draw the surface into the depth attachment only, so the points drawn afterwards for a point selection...
virtual void BeginUpdateMeshGeometryBuffers()
Set all point/cell buffer's Touched flag to false.
virtual void ReplaceShaderMeshAttributeBindings(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
virtual void ReplaceVertexShaderPositionVC(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceShaderVertexOutputDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
virtual void ReplaceVertexShaderNormalTransform(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceFragmentShaderMainEnd(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
virtual void ReplaceFragmentShaderMainStart(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
virtual void ReplaceFragmentShaderClippingPlanes(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
virtual void SetVertexBuffers(const WGPURenderBundleEncoder &bundleEncoder)
virtual std::vector< WGPUBindGroupEntry > GetMeshBindGroupEntries()
Allow subclasses to customize the entries in the bind group corresponding to GROUP_MESH.
static bool ShouldRecordDrawCommands(vtkWebGPURenderer *wgpuRenderer, vtkWebGPUActor *wgpuActor)
Whether draw commands should be recorded in the pass being recorded now.
virtual void ReplaceFragmentShaderCoincidentOffset(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
virtual void EndUpdateMeshGeometryBuffers()
Timestamp the buffers whose Touched flag is true.
vtkTypeFloat32 PlaneEquations[6][4]
std::array< std::uint32_t, GROUP_NB_BINDGROUPS > NumberOfBindings
std::vector< ActivePipeline > CollectActivePipelines(vtkActor *actor, int representation)
virtual void ReplaceVertexShaderPicking(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
vtkTimeStamp ClippingPlanesBuildTimestamp
Timestamps help reuse previous resources as much as possible.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool HasCellAttributes[CELL_NB_ATTRIBUTES]
void MapDataArrayToVertexAttribute(const char *vertexAttributeName, const char *dataArrayName, int fieldAssociation, int componentno=-1) override
Select a data array from the point/cell data and map it to a generic vertex attribute.
virtual void ReplaceShaderClippingPlanesBindings(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
void RemoveAllVertexAttributeMappings() override
Remove all vertex attributes.
virtual std::vector< WGPUBindGroupEntry > GetTopologyBindGroupEntries(vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType, bool homogeneousCellSize, bool useEdgeArray)
Allow subclasses to customize the entries in the bind group corresponding to GROUP_TOPOLOGY.
AttributeBuffer CellBuffers[CELL_NB_ATTRIBUTES]
vtkPolyDataMapper::MapperHashType GenerateHash(vtkPolyData *polydata) override
This hash integer is computed by concrete graphics implementation of this class.
virtual std::vector< std::pair< std::string, std::string > > GetSlangDefines(vtkWebGPUActor *actor, GraphicsPipelineType pipelineType)
WGPUBindGroup CreateTopologyBindGroup(const WGPUDevice &device, const std::string &label, vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType)
Create a bind group for the primitives of a mesh.
void RecordPointSelectionDepthPass(vtkRenderer *renderer, vtkActor *actor, const WGPURenderBundleEncoder &bundleEncoder)
virtual void DeducePointCellAttributeAvailability()
Looks at the point/cell data of vtkPolyData object and determines which attributes are available.
vtkSmartPointer< vtkWebGPUTexture > ColorTextureHostResource
virtual bool EnsureInput()
Ensures that the input data is valid and ready for processing.
static bool IsSelectingPoints(vtkWebGPURenderer *wgpuRenderer)
Whether a hardware selection of points is in progress.
virtual void ReplaceShaderRendererBindings(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
virtual std::vector< WGPUBindGroupLayoutEntry > GetTopologyBindGroupLayoutEntries(bool homogeneousCellSize, bool useEdgeArray)
Allow subclasses to customize the entries in the bind group layout corresponding to GROUP_TOPOLOGY.
vtkTimeStamp CellAttributesBuildTimestamp[CELL_NB_ATTRIBUTES]
Timestamps help reuse previous resources as much as possible.
vtkSmartPointer< vtkWebGPUComputeRenderBuffer > AcquirePointAttributeComputeRenderBuffer(PointDataAttributes attribute, int bufferGroup, int bufferBinding, int uniformsGroup, int uniformsBinding)
Returns an already configured (ready to be added to a vtkWebGPUComputePipeline) buffer bound to the g...
virtual void ReplaceFragmentShaderOutputDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
vtkSmartPointer< vtkWebGPUComputeRenderBuffer > AcquireCellAttributeComputeRenderBuffer(CellDataAttributes attribute, int bufferGroup, int bufferBinding, int uniformsGroup, int uniformsBinding)
Same as AcquirePointAttributeComputeRenderBuffer but for cell data attributes.
virtual void ReplaceShaderActorBindings(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
WGPUBindGroup CreateMeshAttributeBindGroup(const WGPUDevice &device, const std::string &label)
Create a bind group for the point and cell attributes of a mesh.
virtual void ReplaceVertexShaderClippingPlanes(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
AttributeBuffer PointBuffers[POINT_NB_ATTRIBUTES]
virtual void ReplaceFragmentShaderColors(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
void RecordDrawCommands(vtkRenderer *renderer, vtkActor *actor, const WGPURenderBundleEncoder &bundleEncoder)
TopologyBindGroupInfo TopologyBindGroupInfos[vtkWebGPUCellToPrimitiveConverter::NUM_TOPOLOGY_SOURCE_TYPES]
virtual void ReplaceVertexShaderEdges(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceVertexShaderPrimitiveId(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
static vtkMTimeType GetShaderStateMTime(vtkActor *actor)
std::string PointSelectionDepthKeys[GFX_PIPELINE_NB_TYPES]
std::string GraphicsPipelineKeys[GFX_PIPELINE_NB_TYPES]
virtual void SetVertexBuffers(const WGPURenderPassEncoder &passEncoder)
virtual void ReplaceVertexShaderPosition(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
void RemoveVertexAttributeMapping(const char *vertexAttributeName) override
Remove a vertex attribute mapping.
virtual bool IsPipelineSupported(GraphicsPipelineType pipelineType)
Whether shaders must be built to target the specific pipeline.
static vtkWebGPUPolyDataMapper * New()
virtual std::vector< WGPUVertexBufferLayout > GetVertexBufferLayouts()
bool PrepareSlangShaders(vtkWebGPUActor *actor, vtkRenderer *renderer)
virtual void ReplaceVertexShaderMainStart(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceFragmentShaderNormals(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
~vtkWebGPUPolyDataMapper() override
std::vector< std::uint32_t > MeshAttributeDynamicOffsets
virtual void ReplaceFragmentShaderEdges(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
virtual DrawCallArgs GetDrawCallArgsForDrawingVertices(vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType)
virtual bool BuildSlangShaders(vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, GraphicsPipelineType pipelineType, std::string &wgsl)
virtual DrawCallArgs GetDrawCallArgs(GraphicsPipelineType pipelineType, vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType)
vtkNew< vtkWebGPUCellToPrimitiveConverter > CellConverter
void MapDataArrayToMultiTextureAttribute(const char *tname, const char *dataArrayName, int fieldAssociation, int componentno=-1) override
This method will Map the specified data array for use as a texture coordinate for texture tname.
virtual void ReplaceFragmentShaderLights(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
virtual std::vector< WGPUBindGroupLayoutEntry > GetMeshBindGroupLayoutEntries()
Allow subclasses to customize the entries in the bind group layout corresponding to GROUP_MESH.
void RecordDrawCommands(vtkRenderer *renderer, vtkActor *actor, const WGPURenderPassEncoder &passEncoder)
Record draw calls in the render pass encoder.
virtual unsigned long GetCellAttributeByteSize(vtkWebGPUPolyDataMapper::CellDataAttributes attribute)
Returns the size of the 'sub-buffer' within the whole cell data SSBO for the given attribute.
virtual void ReplaceShaderConstantsDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
virtual void ReplaceShaderClippingPlanesDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
virtual void UpdateMeshTopologyBuffers(vtkWebGPUConfiguration *wgpuConfiguration, vtkProperty *displayProperty)
Updates the connectivity related buffers.
virtual void UpdateMeshGeometryBuffers(vtkWebGPUConfiguration *wgpuConfiguration)
Creates buffers as needed and updates them with point/cell attributes, topology, draw parameters.
virtual void ReplaceShaderActorDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
void RenderPiece(vtkRenderer *renderer, vtkActor *act) override
Implemented by sub classes.
virtual void ReplaceVertexShaderTangents(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceVertexShaderInputDef(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceFragmentShaderPicking(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &fss)
GraphicsPipelineType
This mapper uses different WGPURenderPipeline to render a list of primitives.
virtual void ReplaceShaderCustomBindings(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
static bool IsPipelineForHomogeneousCellSize(GraphicsPipelineType pipelineType)
virtual void ReplaceVertexShaderUVs(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceVertexShaderCamera(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ReplaceVertexShaderCellId(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual void ApplyShaderReplacements(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
Generates vertex and fragment shader code.
bool HasPointAttributes[POINT_NB_ATTRIBUTES]
virtual bool ShouldReleaseGraphicsResourcesOnSync()
Return true if the mapper should release graphics resources from previous render during the vtkWebGPU...
virtual void ReplaceVertexShaderNormals(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
virtual WGPUPrimitiveTopology GetPrimitiveTopologyForPipeline(GraphicsPipelineType pipelineType)
Get the primitive topology type that should be used for the given pipeline.
CellDataAttributes
All the attributes supported by the cell data buffer.
void ComputeBounds() override
Called in GetBounds().
virtual void ReplaceVertexShaderVertexId(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
static bool UsesDeepFramebuffer(vtkWebGPURenderer *wgpuRenderer, vtkWebGPUActor *wgpuActor)
Whether this draw appends its fragments to the renderer's deep framebuffer rather than writing to the...
virtual void ReplaceShaderTopologyBindings(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss, std::string &fss)
static vtkOverrideAttribute * CreateOverrideAttributes()
virtual void ReplaceVertexShaderColors(GraphicsPipelineType pipelineType, vtkWebGPURenderer *renderer, vtkWebGPUActor *actor, std::string &vss)
WebGPU rendering window.
vtkWebGPUTexture is a concrete implementation of the abstract class vtkTexture for WebGPU.
window superclass for vtkRenderWindow
Definition vtkWindow.h:62
A graphics pipeline together with the topology bind groups it draws from.
std::vector< vtkWebGPUCellToPrimitiveConverter::TopologySourceType > BindGroupTypes
bool RecordUpload(vtkDataArray *array, vtkMTimeType buildTime)
Record array as the next upload, at the current watermark, and return whether it must be written.
std::vector< std::pair< vtkTypeUInt32, vtkTypeUInt32 > > VertexOffsetAndCounts
#define vtkDataArray
#define VTK_SURFACE
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:321
#define VTK_MARSHALAUTO
#define VTK_NEWINSTANCE