ComputeMaterial constructor
Renderer class object or GPUCurtains class object used to create this ComputeMaterial.
parameters used to create our ComputeMaterial.
Compute pipeline entry used by this ComputeMaterial.
Options used to create this ComputeMaterial.
Optional
dispatchDefault work group dispatch size to use with this ComputeMaterial.
function assigned to the useCustomRender callback.
The type of the Material.
Readonly
uuidThe universal unique id of the Material.
The Renderer used.
Array of bind groups used by this Material. This array respects a specific order:
Array of texture bind groups used by this Material.
Array of bind groups created using the uniforms and storages parameters when instancing this Material.
Array of cloned bind groups created by this Material.
Object containing all uniforms inputs handled by this Material.
Object containing all read only or read/write storages inputs handled by this Material.
Array of Texture or MediaTexture handled by this Material.
Get whether the renderer is ready, our pipeline entry and pipeline have been created and successfully compiled.
Get the main texture bind group created by this Material to manage all textures related struct.
Set (or reset) the current pipelineEntry. Use the renderer pipelineManager to check whether we can get an already created ComputePipelineEntry from cache or if we should create a new one.
Compile the ComputePipelineEntry.
Check if all bind groups are ready, create them if needed, set ComputePipelineEntry bind group buffers and compile the pipeline.
Get the complete code of a given shader including all the WGSL fragment code snippets added by the pipeline. Can wait for the pipelineEntry to be compiled if that's not already the case.
Optional
shaderType: FullShadersType = 'compute'Shader to get the code from.
Get the added code of a given shader, i.e. all the WGSL fragment code snippets added by the pipeline. Can wait for the pipelineEntry to be compiled if that's not already the case.
Optional
shaderType: FullShadersType = 'compute'Shader to get the code from
If a custom render function has been defined instead of the default one, register the callback
callback to run instead of the default render behaviour, which is to set the bind groups and dispatch the work groups based on the default dispatch size. This is where you will have to set all the bind groups and dispatch the workgroups by yourself.
Render the material if it is ready: Set the current pipeline, set the bind groups and dispatch the work groups.
Current compute pass encoder.
Copy all writable binding buffers that need it.
Current command encoder.
Get the result GPU buffer content by binding and buffer element names.
Parameters used to get the result.
Optional
bindingName?: stringbinding name from which to get the result.
Optional
bufferElementName?: stringPptional buffer element (i.e. struct member) name if the result needs to be restrained to only one element.
Set or reset this Material renderer. Also reset the bindGroups renderer.
New Renderer or GPUCurtains instance to use.
Called when the device has been restored to recreate our samplers, textures and bind groups.
Clones a BindGroup from a list of buffers. Useful to create a newBindGroup with already created buffers, but swapped.
parameters used to clone the BindGroup.
Optional
bindGroup?: AllowedBindGroupsthe BindGroup to clone.
Optional
bindings?: BindGroupBindingElement[]our input binding buffers.
Optional
keepLayout?: booleanwhether we should keep original bind group layout or not.
Get a corresponding BindGroup or TextureBindGroup from one of its binding name/key
the binding name/key to look for.
Destroy a BindGroup, only if it is not used by another object.
BindGroup to eventually destroy.
Destroy all BindGroup.
Update all BindGroup.
Look for a binding by name in all input bindings
the binding name or key.
Look for a buffer binding by name in all input bindings.
The binding name or key.
Force setting a given buffer binding shouldUpdate flag to true
to update it at next render.
Optional
bufferBindingName: stringThe buffer binding name.
Optional
bindingName: stringThe binding name.
Prepare our textures array and set the TextureBindGroup.
Add a MediaTexture or Texture to our textures array, and add it to the textures bind group only if used in the shaders (avoid binding useless data).
MediaTexture or Texture to add.
Destroy a MediaTexture or Texture, only if it is not used by another object or cached.
MediaTexture or Texture to eventually destroy.
Destroy all the Material textures.
Map a Buffer's GPU buffer and put a copy of the data into a Float32Array
Map the content of a BufferBinding GPU buffer and put a copy of the data into a Float32Array.
The name of the input bindings from which to map the GPU buffer.
Map the content of a specific buffer element belonging to a BufferBinding GPU buffer and put a copy of the data into a Float32Array.
Parameters used to get the result.
The name of the input bindings from which to map the GPU buffer.
The name of the buffer element from which to extract the data afterwards.
Called before rendering the Material. First, check if we need to create our bind groups or pipeline. Finally, updates all the bind groups.
Set the current pipeline.
Current pass encoder.
Use the renderer pipelineManager to only set the bind groups that are not already set.
Current pass encoder.
Create a Material specifically built to run computations on the GPU. Internally used by ComputePass.
Compute pipeline
A ComputeMaterial automatically creates a ComputePipelineEntry. Once all the BindGroup have been created, they are sent with the compute shader code to the ComputePipelineEntry, which is in turns responsible for creating the GPUComputePipeline.
After the GPUComputePipeline has been successfully compiled, the ComputeMaterial is considered to be ready and it can start running the compute shader computations.