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.
| Argument | Type | Required | Description |
|---|---|---|---|
view | vtkWebGPUTextureView | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
renderEncoder | vtkWebGPURenderEncoder | Yes |
extend
Method used to decorate a given object (publicAPI+model) with vtkWebGPUSimpleMapper characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IWebGPUSimpleMapperInitialValues | No | (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.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IWebGPUSimpleMapperInitialValues | No | for pre-setting some of its content |
prepareAndDraw
Prepare, bind the pipeline and draw immediately.
| Argument | Type | Required | Description |
|---|---|---|---|
encoder | vtkWebGPURenderEncoder | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
renderEncoder | vtkWebGPURenderEncoder | Yes |
registerDrawCallback
Register this mapper's draw call on an encoder, to be invoked once the pipeline is bound.
| Argument | Type | Required | Description |
|---|---|---|---|
encoder | vtkWebGPURenderEncoder | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
replaceShaderMapper
Emit the declarations of the mapper bind group.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
replaceShaderPosition
Emit the clip space position of the vertex.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
replaceShaderRenderEncoder
Let the render encoder emit its own fragment output declarations.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
replaceShaderRenderer
Emit the declarations of the renderer bind group. Does nothing when the mapper has no WebGPU renderer.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
replaceShaderTCoord
Declare the texture coordinate passed from the vertex to the fragment stage.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes | the pipeline hash |
pipeline | vtkWebGPUPipeline | Yes | |
vertexInput | vtkWebGPUVertexInput | Yes |
setAdditionalBindables
Set the bindables added to the mapper bind group ahead of the buffers and texture views.
| Argument | Type | Required | Description |
|---|---|---|---|
additionalBindables | Array[IWebGPUBindable] | Yes |
setDevice
Set the device this mapper creates its resources on.
| Argument | Type | Required | Description |
|---|---|---|---|
device | vtkWebGPUDevice | Yes |
setFragmentShaderTemplate
Set the WGSL template the fragment shader is assembled from.
| Argument | Type | Required | Description |
|---|---|---|---|
fragmentShaderTemplate | String | Yes |
setInterpolate
Set whether the textures of this mapper are sampled with interpolation.
| Argument | Type | Required | Description |
|---|---|---|---|
interpolate | Boolean | Yes |
setNumberOfInstances
Set the number of instances drawn.
| Argument | Type | Required | Description |
|---|---|---|---|
numberOfInstances | Number | Yes |
setNumberOfVertices
Set the number of vertices drawn when there is no index buffer.
| Argument | Type | Required | Description |
|---|---|---|---|
numberOfVertices | Number | Yes |
setPipelineHash
Set the hash the pipeline of this mapper is cached under.
| Argument | Type | Required | Description |
|---|---|---|---|
pipelineHash | String | Yes |
setSSBO
Set the storage buffer bound by this mapper.
| Argument | Type | Required | Description |
|---|---|---|---|
SSBO | vtkWebGPUStorageBuffer | Yes |
setShaderReplacements
Set the shader replacement functions.
| Argument | Type | Required | Description |
|---|---|---|---|
shaderReplacements | Yes |
setTextureViews
Set the texture views bound by this mapper.
| Argument | Type | Required | Description |
|---|---|---|---|
textureViews | Array[vtkWebGPUTextureView] | Yes |
setTopology
Set the primitive topology this mapper draws.
| Argument | Type | Required | Description |
|---|---|---|---|
topology | GPUPrimitiveTopology | Yes |
setUBO
Set the uniform buffer bound by this mapper.
| Argument | Type | Required | Description |
|---|---|---|---|
UBO | vtkWebGPUUniformBuffer | Yes |
setVertexShaderTemplate
Set the WGSL template the vertex shader is assembled from.
| Argument | Type | Required | Description |
|---|---|---|---|
vertexShaderTemplate | String | Yes |
setWebGPURenderer
Set the scene graph renderer this mapper draws inside.
| Argument | Type | Required | Description |
|---|---|---|---|
WebGPURenderer | vtkWebGPURenderer | Yes |
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.