QRhiGraphicsPipeline Class

Graphics pipeline state resource. More...

Header: #include <QRhiGraphicsPipeline>
qmake: QT += rhi
Inherits: QRhiResource

Public Types

class StencilOpState
class TargetBlend
enum BlendFactor { Zero, One, SrcColor, OneMinusSrcColor, ..., OneMinusSrc1Alpha }
enum BlendOp { Add, Subtract, ReverseSubtract, Min, Max }
flags ColorMask
enum ColorMaskComponent { R, G, B, A }
enum CompareOp { Never, Less, Equal, LessOrEqual, ..., Always }
enum CullMode { None, Front, Back }
enum Flag { UsesBlendConstants, UsesStencilRef, UsesScissor }
flags Flags
enum FrontFace { CCW, CW }
enum StencilOp { StencilZero, Keep, Replace, IncrementAndClamp, ..., DecrementAndWrap }
enum Topology { Triangles, TriangleStrip, Lines, LineStrip, Points }

Public Functions

virtual bool build() = 0
QRhiGraphicsPipeline::CullMode cullMode() const
QRhiGraphicsPipeline::CompareOp depthOp() const
QRhiGraphicsPipeline::Flags flags() const
QRhiGraphicsPipeline::FrontFace frontFace() const
bool hasDepthTest() const
bool hasDepthWrite() const
bool hasStencilTest() const
QRhiRenderPassDescriptor *renderPassDescriptor() const
int sampleCount() const
void setCullMode(QRhiGraphicsPipeline::CullMode mode)
void setDepthOp(QRhiGraphicsPipeline::CompareOp op)
void setDepthTest(bool enable)
void setDepthWrite(bool enable)
void setFlags(QRhiGraphicsPipeline::Flags f)
void setFrontFace(QRhiGraphicsPipeline::FrontFace f)
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
void setSampleCount(int s)
void setShaderResourceBindings(QRhiShaderResourceBindings *srb)
void setShaderStages(const QVector<QRhiShaderStage> &stages)
void setStencilBack(const QRhiGraphicsPipeline::StencilOpState &state)
void setStencilFront(const QRhiGraphicsPipeline::StencilOpState &state)
void setStencilReadMask(quint32 mask)
void setStencilTest(bool enable)
void setStencilWriteMask(quint32 mask)
void setTargetBlends(const QVector<QRhiGraphicsPipeline::TargetBlend> &blends)
void setTopology(QRhiGraphicsPipeline::Topology t)
void setVertexInputLayout(const QRhiVertexInputLayout &layout)
QRhiShaderResourceBindings *shaderResourceBindings() const
QVector<QRhiShaderStage> shaderStages() const
QRhiGraphicsPipeline::StencilOpState stencilBack() const
QRhiGraphicsPipeline::StencilOpState stencilFront() const
quint32 stencilReadMask() const
quint32 stencilWriteMask() const
QVector<QRhiGraphicsPipeline::TargetBlend> targetBlends() const
QRhiGraphicsPipeline::Topology topology() const
QRhiVertexInputLayout vertexInputLayout() const

Reimplemented Public Functions

virtual QRhiResource::Type resourceType() const override

Protected Variables

QRhiGraphicsPipeline::CullMode m_cullMode
QRhiGraphicsPipeline::CompareOp m_depthOp
bool m_depthTest
bool m_depthWrite
QRhiGraphicsPipeline::Flags m_flags
QRhiGraphicsPipeline::FrontFace m_frontFace
QRhiRenderPassDescriptor *m_renderPassDesc
int m_sampleCount
QRhiShaderResourceBindings *m_shaderResourceBindings
QVector<QRhiShaderStage> m_shaderStages
QRhiGraphicsPipeline::StencilOpState m_stencilBack
QRhiGraphicsPipeline::StencilOpState m_stencilFront
quint32 m_stencilReadMask
bool m_stencilTest
quint32 m_stencilWriteMask
QVector<QRhiGraphicsPipeline::TargetBlend> m_targetBlends
QRhiGraphicsPipeline::Topology m_topology
QRhiVertexInputLayout m_vertexInputLayout

Additional Inherited Members

Detailed Description

Graphics pipeline state resource.

Note: Setting the shader resource bindings is mandatory. The referenced QRhiShaderResourceBindings must already be built by the time build() is called.

Note: Setting the render pass descriptor is mandatory. To obtain a QRhiRenderPassDescriptor that can be passed to setRenderPassDescriptor(), use either QRhiTextureRenderTarget::newCompatibleRenderPassDescriptor() or QRhiSwapChain::newCompatibleRenderPassDescriptor().

Note: Setting the vertex input layout is mandatory.

Note: Setting the shader stages is mandatory.

Note: sampleCount() defaults to 1 and must match the sample count of the render target's color and depth stencil attachments.

Note: The depth test, depth write, and stencil test are disabled by default.

Note: stencilReadMask() and stencilWriteMask() apply to both faces. They both default to 0xFF.

Member Type Documentation

enum QRhiGraphicsPipeline::BlendFactor

