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
QSGMaterialShader::RenderState Class Reference

Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and the other update type of functions. More...

#include <qsgmaterialshader.h>

+ Collaboration diagram for QSGMaterialShader::RenderState:

Public Types

enum  DirtyState { DirtyMatrix = 0x0001 , DirtyOpacity = 0x0002 , DirtyCachedMaterialData = 0x0004 , DirtyAll = 0xFFFF }
 \value DirtyMatrix Used to indicate that the matrix has changed and must be updated. More...
 

Public Member Functions

DirtyStates dirtyStates () const
 Returns which rendering states that have changed and needs to be updated for geometry rendered with this material to conform to the current rendering state.
 
bool isMatrixDirty () const
 Returns true if the dirtyStates() contain the dirty matrix state, otherwise returns false.
 
bool isOpacityDirty () const
 Returns true if the dirtyStates() contains the dirty opacity state, otherwise returns false.
 
float opacity () const
 \variable QSGMaterialShader::GraphicsPipelineState::blendEnable
 
QMatrix4x4 combinedMatrix () const
 Returns the matrix combined of modelview matrix and project matrix.
 
QMatrix4x4 combinedMatrix (int index) const
 
QMatrix4x4 modelViewMatrix () const
 Returns the model view matrix.
 
QMatrix4x4 projectionMatrix () const
 Returns the projection matrix.
 
QMatrix4x4 projectionMatrix (int index) const
 
int projectionMatrixCount () const
 
QRect viewportRect () const
 Returns the viewport rect of the surface being rendered to.
 
QRect deviceRect () const
 Returns the device rect of the surface being rendered to.
 
float determinant () const
 Returns the modelview determinant to be used for rendering.
 
float devicePixelRatio () const
 Returns the ratio between physical pixels and device-independent pixels to be used for rendering.
 
QByteArrayuniformData ()
 Returns a pointer to the data for the uniform (constant) buffer in the shader.
 
QRhiResourceUpdateBatchresourceUpdateBatch ()
 Returns a resource update batch to which upload and copy operatoins can be queued.
 
QRhirhi ()
 Returns the current QRhi.
 

Friends

class QSGRenderer
 

Detailed Description

Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and the other update type of functions.

\inmodule QtQuick

Since
5.14

The render state contains a number of accessors that the shader needs to respect in order to conform to the current state of the scene graph.

Definition at line 25 of file qsgmaterialshader.h.

Member Enumeration Documentation

◆ DirtyState

\value DirtyMatrix Used to indicate that the matrix has changed and must be updated.

\value DirtyOpacity Used to indicate that the opacity has changed and must be updated.

\value DirtyCachedMaterialData Used to indicate that the cached material state has changed and must be updated.

\value DirtyAll Used to indicate that everything needs to be updated.

Enumerator
DirtyMatrix 
DirtyOpacity 
DirtyCachedMaterialData 
DirtyAll 

Definition at line 27 of file qsgmaterialshader.h.

Member Function Documentation

◆ combinedMatrix() [1/2]

QMatrix4x4 QSGMaterialShader::RenderState::combinedMatrix ( ) const

Returns the matrix combined of modelview matrix and project matrix.

Definition at line 795 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ combinedMatrix() [2/2]

QMatrix4x4 QSGMaterialShader::RenderState::combinedMatrix ( int index) const

Definition at line 804 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ determinant()

float QSGMaterialShader::RenderState::determinant ( ) const

Returns the modelview determinant to be used for rendering.

Definition at line 786 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ devicePixelRatio()

float QSGMaterialShader::RenderState::devicePixelRatio ( ) const

Returns the ratio between physical pixels and device-independent pixels to be used for rendering.

Definition at line 814 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ deviceRect()

QRect QSGMaterialShader::RenderState::deviceRect ( ) const

Returns the device rect of the surface being rendered to.

Definition at line 879 of file qsgmaterialshader.cpp.

References deviceRect, m_data, and Q_ASSERT.

◆ dirtyStates()

QSGMaterialShader::RenderState::DirtyStates QSGMaterialShader::RenderState::dirtyStates ( ) const
inline

Returns which rendering states that have changed and needs to be updated for geometry rendered with this material to conform to the current rendering state.

Definition at line 36 of file qsgmaterialshader.h.

◆ isMatrixDirty()

bool QSGMaterialShader::RenderState::isMatrixDirty ( ) const
inline

Returns true if the dirtyStates() contain the dirty matrix state, otherwise returns false.

Definition at line 38 of file qsgmaterialshader.h.

References DirtyMatrix.

◆ isOpacityDirty()

bool QSGMaterialShader::RenderState::isOpacityDirty ( ) const
inline

Returns true if the dirtyStates() contains the dirty opacity state, otherwise returns false.

Definition at line 39 of file qsgmaterialshader.h.

References DirtyOpacity.

◆ modelViewMatrix()

QMatrix4x4 QSGMaterialShader::RenderState::modelViewMatrix ( ) const

Returns the model view matrix.

If the material has the RequiresFullMatrix flag set, this is guaranteed to be the complete transform matrix calculated from the scenegraph.

However, if this flag is not set, the renderer may choose to alter this matrix. For example, it may pre-transform vertices on the CPU and set this matrix to identity.

In a situation such as the above, it is still possible to retrieve the actual matrix determinant by setting the RequiresDeterminant flag in the material and calling the determinant() accessor.

Definition at line 834 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ opacity()

float QSGMaterialShader::RenderState::opacity ( ) const

\variable QSGMaterialShader::GraphicsPipelineState::blendEnable

Since
5.14

Enables blending.

Note
Changing this flag should be done with care, and is best avoided. Rather, materials should always use the QSGMaterial::Blend flag to indicate that they wish to use blending. Changing this value from false to true for a material that did not declare QSGMaterial::Blend can lead to unexpected visual results.

\variable QSGMaterialShader::GraphicsPipelineState::srcColor

Since
5.14

Source blending factor, either RGB or RGBA depending on separateBlendFactors.

\variable QSGMaterialShader::GraphicsPipelineState::dstColor

Since
5.14

Destination blending factor, either RGB or RGBA depending on separateBlendFactors.

\variable QSGMaterialShader::GraphicsPipelineState::colorWrite

Since
5.14

Color write mask.

\variable QSGMaterialShader::GraphicsPipelineState::blendConstant

Since
5.14

Blend constant applicable when a blending factor is set to use a constant value.

\variable QSGMaterialShader::GraphicsPipelineState::cullMode

Since
5.14

Cull mode.

\variable QSGMaterialShader::GraphicsPipelineState::polygonMode

Since
6.4

Polygon rasterization mode.

\variable QSGMaterialShader::GraphicsPipelineState::separateBlendFactors

Since
6.5

Indicates that alpha blending factors are specified separately.

False by default, meaning both RGB and alpha blending factors are defined by srcColor and dstColor. When set to true, the alpha blending factors are taken from srcAlpha and dstAlpha instead, and srcColor and dstColor applies only to RGB.

\variable QSGMaterialShader::GraphicsPipelineState::srcAlpha

Since
6.5

Source alpha blending factor.

Applies only when separateBlendFactors is set to true.

\variable QSGMaterialShader::GraphicsPipelineState::dstAlpha

Since
6.5

Destination alpha blending factor.

Applies only when separateBlendFactors is set to true.

Returns the accumulated opacity to be used for rendering.

Definition at line 777 of file qsgmaterialshader.cpp.

References Q_ASSERT.

◆ projectionMatrix() [1/2]

QMatrix4x4 QSGMaterialShader::RenderState::projectionMatrix ( ) const

Returns the projection matrix.

Definition at line 843 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ projectionMatrix() [2/2]

QMatrix4x4 QSGMaterialShader::RenderState::projectionMatrix ( int index) const

Definition at line 852 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ projectionMatrixCount()

int QSGMaterialShader::RenderState::projectionMatrixCount ( ) const

Definition at line 861 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ resourceUpdateBatch()

QRhiResourceUpdateBatch * QSGMaterialShader::RenderState::resourceUpdateBatch ( )

Returns a resource update batch to which upload and copy operatoins can be queued.

This is typically used by QSGMaterialShader::updateSampledImage() to enqueue texture image content updates.

Definition at line 917 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ rhi()

QRhi * QSGMaterialShader::RenderState::rhi ( )

Returns the current QRhi.

Definition at line 926 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ uniformData()

QByteArray * QSGMaterialShader::RenderState::uniformData ( )

Returns a pointer to the data for the uniform (constant) buffer in the shader.

Uniform data must only be updated from QSGMaterialShader::updateUniformData(). The return value is null in the other reimplementable functions, such as, QSGMaterialShader::updateSampledImage().

Note
It is strongly recommended to declare the uniform block with std140 in the shader, and to carefully study the standard uniform block layout as described in section 7.6.2.2 of the OpenGL specification. It is up to the QSGMaterialShader implementation to ensure data gets placed at the right location in this QByteArray, taking alignment requirements into account. Shader code translated to other shading languages is expected to use the same offsets for block members, even when the target language uses different packing rules by default.
Avoid copying from C++ POD types, such as, structs, in order to update multiple members at once, unless it has been verified that the layouts of the C++ struct and the GLSL uniform block match.

Definition at line 905 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

◆ viewportRect()

QRect QSGMaterialShader::RenderState::viewportRect ( ) const

Returns the viewport rect of the surface being rendered to.

Definition at line 870 of file qsgmaterialshader.cpp.

References m_data, and Q_ASSERT.

Friends And Related Symbol Documentation

◆ QSGRenderer

friend class QSGRenderer
friend

Definition at line 58 of file qsgmaterialshader.h.


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