3#ifndef vtkWebGPUPolyDataMapper_h
4#define vtkWebGPUPolyDataMapper_h
9#include "vtkRenderingWebGPUModule.h"
15#include <unordered_set>
17VTK_ABI_NAMESPACE_BEGIN
108 int fieldAssociation,
int componentno = -1)
override;
118 int fieldAssociation,
int componentno = -1)
override;
154 int uniformsBinding);
161 int uniformsBinding);
210 const wgpu::Device& device,
const std::string& label);
216 const wgpu::Device& device,
const std::string& label);
222 wgpu::RenderPipelineDescriptor* pipelineDescriptor,
const wgpu::ShaderModule& shaderModule,
223 wgpu::PrimitiveTopology primitiveTopology);
241 const wgpu::Device& device,
const std::string& label);
443 wgpu::Buffer GetPointDataWGPUBuffer() {
return this->MeshSSBO.
Point.
Buffer; }
448 wgpu::Buffer GetCellDataWGPUBuffer() {
return this->MeshSSBO.
Cell.
Buffer; }
456 std::vector<vtkSmartPointer<vtkWebGPUComputeRenderBuffer>> SetupComputeRenderBuffers;
461 std::unordered_set<vtkSmartPointer<vtkWebGPUComputeRenderBuffer>> NotSetupComputeRenderBuffers;
466 const PointDataAttributes PointDataAttributesOrder[PointDataAttributes::POINT_NB_ATTRIBUTES] = {
467 PointDataAttributes::POINT_POSITIONS, PointDataAttributes::POINT_COLORS,
468 PointDataAttributes::POINT_NORMALS, PointDataAttributes::POINT_TANGENTS,
469 PointDataAttributes::POINT_UVS
475 const CellDataAttributes CellDataAttributesOrder[CellDataAttributes::CELL_NB_ATTRIBUTES] = {
476 CellDataAttributes::CELL_COLORS, CellDataAttributes::CELL_NORMALS
479 std::map<std::pair<vtkActor*, vtkRenderer*>, ActorState> CachedActorRendererProperties;
481 vtkWebGPUPolyDataMapper(
const vtkWebGPUPolyDataMapper&) =
delete;
482 void operator=(
const vtkWebGPUPolyDataMapper&) =
delete;
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.
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
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.
vtkTimeStamp PointAttributesBuildTimestamp[POINT_NB_ATTRIBUTES]
Timestamps help reuse previous resources as much as possible.
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.
wgpu::BindGroup MeshAttributeBindGroup
bool RebuildGraphicsPipelines
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.
bool HasCellAttributes[CELL_NB_ATTRIBUTES]
friend class vtkWebGPURenderer
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.
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...
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...
TopologyBindGroupInfo TopologyBindGroupInfos[vtkWebGPUCellToPrimitiveConverter::NUM_TOPOLOGY_SOURCE_TYPES]
vtkPolyData * CurrentInput
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()
std::string GraphicsPipelineKeys[GFX_PIPELINE_NB_TYPES]
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.
bool LastScalarVisibility
vtkTimeStamp IndirectDrawBufferUploadTimeStamp[vtkWebGPUCellToPrimitiveConverter::NUM_TOPOLOGY_SOURCE_TYPES]
Timestamps help reuse previous resources as much as possible.
void RenderPiece(vtkRenderer *renderer, vtkActor *act) override
Implemented by sub classes.
vtkPolyData * CachedInput
friend class vtkWebGPUComputeRenderBuffer
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.
bool HasPointAttributes[POINT_NB_ATTRIBUTES]
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().
window superclass for vtkRenderWindow
bool LastHasRenderingTranslucentGeometry
bool LastActorFrontfaceCulling
bool LastVertexVisibility
bool LastActorBackfaceCulling
vtkTypeUInt32 NumComponents
struct vtkWebGPUPolyDataMapper::MeshAttributeBuffers::@320066264313321177165367213064212262215077312156 Cell
struct vtkWebGPUPolyDataMapper::MeshAttributeBuffers::@322277060310063306147312044355276063234262207064 Point
vtkTypeFloat32 Ambient[3]
AttributeDescriptor Positions
AttributeDescriptor CellColors
AttributeDescriptor CellNormals
vtkTypeUInt32 CompositeId
AttributeDescriptor Normals
AttributeDescriptor Colors
AttributeDescriptor Tangents
vtkTypeFloat32 Diffuse[3]
vtkTypeUInt32 ApplyOverrideColors
wgpu::BindGroup BindGroup
vtkTypeUInt32 VertexCount
wgpu::Buffer TopologyBuffer
wgpu::Buffer EdgeArrayBuffer