Dispatch QML Type

Dispatches a compute shader. More...

Import Statement: import QtQuick3D
Since: Qt 6.13
Inherits:

Command

Properties

Detailed Description

A Dispatch command specifies how many work groups a ComputePass dispatches its compute shader with, along the X, Y, and Z dimensions. A ComputePass without a Dispatch command in its commands list does not execute its shader.

The total number of shader invocations is the group count multiplied by the shader's local work group size (declared with layout(local_size_x = ..., local_size_y = ..., local_size_z = ...) in; in the shader itself). For example, to run one invocation per texel of a ShaderImage when the shader declares a local size of 8x8x1:

 Dispatch {
     groupCountX: (myImage.width + 7) / 8
     groupCountY: (myImage.height + 7) / 8
 }

The group count dimensions are clamped to the maximum supported amount: QRhi::MaxThreadGroupsPerDimension, with a warning.

Setting any of the group counts to 0 disables the ComputePass: its shader is not executed until all group counts are non-zero again. This is useful for toggling a pass on and off without editing its commands list, for example:

 Dispatch {
     groupCountX: computeEnabled ? (myImage.width + 7) / 8 : 0
     groupCountY: (myImage.height + 7) / 8
 }

See also ComputePass.

Property Documentation

groupCountX : int

This property holds the number of work groups to dispatch along the X dimension. The default value is 1. A value of 0 disables the ComputePass. Negative values are ignored.

groupCountY : int

This property holds the number of work groups to dispatch along the Y dimension. The default value is 1. A value of 0 disables the ComputePass. Negative values are ignored.

groupCountZ : int

This property holds the number of work groups to dispatch along the Z dimension. The default value is 1. A value of 0 disables the ComputePass. Negative values are ignored.