3#ifndef vtkWebGPUPolyDataMapper_h
4#define vtkWebGPUPolyDataMapper_h
9#include "vtkRenderingWebGPUModule.h"
15#include <unordered_set>
17VTK_ABI_NAMESPACE_BEGIN
64 GFX_PIPELINE_POINTS = 0,
108 int fieldAssociation,
int componentno = -1)
override;
118 int fieldAssociation,
int componentno = -1)
override;
154 int uniformsBinding);
161 int uniformsBinding);
217 const wgpu::Device& device,
const std::string& label);
223 const wgpu::Device& device,
const std::string& label);
229 wgpu::RenderPipelineDescriptor* pipelineDescriptor,
const wgpu::ShaderModule& shaderModule,
230 wgpu::PrimitiveTopology primitiveTopology);
248 const wgpu::Device& device,
const std::string& label);
364 vtkTypeUInt32 Start = 0;
365 vtkTypeUInt32 NumTuples = 0;
366 vtkTypeUInt32 NumComponents = 0;
370 vtkTypeUInt32 ApplyOverrideColors = 0;
371 vtkTypeFloat32 Opacity = 0;
372 vtkTypeUInt8 Padding1[8];
373 vtkTypeFloat32 Ambient[4] = {};
374 vtkTypeFloat32 Diffuse[4] = {};
385 vtkTypeUInt8 Padding[12];
397 bool HasPointAttributes[POINT_NB_ATTRIBUTES];
398 bool HasCellAttributes[CELL_NB_ATTRIBUTES];
399 bool RebuildGraphicsPipelines =
true;
425 vtkTypeUInt32 VertexCount = 0;
431 std::string GraphicsPipelineKeys[GFX_PIPELINE_NB_TYPES] = {};
435 int LastScalarMode = -1;
436 bool LastScalarVisibility =
false;
439 bool LastActorBackfaceCulling =
false;
440 bool LastActorFrontfaceCulling =
false;
441 bool LastVertexVisibility =
false;
443 bool LastHasRenderingTranslucentGeometry =
false;
455 wgpu::Buffer GetPointDataWGPUBuffer() {
return this->MeshSSBO.
Point.
Buffer; }
460 wgpu::Buffer GetCellDataWGPUBuffer() {
return this->MeshSSBO.
Cell.
Buffer; }
468 std::vector<vtkSmartPointer<vtkWebGPUComputeRenderBuffer>> SetupComputeRenderBuffers;
473 std::unordered_set<vtkSmartPointer<vtkWebGPUComputeRenderBuffer>> NotSetupComputeRenderBuffers;
478 const PointDataAttributes PointDataAttributesOrder[PointDataAttributes::POINT_NB_ATTRIBUTES] = {
479 PointDataAttributes::POINT_POSITIONS, PointDataAttributes::POINT_COLORS,
480 PointDataAttributes::POINT_NORMALS, PointDataAttributes::POINT_TANGENTS,
481 PointDataAttributes::POINT_UVS
487 const CellDataAttributes CellDataAttributesOrder[CellDataAttributes::CELL_NB_ATTRIBUTES] = {
488 CellDataAttributes::CELL_COLORS, CellDataAttributes::CELL_NORMALS
represents an object (geometry & properties) in a rendered scene
object to represent cell connectivity
a simple class to control print indentation
Allocate and hold a VTK object.
map vtkPolyData to graphics primitives
std::uintptr_t MapperHashType
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract superclass for all actors, volumes and annotations
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.
@ NUM_TOPOLOGY_SOURCE_TYPES
Render buffers are returned by calls to vtkWebGPUPolyDataMapper::AcquirePointAttributeComputeRenderBu...
Create a webgpu device for use in rendering and compute pipelines.
PointDataAttributes
All the attributes supported by the point data buffer.
unsigned long GetPointAttributeByteSize(vtkWebGPUPolyDataMapper::PointDataAttributes attribute)
Returns the size of the 'sub-buffer' within the whole point data SSBO for the given attribute.
static wgpu::BindGroupLayout CreateMeshAttributeBindGroupLayout(const wgpu::Device &device, const std::string &label)
Create a bind group layout for the mesh attribute bind group.
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 ...
bool GetSupportsSelection() override
static wgpu::RenderPipeline CreateRenderPipeline(const wgpu::Device &device, wgpu::RenderPipelineDescriptor *pipelineDescriptor, const wgpu::ShaderModule &shaderModule, wgpu::PrimitiveTopology primitiveTopology)
Create a render pipeline.
bool GetNeedToRemapScalars(vtkPolyData *mesh)
Determines whether this mapper should re-map scalars on the mesh to colors.
wgpu::BindGroup MeshAttributeBindGroup
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
vtkIdType GetPointAttributeByteOffset(PointDataAttributes attribute)
Returns the offset at which the 'sub-buffer' of 'attribute' starts within the mesh SSBO point data bu...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
unsigned long GetCellAttributeElementSize(vtkWebGPUPolyDataMapper::CellDataAttributes attribute)
Returns the size in bytes of one element of the given attribute.
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.
void RemoveAllVertexAttributeMappings() override
Remove all vertex attributes.
void DeducePointCellAttributeAvailability(vtkPolyData *mesh)
Looks at the point/cell data of vtkPolyData object and determines which attributes are available.
vtkPolyDataMapper::MapperHashType GenerateHash(vtkPolyData *polydata) override
This hash integer is computed by concrete graphics implementation of this class.
MeshAttributeBuffers MeshSSBO
void ResetPointCellAttributeState()
Reset the internal Has{Point,Cell}Attribute booleans to false.
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...
vtkSmartPointer< vtkWebGPUComputeRenderBuffer > AcquireCellAttributeComputeRenderBuffer(CellDataAttributes attribute, int bufferGroup, int bufferBinding, int uniformsGroup, int uniformsBinding)
Same as AcquirePointAttributeComputeRenderBuffer but for cell data attributes.
unsigned long GetExactPointBufferSize()
Calculates the size of a buffer that is large enough to contain all the values from the point attribu...
vtkIdType GetCellAttributeByteOffset(CellDataAttributes attribute)
Returns the offset at which the 'sub-buffer' of 'attribute' starts within the mesh SSBO cell data buf...
wgpu::BindGroup CreateTopologyBindGroup(const wgpu::Device &device, const std::string &label, vtkWebGPUCellToPrimitiveConverter::TopologySourceType topologySourceType)
Create a bind group for the primitives of a mesh.
void SetupGraphicsPipelines(const wgpu::Device &device, vtkRenderer *renderer, vtkActor *actor)
Creates the graphics pipeline.
vtkWebGPUPolyDataMapper()
void RecordDrawCommands(vtkRenderer *renderer, vtkActor *actor, const wgpu::RenderPassEncoder &passEncoder)
Record draw calls in the render pass encoder.
void RemoveVertexAttributeMapping(const char *vertexAttributeName) override
Remove a vertex attribute mapping.
static vtkWebGPUPolyDataMapper * New()
~vtkWebGPUPolyDataMapper() override
static wgpu::BindGroupLayout CreateTopologyBindGroupLayout(const wgpu::Device &device, const std::string &label)
Create a bind group layout for the TopologyRenderInfo::BindGroup
void RecordDrawCommands(vtkRenderer *renderer, vtkActor *actor, const wgpu::RenderBundleEncoder &bundleEncoder)
const char * GetGraphicsPipelineTypeAsString(GraphicsPipelineType graphicsPipelineType)
Get the name of the graphics pipeline type as a string.
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.
unsigned long GetCellAttributeByteSize(vtkWebGPUPolyDataMapper::CellDataAttributes attribute)
Returns the size of the 'sub-buffer' within the whole cell data SSBO for the given attribute.
void RenderPiece(vtkRenderer *renderer, vtkActor *act) override
Implemented by sub classes.
GraphicsPipelineType
This mapper uses different wgpu::RenderPipeline to render a list of primitives.
@ GFX_PIPELINE_LINES_ROUND_CAP_ROUND_JOIN
@ GFX_PIPELINE_LINES_MITER_JOIN
void UpdateMeshGeometryBuffers(vtkWebGPURenderWindow *wgpuRenderWindow)
Creates buffers as needed and updates them with point/cell attributes, topology, draw parameters.
bool GetNeedToRebuildGraphicsPipelines(vtkActor *actor, vtkRenderer *renderer)
Get whether the graphics pipeline needs rebuilt.
unsigned long GetExactCellBufferSize()
Calculates the size of a buffer that is large enough to contain all the values from the cell attribut...
wgpu::Buffer AttributeDescriptorBuffer
unsigned long GetPointAttributeElementSize(vtkWebGPUPolyDataMapper::PointDataAttributes attribute)
Returns the size in bytes of one element of the given attribute.
wgpu::BindGroup CreateMeshAttributeBindGroup(const wgpu::Device &device, const std::string &label)
Create a bind group for the point and cell attributes of a mesh.
bool CacheActorRendererProperties(vtkActor *actor, vtkRenderer *renderer)
This method keeps track of few properties of the actor which when changed, require rebuilding a rende...
CellDataAttributes
All the attributes supported by the cell data buffer.
void ComputeBounds() override
Called in GetBounds().
std::map< std::pair< vtkWeakPointer< vtkActor >, vtkWeakPointer< vtkRenderer > >, ActorState > CachedActorRendererProperties
window superclass for vtkRenderWindow
struct vtkWebGPUPolyDataMapper::MeshAttributeBuffers::@201 Cell
struct vtkWebGPUPolyDataMapper::MeshAttributeBuffers::@200 Point
AttributeDescriptor Positions
AttributeDescriptor CellColors
AttributeDescriptor CellNormals
AttributeDescriptor Normals
AttributeDescriptor Colors
OverrideColorDescriptor OverrideColors
AttributeDescriptor Tangents
wgpu::BindGroup BindGroup
wgpu::Buffer TopologyBuffer
wgpu::Buffer EdgeArrayBuffer