Class FrameGraphComputeShaderTask
Hierarchy (View Summary)
- FrameGraphTask
- FrameGraphComputeShaderTask
Constructors
constructor
-
new FrameGraphComputeShaderTask(
name: string,
frameGraph: FrameGraph,
shaderPath: any,
options?: IComputeShaderOptions,
): FrameGraphComputeShaderTaskCreates a new compute shader task.
Parameters
- name: string
The name of the task.
- frameGraph: FrameGraph
The frame graph the task belongs to.
- shaderPath: any
Defines the route to the shader code in one of three ways:
- object: { compute: "custom" }, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
- object: { computeElement: "HTMLElementId" }, used with shader code in script tags
- object: { computeSource: "compute shader code string" }, where the string contains the shader code
- string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
- options: IComputeShaderOptions = {}
Define the options used to create the shader
Returns FrameGraphComputeShaderTask
- name: string
Properties
Optionaldependencies
The (texture) dependencies of the task (optional).
dispatch Size
Defines the dispatch size for the compute shader
Optionalexecute
An optional execute function that will be called at the beginning of the task execution
Optionalindirect Dispatch
Defines an indirect dispatch buffer and offset. If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed. "offset" is the offset in the buffer where the workgroup counts are stored (default: 0)
on After Task Execute
An observable that is triggered after the task is executed.
on Before Task Execute
An observable that is triggered before the task is executed.
on Textures Allocated Observable
An observable that is triggered after the textures have been allocated.
Accessors
compute Shader
-
get computeShader(): ComputeShader
Gets the compute shader used by the task
Returns ComputeShader
disabled
-
get disabled(): boolean
Whether the task is disabled.
Returns boolean
-
set disabled(value: boolean): void
Parameters
- value: boolean
Returns void
name
-
get name(): string
The name of the task.
Returns string
-
set name(value: string): void
Parameters
- value: string
Returns void
passes
-
get passes(): IFrameGraphPass[]
Gets the passes of the task.
Returns IFrameGraphPass[]
passes Disabled
-
get passesDisabled(): IFrameGraphPass[]
Gets the disabled passes of the task.
Returns IFrameGraphPass[]
Methods
create Uniform Buffer
-
createUniformBuffer(
name: string,
description: { [name: string]: number },
autoUpdate?: boolean,
): UniformBufferCreates a uniform buffer and binds it to the shader
Parameters
- name: string
Name of the uniform buffer
- description: { [name: string]: number }
Description of the uniform buffer: names and sizes (in floats) of the uniforms
- autoUpdate: boolean = true
If the UBO must be updated automatically before each dispatch (default: true)
Returns UniformBuffer
The created uniform buffer
- name: string
dispose
-
Disposes of the task.
Returns void
get Class Name
-
Gets the current class name
Returns string
the class name
get Uniform Buffer
-
Gets a uniform buffer created by a call to createUniformBuffer()
Parameters
- name: string
Name of the uniform buffer
Returns UniformBuffer
The uniform buffer
- name: string
init Async
-
This function is called once after the task has been added to the frame graph and before the frame graph is built for the first time. This allows you to initialize asynchronous resources, which is not possible in the constructor.
Returns Promise<unknown>
A promise that resolves when the initialization is complete.
is Ready
-
Checks if the task is ready to be executed.
Returns boolean
True if the task is ready to be executed, else false.
record
-
Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.
Parameters
OptionalskipCreationOfDisabledPasses: booleanIf true, the disabled passe(s) won't be created.
Returns FrameGraphPass<FrameGraphContext>
set External Texture
-
Binds an external texture to the shader
Parameters
- name: string
Binding name of the texture
- texture: ExternalTexture
Texture to bind
Returns void
- name: string
set Internal Texture
-
Binds an internal texture to the shader
Parameters
- name: string
Binding name of the texture
- texture: InternalTexture
Texture to bind
Returns void
- name: string
set Storage Buffer
-
Binds a storage buffer to the shader
Parameters
- name: string
Binding name of the buffer
- buffer: any
Buffer to bind
Returns void
- name: string
set Storage Texture
-
Binds a storage texture to the shader
Parameters
- name: string
Binding name of the texture
- texture: BaseTexture
Texture to bind
Returns void
- name: string
set Texture
-
Binds a texture to the shader
Parameters
- name: string
Binding name of the texture
- texture: BaseTexture
Texture to bind
- bindSampler: boolean = true
Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
Returns void
- name: string
set Texture Sampler
-
Binds a texture sampler to the shader
Parameters
- name: string
Binding name of the sampler
- sampler: TextureSampler
Sampler to bind
Returns void
- name: string
set Uniform Buffer
-
Binds a uniform buffer to the shader
Parameters
- name: string
Binding name of the buffer
- buffer: any
Buffer to bind
Returns void
- name: string
set Video Texture
-
Binds a video texture to the shader (by binding the external texture attached to this video)
Parameters
- name: string
Binding name of the texture
- texture: VideoTexture
Texture to bind
Returns any
true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
- name: string
Task used to execute a compute shader (WebGPU only)