Specifies the blend factor

ConstantValue
QRhiGraphicsPipeline::Zero0
QRhiGraphicsPipeline::One1
QRhiGraphicsPipeline::SrcColor2
QRhiGraphicsPipeline::OneMinusSrcColor3
QRhiGraphicsPipeline::DstColor4
QRhiGraphicsPipeline::OneMinusDstColor5
QRhiGraphicsPipeline::SrcAlpha6
QRhiGraphicsPipeline::OneMinusSrcAlpha7
QRhiGraphicsPipeline::DstAlpha8
QRhiGraphicsPipeline::OneMinusDstAlpha9
QRhiGraphicsPipeline::ConstantColor10
QRhiGraphicsPipeline::OneMinusConstantColor11
QRhiGraphicsPipeline::ConstantAlpha12
QRhiGraphicsPipeline::OneMinusConstantAlpha13
QRhiGraphicsPipeline::SrcAlphaSaturate14
QRhiGraphicsPipeline::Src1Color15
QRhiGraphicsPipeline::OneMinusSrc1Color16
QRhiGraphicsPipeline::Src1Alpha17
QRhiGraphicsPipeline::OneMinusSrc1Alpha18

enum QRhiGraphicsPipeline::BlendOp

Specifies the blend operation

ConstantValue
QRhiGraphicsPipeline::Add0
QRhiGraphicsPipeline::Subtract1
QRhiGraphicsPipeline::ReverseSubtract2
QRhiGraphicsPipeline::Min3
QRhiGraphicsPipeline::Max4

enum QRhiGraphicsPipeline::ColorMaskComponent
flags QRhiGraphicsPipeline::ColorMask

Flag values for specifying the color write mask

ConstantValue
QRhiGraphicsPipeline::R1 << 0
QRhiGraphicsPipeline::G1 << 1
QRhiGraphicsPipeline::B1 << 2
QRhiGraphicsPipeline::A1 << 3

The ColorMask type is a typedef for QFlags<ColorMaskComponent>. It stores an OR combination of ColorMaskComponent values.

enum QRhiGraphicsPipeline::CompareOp

Specifies the depth or stencil comparison function

ConstantValueDescription
QRhiGraphicsPipeline::Never0 
QRhiGraphicsPipeline::Less1(default for depth)
QRhiGraphicsPipeline::Equal2 
QRhiGraphicsPipeline::LessOrEqual3 
QRhiGraphicsPipeline::Greater4 
QRhiGraphicsPipeline::NotEqual5 
QRhiGraphicsPipeline::GreaterOrEqual6 
QRhiGraphicsPipeline::Always7(default for stencil)

enum QRhiGraphicsPipeline::CullMode

Specifies the culling mode

ConstantValueDescription
QRhiGraphicsPipeline::None0No culling (default)
QRhiGraphicsPipeline::Front1Cull front faces
QRhiGraphicsPipeline::Back2Cull back faces

enum QRhiGraphicsPipeline::Flag
flags QRhiGraphicsPipeline::Flags

Flag values for describing the dynamic state of the pipeline. The viewport is always dynamic.

ConstantValueDescription
QRhiGraphicsPipeline::UsesBlendConstants1 << 0Indicates that a blend color constant will be set via QRhiCommandBuffer::setBlendConstants()
QRhiGraphicsPipeline::UsesStencilRef1 << 1Indicates that a stencil reference value will be set via QRhiCommandBuffer::setStencilRef()
QRhiGraphicsPipeline::UsesScissor1 << 2Indicates that a scissor rectangle will be set via QRhiCommandBuffer::setScissor()

The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.

enum QRhiGraphicsPipeline::FrontFace

Specifies the front face winding order

ConstantValueDescription
QRhiGraphicsPipeline::CCW0Counter clockwise (default)
QRhiGraphicsPipeline::CW1Clockwise

enum QRhiGraphicsPipeline::StencilOp

Specifies the stencil operation

ConstantValueDescription
QRhiGraphicsPipeline::StencilZero0 
QRhiGraphicsPipeline::Keep1(default)
QRhiGraphicsPipeline::Replace2 
QRhiGraphicsPipeline::IncrementAndClamp3 
QRhiGraphicsPipeline::DecrementAndClamp4 
QRhiGraphicsPipeline::Invert5 
QRhiGraphicsPipeline::IncrementAndWrap6 
QRhiGraphicsPipeline::DecrementAndWrap7 

enum QRhiGraphicsPipeline::Topology

Specifies the primitive topology

ConstantValueDescription
QRhiGraphicsPipeline::Triangles0(default)
QRhiGraphicsPipeline::TriangleStrip1 
QRhiGraphicsPipeline::Lines2 
QRhiGraphicsPipeline::LineStrip3 
QRhiGraphicsPipeline::Points4 

Property Documentation

Member Function Documentation

[pure virtual] bool QRhiGraphicsPipeline::build()

Creates the corresponding native graphics resources. If there are already resources present due to an earlier build() with no corresponding release(), then release() is called implicitly first.

