Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QRhiShaderStage Class Reference

\inmodule QtGui More...

#include <qrhi.h>

+ Collaboration diagram for QRhiShaderStage:

Public Types

enum  Type {
  Vertex , TessellationControl , TessellationEvaluation , Geometry ,
  Fragment , Compute
}
 Specifies the type of the shader stage. More...
 

Public Member Functions

 QRhiShaderStage ()=default
 Constructs a shader stage description for the vertex stage with an empty QShader.
 
 QRhiShaderStage (Type type, const QShader &shader, QShader::Variant v=QShader::StandardShader)
 Constructs a shader stage description with the type of the stage and the shader.
 
Type type () const
 
void setType (Type t)
 Sets the type of the stage to t.
 
QShader shader () const
 
void setShader (const QShader &s)
 Sets the shader collection s.
 
QShader::Variant shaderVariant () const
 
void setShaderVariant (QShader::Variant v)
 Sets the requested shader variant v.
 

Friends

bool operator== (const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept
 
bool operator!= (const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept
 
size_t qHash (const QRhiShaderStage &v, size_t seed=0) noexcept
 

Detailed Description

\inmodule QtGui

Since
6.6

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

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 \l{QShader::Variant}{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 QRhiGraphicsPipeline::setShaderStages(), shown here with a simple approach to load the QShader from {.qsb} files generated offline or at build time:

{
return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader();
}
QShader vs = getShader("material.vert.qsb");
QShader fs = getShader("material.frag.qsb");
pipeline->setShaderStages({
});
\inmodule QtCore
Definition qfile.h:93
\inmodule QtGui
Definition qshader.h:81
static QShader fromSerialized(const QByteArray &data)
Creates a new QShader instance from the given data.
Definition qshader.cpp:540
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QShader getShader(const QString &name)
GLfloat GLfloat f
GLuint name
Note
This is a RHI API with limited compatibility guarantees, see \l QRhi for details.

Definition at line 378 of file qrhi.h.

Member Enumeration Documentation

◆ Type

Specifies the type of the shader stage.

\value Vertex Vertex stage

\value TessellationControl Tessellation control (hull shader) stage. Must be used only when the QRhi::Tessellation feature is supported.

\value TessellationEvaluation Tessellation evaluation (domain shader) stage. Must be used only when the QRhi::Tessellation feature is supported.

\value Fragment Fragment (pixel shader) stage

\value Compute Compute stage. Must be used only when the QRhi::Compute feature is supported.

\value Geometry Geometry stage. Must be used only when the QRhi::GeometryShader feature is supported.

Enumerator
Vertex 
TessellationControl 
TessellationEvaluation 
Geometry 
Fragment 
Compute 

Definition at line 381 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiShaderStage() [1/2]

QRhiShaderStage::QRhiShaderStage ( )
default

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

◆ QRhiShaderStage() [2/2]

QRhiShaderStage::QRhiShaderStage ( Type type,
const QShader & shader,
QShader::Variant v = QShader::StandardShader )

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

The shader variant v defaults to QShader::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.

Definition at line 2192 of file qrhi.cpp.

Member Function Documentation

◆ setShader()

void QRhiShaderStage::setShader ( const QShader & s)
inline

Sets the shader collection s.

Definition at line 398 of file qrhi.h.

◆ setShaderVariant()

void QRhiShaderStage::setShaderVariant ( QShader::Variant v)
inline

Sets the requested shader variant v.

Definition at line 401 of file qrhi.h.

◆ setType()

void QRhiShaderStage::setType ( Type t)
inline

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.

Definition at line 395 of file qrhi.h.

◆ shader()

QShader QRhiShaderStage::shader ( ) const
inline
Returns
the QShader to be used for this stage in the graphics pipeline.

Definition at line 397 of file qrhi.h.

Referenced by addOpaqueDepthPrePassBindings(), QSSGRhiShaderPipeline::addStage(), QD3D11ComputePipeline::create(), QGles2ComputePipeline::create(), QMetalComputePipeline::create(), QVkComputePipeline::create(), and QRhiGles2::shaderSource().

+ Here is the caller graph for this function:

◆ shaderVariant()

QShader::Variant QRhiShaderStage::shaderVariant ( ) const
inline
Returns
the requested shader variant.

Definition at line 400 of file qrhi.h.

Referenced by QD3D11ComputePipeline::create(), QGles2ComputePipeline::create(), QMetalComputePipeline::create(), QVkComputePipeline::create(), and QRhiGles2::shaderSource().

+ Here is the caller graph for this function:

◆ type()

QRhiShaderStage::Type QRhiShaderStage::type ( ) const
inline
Returns
the type of the stage.

Definition at line 394 of file qrhi.h.

Referenced by QSSGRhiShaderPipeline::addStage(), QRhiGles2::compileShader(), QVkComputePipeline::create(), isGraphicsStage(), and QRhiGles2::tryLoadFromDiskOrPipelineCache().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool QRhiShaderStage::operator!= ( const QRhiShaderStage & a,
const QRhiShaderStage & b )
friend
Returns
false if the values in the two QRhiShaderStage objects a and b are equal; otherwise returns true.

Definition at line 415 of file qrhi.h.

◆ operator==

bool QRhiShaderStage::operator== ( const QRhiShaderStage & a,
const QRhiShaderStage & b )
friend
Returns
true if the values in the two QRhiShaderStage objects a and b are equal.

Definition at line 408 of file qrhi.h.

◆ qHash

size_t QRhiShaderStage::qHash ( const QRhiShaderStage & v,
size_t seed = 0 )
friend
Returns
the hash value for v, using seed to seed the calculation.

Definition at line 420 of file qrhi.h.


The documentation for this class was generated from the following files: