- Qbs Manual
- QbsModules
- Qt.shadertools
- Qbs 3.1.1

# Qt.shadertools

Provides Qt Shader Tools support. More...

- List of all members, including inherited members

## Properties

- addResourceData : bool
- batchable : bool
- debugInformation : bool
- defines : stringList
- enableLinking : bool
- generatedShadersDir : string
- glslVersions : stringList
- hlslVersions : stringList
- mslVersions : stringList
- optimized : bool
- qsbName : string
- tessellation : bool
- tessellationMode : string
- tessellationVertexCount : int
- useCompiler : bool
- useQt6Versions : bool
- viewCount : int
- zOrderLocation : int

## Detailed Description

The Qt.shadertools module provides functionality for compiling and processing shaders in Qbs projects. It supports various shader languages including GLSL, HLSL, and MSL.

### Relevant File Tags

Tag | Auto-tagged File Names | Since | Description
--- | --- | --- | ---
`qt.shader` | `*.vert, *.tesc, *.tese, *.frag, *.comp` | `3.0` | Source files with these extensions are considered shaders and are processed by the qsb tool.
`qt.shader.vertex` | `*.vert` | `3.0` | Source files with this extension are considered vertex shaders.
`qt.shader.fragment` | `*.frag` | `3.0` | Source files with this extension are considered fragment shaders.
`qt.shader.compute` | `*.comp` | `3.0` | Source files with this extension are considered compute shaders.
`qt.shader.tessellation` | `*.tesc` | `3.0` | Source files with this extension are considered tessellation shaders. These shaders are automatically processed by using tessellation properties.
`qt.compiled_shader` | n/a | `3.0` | This tag is attached to the output artifacts of the rule that runs the qsb tool.

### Example

     QtApplication {
         name: "shader-app"
         type: "application"

         Depends { name: "Qt.shadertools" }

         files: ["shader.frag", "shader.vert"]
         Qt.shadertools.glslVersions: ["300 es", "330"]
         Qt.shadertools.hlslVersions: ["50"]
         Qt.shadertools.mslVersions: ["12"]
     }

For more details on the `qsb` tool, see its documentation

## Property Documentation

addResourceData : bool

Whether to automatically add the compiled shaders to the Qt resource data.

Default: `true`

batchable : bool

Whether vertex shaders should be made batchable for use with Qt Quick.

Default: `false`

debugInformation : bool

Whether to generate full debug information for SPIR-V.

Default: `false`

defines : stringList

List of preprocessor defines to be active during shader compilation.

Defines should be added as `"<name>=<value>"` pairs.

Default: `[]`

enableLinking : bool

Set this property to `true` to enable linking to the QtShaderTools library.

For example:

     QtApplication {
         name: "shader-app"
         Depends { name: "Qt.shadertools" }
         Qt.shadertools.enableLinking: true
     }

The Qt.shadertools module can be used in two ways:

- Using the `qsb` tool to compile shaders.
- Linking directly to the QtShaderTools library and using the QShaderBaker class.

This property and useCompiler property controls which mode is used. You can also enable both modes by setting both properties to `true`.

Default: `false`

generatedShadersDir : string

The directory where compiled shaders will be placed.

Default: `"shaders"`

glslVersions : stringList

List of GLSL versions to generate. Each version should be specified as a string, for example `"100 es"` for GLSL ES 1.00.

If this property is set to `[]`, GLSL generation is disabled.

Default: `[]`

hlslVersions : stringList

List of HLSL (shader model) versions to generate. The versions follow GLSL-style version numbers, where 50 corresponds to Shader Model 5.0.

If this property is set to `[]`, HLSL generation is disabled.

Default: `[]`

mslVersions : stringList

List of Metal Shading Language versions to generate. 12 corresponds to version 1.2.

If this property is set to `[]`, MSL generation is disabled.

Default: `[]`

optimized : bool

Whether to perform SPIR-V optimizations using spirv-opt.

Default: `false`

qsbName : string

The name of the Qt Shader Tools compiler executable.

Default: `"qsb"`

tessellation : bool

Whether the shaders are used in a pipeline that uses tessellation.

By default, Qbs adds flags contolled by tessellationMode and tessellationVertexCount properties for all files with the `"qt.shader.tessellation"` file tag. Set this property to `false` to disable tessellation options for such files.

Default: `true`

tessellationMode : string

The tessellation mode. Can be either `"triangles"` or `"quads"`.

This property must be specified when a tessellation control shader is used.

Default: `"triangles"`

tessellationVertexCount : int

The output vertex count from the tessellation control stage.

Default: `3`

useCompiler : bool

Whether to use the Qt Shader Tools compiler.

Set this property to `false` to disable the qsb tool. This is set to `false` by default if enableLinking is `true`.

Default: `true`

useQt6Versions : bool

Use default version used by Qt6.

This is equivalent to passing `--qt6` switch to the `qsb` tool.

Default: `false`

viewCount : int

The number of views a vertex shader is used with. Relevant for multiview functionality (GL_OVR_multiview2, VK_KHR_multiview, D3D12 view instancing).

Default: `undefined`

zOrderLocation : int

When batchable is true, this specifies the location for the additional vertex input that is injected with location 7 by default.

Use this property to change the location of the injected vertex input to another value.

This becomes relevant if the vertex shader has many inputs and 7 is in use and would clash.

Default: `undefined`