Skip to content

SimpleMapper ​

Introduction ​

The base of the WebGPU mappers: owns a vertex input, a bind group, a pipeline and the shader templates and replacement functions the shader code is assembled from.

Methods ​

addTextureView ​

Add a texture view to the ones bound by this mapper, unless it is already there.

ArgumentTypeRequiredDescription
viewvtkWebGPUTextureViewYes

computePipelineHash ​

Compute the hash the pipeline of this mapper is cached under.

draw ​

Record the draw commands of this mapper. The command encoder and the pipeline must already be bound.

ArgumentTypeRequiredDescription
renderEncodervtkWebGPURenderEncoderYes

extend ​

Method used to decorate a given object (publicAPI+model) with vtkWebGPUSimpleMapper characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIWebGPUSimpleMapperInitialValuesNo(default: {})

generateShaderDescriptions ​

Create the vertex and fragment shader descriptions of a pipeline from the shader templates, then invoke every registered shader replacement whose //VTK::Section:: tag appears in them. The IOStructs replacement is always invoked last, as the other replacements can add shader inputs and outputs.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

getAdditionalBindables ​

Get the bindables added to the mapper bind group ahead of the buffers and texture views.

getBindables ​

Get the objects bound by the mapper bind group: the additional bindables, the uniform and storage buffers, and the texture views with their samplers.

getDevice ​

Get the device this mapper creates its resources on.

getFragmentShaderTemplate ​

Get the WGSL template the fragment shader is assembled from.

getInterpolate ​

Get whether the textures of this mapper are sampled with interpolation.

getNumberOfInstances ​

Get the number of instances drawn.

getNumberOfVertices ​

Get the number of vertices drawn when there is no index buffer.

getPipeline ​

Get the render pipeline this mapper draws with.

getPipelineHash ​

Get the hash the pipeline of this mapper is cached under.

getPipelineSettings ​

Get the pipeline settings merged on top of the render encoder settings.

getSSBO ​

Get the storage buffer bound by this mapper.

getShaderReplacements ​

Get the shader replacement functions, keyed by the name of the //VTK::Section:: tag they fill in.

getTextureViews ​

Get the texture views bound by this mapper.

getTopology ​

Get the primitive topology this mapper draws.

getUBO ​

Get the uniform buffer bound by this mapper.

getVertexInput ​

Get the vertex input of this mapper.

getVertexShaderTemplate ​

Get the WGSL template the vertex shader is assembled from.

getWebGPURenderer ​

Get the scene graph renderer this mapper draws inside.

newInstance ​

Method used to create a new instance of vtkWebGPUSimpleMapper.

ArgumentTypeRequiredDescription
initialValuesIWebGPUSimpleMapperInitialValuesNofor pre-setting some of its content

prepareAndDraw ​

Prepare, bind the pipeline and draw immediately.

ArgumentTypeRequiredDescription
encodervtkWebGPURenderEncoderYes

prepareToDraw ​

Do everything needed for this mapper to be ready to draw: update the input, the buffers, the bindings and the pipeline. Does not bind anything nor record any draw command, as the pipeline may not be bound yet.

ArgumentTypeRequiredDescription
renderEncodervtkWebGPURenderEncoderYes

registerDrawCallback ​

Register this mapper's draw call on an encoder, to be invoked once the pipeline is bound.

ArgumentTypeRequiredDescription
encodervtkWebGPURenderEncoderYes

releaseGraphicsResources ​

Release the GPU resources of the vertex input, the bind group and the buffers, and drop the pipeline, the render encoder and the texture views.

replaceShaderIOStructs ​

Build the input and output structs of both shader stages.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

replaceShaderMapper ​

Emit the declarations of the mapper bind group.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

replaceShaderPosition ​

Emit the clip space position of the vertex.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

replaceShaderRenderEncoder ​

Let the render encoder emit its own fragment output declarations.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

replaceShaderRenderer ​

Emit the declarations of the renderer bind group. Does nothing when the mapper has no WebGPU renderer.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

replaceShaderTCoord ​

Declare the texture coordinate passed from the vertex to the fragment stage.

ArgumentTypeRequiredDescription
hashStringYesthe pipeline hash
pipelinevtkWebGPUPipelineYes
vertexInputvtkWebGPUVertexInputYes

setAdditionalBindables ​

Set the bindables added to the mapper bind group ahead of the buffers and texture views.

ArgumentTypeRequiredDescription
additionalBindablesArray[IWebGPUBindable]Yes

setDevice ​

Set the device this mapper creates its resources on.

ArgumentTypeRequiredDescription
devicevtkWebGPUDeviceYes

setFragmentShaderTemplate ​

Set the WGSL template the fragment shader is assembled from.

ArgumentTypeRequiredDescription
fragmentShaderTemplateStringYes

setInterpolate ​

Set whether the textures of this mapper are sampled with interpolation.

ArgumentTypeRequiredDescription
interpolateBooleanYes

setNumberOfInstances ​

Set the number of instances drawn.

ArgumentTypeRequiredDescription
numberOfInstancesNumberYes

setNumberOfVertices ​

Set the number of vertices drawn when there is no index buffer.

ArgumentTypeRequiredDescription
numberOfVerticesNumberYes

setPipelineHash ​

Set the hash the pipeline of this mapper is cached under.

ArgumentTypeRequiredDescription
pipelineHashStringYes

setSSBO ​

Set the storage buffer bound by this mapper.

ArgumentTypeRequiredDescription
SSBOvtkWebGPUStorageBufferYes

setShaderReplacements ​

Set the shader replacement functions.

ArgumentTypeRequiredDescription
shaderReplacementsYes

setTextureViews ​

Set the texture views bound by this mapper.

ArgumentTypeRequiredDescription
textureViewsArray[vtkWebGPUTextureView]Yes

setTopology ​

Set the primitive topology this mapper draws.

ArgumentTypeRequiredDescription
topologyGPUPrimitiveTopologyYes

setUBO ​

Set the uniform buffer bound by this mapper.

ArgumentTypeRequiredDescription
UBOvtkWebGPUUniformBufferYes

setVertexShaderTemplate ​

Set the WGSL template the vertex shader is assembled from.

ArgumentTypeRequiredDescription
vertexShaderTemplateStringYes

setWebGPURenderer ​

Set the scene graph renderer this mapper draws inside.

ArgumentTypeRequiredDescription
WebGPURenderervtkWebGPURendererYes

updateBindings ​

Set the bindables of the mapper bind group. Done on every draw, as bindings can change without the pipeline hash changing.

updateBuffers ​

Create and update the buffers this mapper draws from.

updateInput ​

Bring the input data of this mapper up to date.

updatePipeline ​

Fetch the pipeline of the current hash from the device, building it when the device has none.