GPURenderer constructor
parameters used to create this GPURenderer.
The type of the GPURenderer.
Readonly
uuidThe universal unique id of this GPURenderer.
The GPUDeviceManager used to create this GPURenderer.
HTMLCanvasElement onto everything is drawn.
The WebGPU context used.
Options used to create this GPURenderer.
The render pass used to render our result to screen.
Additional render pass used by ShaderPass for compositing / post processing. Does not handle depth.
The Scene used.
Whether we should render our GPURenderer or not. If set to false
, the render hooks onBeforeCommandEncoderCreation, onBeforeRenderScene, onAfterRenderScene and onAfterCommandEncoderSubmission won't be called, the scene graph will not be updated and the scene will not be rendered, completely pausing the renderer. Default to true
.
Whether we should explicitly update our Scene or not. If set to false
, the scene graph will not be updated and the scene will not be rendered. Default to true
.
An array containing all our created ComputePass.
An array containing all our created PingPongPlane.
An array containing all our created ShaderPass.
A Map containing all the RenderPass handled by this renderer.
An array containing all our created RenderTarget.
An array containing all our created meshes.
An array containing all our created Texture.
A Map containing all the EnvironmentMap handled by this renderer.
A Map containing all the RenderBundle handled by this renderer.
A Map containing all the TargetsAnimationsManager handled by this renderer.
Pixel ratio to use for rendering.
An object defining the width, height, top and left position of the canvas. Mainly used internally. If you need to get the renderer dimensions, use boundingRect instead.
Current RenderPassViewport to use to set the renderPass and postProcessingPass RenderPass viewport if any.
Current scissor RectBBox to use to set the renderPass and postProcessingPass RenderPass scissorRect if any.
DOMElement that will track our canvas container size.
Allow to add callbacks to be executed at each render before the GPUCommandEncoder is created.
Allow to add callbacks to be executed at each render after the GPUCommandEncoder has been created but before the Scene is rendered.
Allow to add callbacks to be executed at each render after the GPUCommandEncoder has been created and after the Scene has been rendered.
Allow to add callbacks to be executed at each render after the Scene has been rendered and the GPUCommandEncoder has been submitted.
function assigned to the onResize callback.
function assigned to the onAfterResize callback.
Get our DOM Element bounding rectangle. If there's no DOM Element (like when using an offscreen canvas for example), the rectBBox values are used.
Get whether our GPUDeviceManager is ready (i.e. its adapter and device are set) its context is set and its size is set.
Get our GPUDeviceManager production flag.
Get all the created GPU buffers.
Get all the created indirect buffers.
Get the pipeline manager.
Get all the rendered objects (i.e. compute passes, meshes, ping pong planes and shader passes) created by the GPUDeviceManager.
Get all created bind group tracked by our GPUDeviceManager.
Get all this GPURenderer rendered objects (i.e. compute passes, meshes, ping pong planes and shader passes).
function assigned to the onBeforeRender callback.
function assigned to the onAfterRender callback.
Set the renderer, renderPass and postProcessingPass viewport values. Beware that if you use a viewport, you should resize it yourself so it does not overflow the canvas
in the onResize
callback to avoid issues.
RenderPassViewport settings to use. Can be set to null
to cancel the viewport.
Set the renderer, renderPass and postProcessingPass scissorRect values. Beware that if you use a scissorRect, you should resize it yourself so it does not overflow the canvas
in the onResize
callback to avoid issues.
RectBBox settings to use. Can be set to null
to cancel the scissorRect.
Set the renderer pixel ratio and resize it.
New pixel ratio to use.
Resize our GPURenderer.
Resize all tracked objects (textures, render passes, render targets, compute passes and meshes).
Resize the meshes.
Clamp to max WebGPU texture dimensions.
Width and height dimensions to clamp.
Configure our context with the given options.
Set our context if possible and initialize the renderPass and postProcessingPass.
Called when the device is lost. Force all our scene objects to lose context.
Called when the device should be restored. Configure the context again, resize the render targets and textures, restore our rendered objects context.
Set our main render pass that will be used to render the result of our draw commands back to the screen and our postprocessing pass that will be used for any additional postprocessing render passes.
Set our scene.
Remove a Buffer from our buffers Map.
Copy a source Buffer GPUBuffer into a destination Buffer GPUBuffer.
Parameters used to realize the copy.
Source Buffer.
Optional
dstBuffer?: BufferDestination Buffer. Will create a new one if none provided.
Optional
commandEncoder?: GPUCommandEncoderGPUCommandEncoder to use for the copy. Will create a new one and submit the command buffer if none provided.
Add a bind group to our bind groups array.
Bind group to add.
Remove a bind group from our bind groups array.
Bind group to remove.
Create a GPUBindGroupLayout.
Create a GPUBindGroup.
Create a GPUShaderModule.
Create a GPUPipelineLayout.
Create a GPURenderPipeline.
Asynchronously create a GPURenderPipeline.
Create a GPUComputePipeline.
Asynchronously create a GPUComputePipeline.
Create a GPUTexture.
MediaTexture or DOMTexture containing the GPUTexture to upload.
Index of the source to upload (for cube maps). Default to 0
.
Generate mips on the GPU using our GPUDeviceManager.
Texture, MediaTexture or DOMTexture for which to generate the mips.
optional GPUCommandEncoder to use if we're already in the middle of a command encoding process.
Import a GPUExternalTexture.
HTMLVideoElement or VideoFrame source.
Optional label of the texture.
Copy a GPUTexture to a Texture using a GPUCommandEncoder. Automatically generate mips after copy if the Texture needs it.
GPUTexture source to copy from.
Texture destination to copy onto.
GPUCommandEncoder to use for copy operation.
Copy a Texture to a Texture using a GPUCommandEncoder. Automatically generate mips after copy if the destination Texture needs it.
Texture source to copy from.
Texture destination to copy onto.
GPUCommandEncoder to use for copy operation.
Copy a Texture to a GPUTexture using a GPUCommandEncoder.
Texture source to copy from.
GPUTexture destination to copy onto.
GPUCommandEncoder to use for copy operation.
Check if a Sampler has already been created with the same parameters. Use it if found, else create a new one and add it to the samplers array.
Remove a Sampler from our samplers array.
Set different tasks queue managers to execute callbacks at different phases of our render call:
Set all objects arrays and Map that we'll keep track of.
Get all objects (rendered meshes or compute passes) using a given bind group. Useful (but slow) to know if a resource is used by multiple objects and if it is safe to destroy it or not.
Bind group to check.
Get all objects (rendered meshes or compute passes) using a given DOMTexture, MediaTexture or Texture. Useful to know if a resource is used by multiple objects and if it is safe to destroy it or not.
DOMTexture, MediaTexture or Texture to check.
Assign a callback function to _onBeforeRenderCallback.
callback to run just before the render method will be executed.
Assign a callback function to _onAfterRenderCallback.
callback to run just after the render method has been executed.
Callback to run after the GPURenderer has been resized but before the resizeObjects method has been executed (before the textures, render passes, render targets, compute passes and meshes are resized).
callback to execute.
Callback to run after the GPURenderer has been resized and after the resizeObjects method has been executed (after the textures, render passes, render targets, compute passes and meshes have been resized).
callback to execute.
Render a single ComputePass.
current GPUCommandEncoder to use.
ComputePass to run.
Whether to copy all writable binding buffers that need it.
Render a single Mesh.
current GPUCommandEncoder.
Mesh to render.
Render an array of objects (either Meshes or ComputePass) once. This method won't call any of the renderer render hooks like onBeforeRender, onAfterRender.
Array of Meshes or ComputePass to render.
Force to clear a GPURenderer content to its .clearValue | clear value by rendering and empty pass.
Optional
commandEncoder: GPUCommandEncoderGPUCommandEncoder to use if any.
RenderPass to clear. Default to renderPass.
Called by the GPUDeviceManager render method before the GPUCommandEncoder has been created. Used to update the Scene matrix stack.
Called by the GPUDeviceManager render method after the GPUCommandEncoder has been created.
Called at each draw call to render our scene and its content.
current GPUCommandEncoder.
Destroy our GPURenderer and everything that needs to be destroyed as well.
Base renderer class, that could technically be used to render compute passes and draw fullscreen quads, even tho it is strongly advised to use at least the GPUCameraRenderer class instead. A renderer is responsible for: