API

Class FrameGraphComputeShaderTask

Task used to execute a compute shader (WebGPU only)

Hierarchy (View Summary)

Index
  • Creates 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

dependencies?: Set<FrameGraphTextureHandle>

The (texture) dependencies of the task (optional).

dispatchSize: any = ...

Defines the dispatch size for the compute shader

execute?: (context: FrameGraphContext) => void

An optional execute function that will be called at the beginning of the task execution

indirectDispatch?: { buffer: any; offset?: number }

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)

onAfterTaskExecute: Observable<FrameGraphTask> = ...

An observable that is triggered after the task is executed.

onBeforeTaskExecute: Observable<FrameGraphTask> = ...

An observable that is triggered before the task is executed.

onTexturesAllocatedObservable: Observable<FrameGraphRenderContext> = ...

An observable that is triggered after the textures have been allocated.

  • Creates 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

  • 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.

  • Records the task in the frame graph. Use this function to add content (render passes, ...) to the task.

    Parameters

    • OptionalskipCreationOfDisabledPasses: boolean

      If true, the disabled passe(s) won't be created.

    Returns FrameGraphPass<FrameGraphContext>

  • 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

  • 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