PySide6.QtGui.QRhiShaderStage

class QRhiShaderStage

Specifies the type and the shader code for a shader stage in the pipeline.

Details

When setting up a QRhiGraphicsPipeline , a collection of shader stages are specified. The QRhiShaderStage contains a QShader and some associated metadata, such as the graphics pipeline stage, and the shader variant to select. There is no need to specify the shader language or version because the QRhi backend in use at runtime will take care of choosing the appropriate shader version from the collection within the QShader .

The typical usage is in combination with setShaderStages() , shown here with a simple approach to load the QShader from .qsb files generated offline or at build time:

QShader getShader(const QString &name)
{
    QFile f(name);
    return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader();
}

QShader vs = getShader("material.vert.qsb");
QShader fs = getShader("material.frag.qsb");
pipeline->setShaderStages({
    { QRhiShaderStage::Vertex, vs },
    { QRhiShaderStage::Fragment, fs }
});

Note

This is a RHI API with limited compatibility guarantees, see QRhi for details.

Added in version 6.6.

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

class Type

Specifies the type of the shader stage.

Constant

Description

QRhiShaderStage.Type.Vertex

Vertex stage

QRhiShaderStage.Type.TessellationControl

Tessellation control (hull shader) stage. Must be used only when the Tessellation feature is supported.

QRhiShaderStage.Type.TessellationEvaluation

Tessellation evaluation (domain shader) stage. Must be used only when the Tessellation feature is supported.

QRhiShaderStage.Type.Fragment

Fragment (pixel shader) stage

QRhiShaderStage.Type.Compute

Compute stage. Must be used only when the Compute feature is supported.

QRhiShaderStage.Type.Geometry

Geometry stage. Must be used only when the GeometryShader feature is supported.

__init__()

Constructs a shader stage description for the vertex stage with an empty QShader .

__init__(type, shader[, v=QShader.StandardShader])
Parameters:

Constructs a shader stage description with the type of the stage and the shader.

The shader variant v defaults to StandardShader . A QShader contains multiple source and binary versions of a shader. In addition, it can also contain variants of the shader with slightly modified code. v can then be used to select the desired variant.

__ne__(b)
Parameters:

bQRhiShaderStage

Return type:

bool

__eq__(b)
Parameters:

bQRhiShaderStage

Return type:

bool

setShader(s)
Parameters:

sQShader

Sets the shader collection s.

See also

shader()

setShaderVariant(v)
Parameters:

vVariant

Sets the requested shader variant v.

See also

shaderVariant()

setType(t)
Parameters:

tType

Sets the type of the stage to t. Setters should rarely be needed in pratice. Most applications will likely use the QRhiShaderStage constructor in most cases.

See also

type()

shader()
Return type:

QShader

Returns the QShader to be used for this stage in the graphics pipeline.

See also

setShader()

shaderVariant()
Return type:

Variant

Returns the requested shader variant.

type()
Return type:

Type

Returns the type of the stage.

See also

setType()