Returns true when successful, false when a graphics operation failed. Regardless of the return value, calling release() is always safe.

QRhiGraphicsPipeline::CullMode QRhiGraphicsPipeline::cullMode() const

See also setCullMode().

QRhiGraphicsPipeline::CompareOp QRhiGraphicsPipeline::depthOp() const

See also setDepthOp().

QRhiGraphicsPipeline::Flags QRhiGraphicsPipeline::flags() const

See also setFlags().

QRhiGraphicsPipeline::FrontFace QRhiGraphicsPipeline::frontFace() const

See also setFrontFace().

bool QRhiGraphicsPipeline::hasDepthTest() const

bool QRhiGraphicsPipeline::hasDepthWrite() const

bool QRhiGraphicsPipeline::hasStencilTest() const

QRhiRenderPassDescriptor *QRhiGraphicsPipeline::renderPassDescriptor() const

See also setRenderPassDescriptor().

[override virtual] QRhiResource::Type QRhiGraphicsPipeline::resourceType() const

Reimplemented from QRhiResource::resourceType().

Returns the resource type.

int QRhiGraphicsPipeline::sampleCount() const

See also setSampleCount().

void QRhiGraphicsPipeline::setCullMode(QRhiGraphicsPipeline::CullMode mode)

See also cullMode().

void QRhiGraphicsPipeline::setDepthOp(QRhiGraphicsPipeline::CompareOp op)

See also depthOp().

void QRhiGraphicsPipeline::setDepthTest(bool enable)

Enables or disables depth testing. Both depth test and the writing out of depth data are disabled by default.

See also hasDepthTest() and setDepthWrite().

void QRhiGraphicsPipeline::setDepthWrite(bool enable)

Controls the writing out of depth data into the depth buffer. By default this is disabled. Depth write is typically enabled together with the depth test.

Note: Enabling depth write without having depth testing enabled may not lead to the desired result, and should be avoided.

See also hasDepthWrite() and setDepthTest().

void QRhiGraphicsPipeline::setFlags(QRhiGraphicsPipeline::Flags f)

See also flags().

void QRhiGraphicsPipeline::setFrontFace(QRhiGraphicsPipeline::FrontFace f)

See also frontFace().

void QRhiGraphicsPipeline::setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)

See also renderPassDescriptor().

void QRhiGraphicsPipeline::setSampleCount(int s)

See also sampleCount().

void QRhiGraphicsPipeline::setShaderResourceBindings(QRhiShaderResourceBindings *srb)

See also shaderResourceBindings().

void QRhiGraphicsPipeline::setShaderStages(const QVector<QRhiShaderStage> &stages)

See also shaderStages().

void QRhiGraphicsPipeline::setStencilBack(const QRhiGraphicsPipeline::StencilOpState &state)

See also stencilBack().

void QRhiGraphicsPipeline::setStencilFront(const QRhiGraphicsPipeline::StencilOpState &state)

See also stencilFront().

void QRhiGraphicsPipeline::setStencilReadMask(quint32 mask)

See also stencilReadMask().

void QRhiGraphicsPipeline::setStencilTest(bool enable)

See also hasStencilTest().

void QRhiGraphicsPipeline::setStencilWriteMask(quint32 mask)

See also stencilWriteMask().

void QRhiGraphicsPipeline::setTargetBlends(const QVector<QRhiGraphicsPipeline::TargetBlend> &blends)

Sets the blend specification for color attachments. Each element in blends corresponds to a color attachment of the render target.

By default no blends are set, which is a shortcut to disabling blending and enabling color write for all four channels.

See also targetBlends().

void QRhiGraphicsPipeline::setTopology(QRhiGraphicsPipeline::Topology t)

See also topology().

void QRhiGraphicsPipeline::setVertexInputLayout(const QRhiVertexInputLayout &layout)

See also vertexInputLayout().

QRhiShaderResourceBindings *QRhiGraphicsPipeline::shaderResourceBindings() const

See also setShaderResourceBindings().

QVector<QRhiShaderStage> QRhiGraphicsPipeline::shaderStages() const

See also setShaderStages().

QRhiGraphicsPipeline::StencilOpState QRhiGraphicsPipeline::stencilBack() const

See also setStencilBack().

QRhiGraphicsPipeline::StencilOpState QRhiGraphicsPipeline::stencilFront() const

See also setStencilFront().

quint32 QRhiGraphicsPipeline::stencilReadMask() const

See also setStencilReadMask().

quint32 QRhiGraphicsPipeline::stencilWriteMask() const

See also setStencilWriteMask().

QVector<QRhiGraphicsPipeline::TargetBlend> QRhiGraphicsPipeline::targetBlends() const

See also setTargetBlends().

QRhiGraphicsPipeline::Topology QRhiGraphicsPipeline::topology() const

See also setTopology().

QRhiVertexInputLayout QRhiGraphicsPipeline::vertexInputLayout() const

See also setVertexInputLayout().

Member Variable Documentation

Related Non-Members

Macro Documentation