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
QVkGraphicsPipeline Struct Reference

#include <qrhivulkan_p.h>

+ Inheritance diagram for QVkGraphicsPipeline:
+ Collaboration diagram for QVkGraphicsPipeline:

Public Member Functions

 QVkGraphicsPipeline (QRhiImplementation *rhi)
 
 ~QVkGraphicsPipeline ()
 
void destroy () override
 Releases (or requests deferred releasing of) the underlying native graphics resources.
 
bool create () override
 Creates the corresponding native graphics resources.
 
- Public Member Functions inherited from QRhiGraphicsPipeline
QRhiResource::Type resourceType () const override
 
Flags flags () const
 
void setFlags (Flags f)
 Sets the flags f.
 
Topology topology () const
 
void setTopology (Topology t)
 Sets the primitive topology t.
 
CullMode cullMode () const
 
void setCullMode (CullMode mode)
 Sets the specified face culling mode.
 
FrontFace frontFace () const
 
void setFrontFace (FrontFace f)
 Sets the front face mode f.
 
void setTargetBlends (std::initializer_list< TargetBlend > list)
 Sets the list of render target blend settings.
 
template<typename InputIterator >
void setTargetBlends (InputIterator first, InputIterator last)
 Sets the list of render target blend settings from the iterators first and last.
 
const TargetBlendcbeginTargetBlends () const
 
const TargetBlendcendTargetBlends () const
 
const TargetBlendtargetBlendAt (qsizetype index) const
 
qsizetype targetBlendCount () const
 
bool hasDepthTest () const
 
void setDepthTest (bool enable)
 Enables or disables depth testing based on enable.
 
bool hasDepthWrite () const
 
void setDepthWrite (bool enable)
 Controls the writing out of depth data into the depth buffer based on enable.
 
CompareOp depthOp () const
 
void setDepthOp (CompareOp op)
 Sets the depth comparison function op.
 
bool hasStencilTest () const
 
void setStencilTest (bool enable)
 Enables or disables stencil tests based on enable.
 
StencilOpState stencilFront () const
 
void setStencilFront (const StencilOpState &state)
 Sets the stencil test state for front faces.
 
StencilOpState stencilBack () const
 
void setStencilBack (const StencilOpState &state)
 Sets the stencil test state for back faces.
 
quint32 stencilReadMask () const
 
void setStencilReadMask (quint32 mask)
 Sets the stencil read mask.
 
quint32 stencilWriteMask () const
 
void setStencilWriteMask (quint32 mask)
 Sets the stencil write mask.
 
int sampleCount () const
 
void setSampleCount (int s)
 Sets the sample count.
 
float lineWidth () const
 
void setLineWidth (float width)
 Sets the line width.
 
int depthBias () const
 
void setDepthBias (int bias)
 Sets the depth bias.
 
float slopeScaledDepthBias () const
 
void setSlopeScaledDepthBias (float bias)
 Sets the slope scaled depth bias.
 
void setShaderStages (std::initializer_list< QRhiShaderStage > list)
 Sets the list of shader stages.
 
template<typename InputIterator >
void setShaderStages (InputIterator first, InputIterator last)
 Sets the list of shader stages from the iterators first and last.
 
const QRhiShaderStagecbeginShaderStages () const
 
const QRhiShaderStagecendShaderStages () const
 
const QRhiShaderStageshaderStageAt (qsizetype index) const
 
qsizetype shaderStageCount () const
 
QRhiVertexInputLayout vertexInputLayout () const
 
void setVertexInputLayout (const QRhiVertexInputLayout &layout)
 Specifies the vertex input layout.
 
QRhiShaderResourceBindingsshaderResourceBindings () const
 
void setShaderResourceBindings (QRhiShaderResourceBindings *srb)
 Associates with srb describing the resource binding layout and the resources (QRhiBuffer, QRhiTexture) themselves.
 
QRhiRenderPassDescriptorrenderPassDescriptor () const
 
void setRenderPassDescriptor (QRhiRenderPassDescriptor *desc)
 Associates with the specified QRhiRenderPassDescriptor desc.
 
int patchControlPointCount () const
 
void setPatchControlPointCount (int count)
 Sets the number of patch control points to count.
 
PolygonMode polygonMode () const
 
void setPolygonMode (PolygonMode mode)
 Sets the polygon mode.
 
int multiViewCount () const
 
void setMultiViewCount (int count)
 Sets the view count for multiview rendering.
 
- Public Member Functions inherited from QRhiResource
virtual ~QRhiResource ()
 Destructor.
 
void deleteLater ()
 When called without a frame being recorded, this function is equivalent to deleting the object.
 
QByteArray name () const
 
void setName (const QByteArray &name)
 Sets a name for the object.
 
quint64 globalResourceId () const
 
QRhirhi () const
 

Public Attributes

VkPipelineLayout layout = VK_NULL_HANDLE
 
VkPipeline pipeline = VK_NULL_HANDLE
 
int lastActiveFrameSlot = -1
 
uint generation = 0
 

Friends

class QRhiVulkan
 

Additional Inherited Members

- Public Types inherited from QRhiGraphicsPipeline
enum  Flag { UsesBlendConstants = 1 << 0 , UsesStencilRef = 1 << 1 , UsesScissor = 1 << 2 , CompileShadersWithDebugInfo = 1 << 3 }
 Flag values for describing the dynamic state of the pipeline, and other options. More...
 
enum  Topology {
  Triangles , TriangleStrip , TriangleFan , Lines ,
  LineStrip , Points , Patches
}
 Specifies the primitive topology. More...
 
enum  CullMode { None , Front , Back }
 Specifies the culling mode. More...
 
enum  FrontFace { CCW , CW }
 Specifies the front face winding order. More...
 
enum  ColorMaskComponent { R = 1 << 0 , G = 1 << 1 , B = 1 << 2 , A = 1 << 3 }
 Flag values for specifying the color write mask. More...
 
enum  BlendFactor {
  Zero , One , SrcColor , OneMinusSrcColor ,
  DstColor , OneMinusDstColor , SrcAlpha , OneMinusSrcAlpha ,
  DstAlpha , OneMinusDstAlpha , ConstantColor , OneMinusConstantColor ,
  ConstantAlpha , OneMinusConstantAlpha , SrcAlphaSaturate , Src1Color ,
  OneMinusSrc1Color , Src1Alpha , OneMinusSrc1Alpha
}
 Specifies the blend factor. More...
 
enum  BlendOp {
  Add , Subtract , ReverseSubtract , Min ,
  Max
}
 Specifies the blend operation. More...
 
enum  CompareOp {
  Never , Less , Equal , LessOrEqual ,
  Greater , NotEqual , GreaterOrEqual , Always
}
 Specifies the depth or stencil comparison function. More...
 
enum  StencilOp {
  StencilZero , Keep , Replace , IncrementAndClamp ,
  DecrementAndClamp , Invert , IncrementAndWrap , DecrementAndWrap
}
 Specifies the stencil operation. More...
 
enum  PolygonMode { Fill , Line }
 Specifies the polygon rasterization mode. More...
 
- Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer
}
 Specifies type of the resource. More...
 
- Protected Member Functions inherited from QRhiGraphicsPipeline
 QRhiGraphicsPipeline (QRhiImplementation *rhi)
 \variable QRhiGraphicsPipeline::StencilOpState::failOp
 
- Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)
 
- Protected Attributes inherited from QRhiGraphicsPipeline
Flags m_flags
 
Topology m_topology = Triangles
 
CullMode m_cullMode = None
 
FrontFace m_frontFace = CCW
 
QVarLengthArray< TargetBlend, 8 > m_targetBlends
 
bool m_depthTest = false
 
bool m_depthWrite = false
 
CompareOp m_depthOp = Less
 
bool m_stencilTest = false
 
StencilOpState m_stencilFront
 
StencilOpState m_stencilBack
 
quint32 m_stencilReadMask = 0xFF
 
quint32 m_stencilWriteMask = 0xFF
 
int m_sampleCount = 1
 
float m_lineWidth = 1.0f
 
int m_depthBias = 0
 
float m_slopeScaledDepthBias = 0.0f
 
int m_patchControlPointCount = 3
 
PolygonMode m_polygonMode = Fill
 
int m_multiViewCount = 0
 
QVarLengthArray< QRhiShaderStage, 4 > m_shaderStages
 
QRhiVertexInputLayout m_vertexInputLayout
 
QRhiShaderResourceBindingsm_shaderResourceBindings = nullptr
 
QRhiRenderPassDescriptorm_renderPassDesc = nullptr
 
- Protected Attributes inherited from QRhiResource
QRhiImplementationm_rhi = nullptr
 
quint64 m_id
 
QByteArray m_objectName
 

Detailed Description

Definition at line 283 of file qrhivulkan_p.h.

Constructor & Destructor Documentation

◆ QVkGraphicsPipeline()

QVkGraphicsPipeline::QVkGraphicsPipeline ( QRhiImplementation * rhi)

Definition at line 7478 of file qrhivulkan.cpp.

◆ ~QVkGraphicsPipeline()

QVkGraphicsPipeline::~QVkGraphicsPipeline ( )

Definition at line 7483 of file qrhivulkan.cpp.

References destroy().

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

bool QVkGraphicsPipeline::create ( )
overridevirtual

Creates the corresponding native graphics resources.

If there are already resources present due to an earlier create() with no corresponding destroy(), then destroy() is called implicitly first.

Returns
true when successful, false when a graphics operation failed. Regardless of the return value, calling destroy() is always safe.
Note
This may be, depending on the underlying graphics API, an expensive operation, especially when shaders get compiled/optimized from source or from an intermediate bytecode format to the GPU's own instruction set. Where applicable, the QRhi backend automatically sets up the relevant non-persistent facilities to accelerate this, for example the Vulkan backend automatically creates a VkPipelineCache to improve data reuse during the lifetime of the application.
Drivers may also employ various persistent (disk-based) caching strategies for shader and pipeline data, which is hidden to and is outside of Qt's control. In some cases, depending on the graphics API and the QRhi backend, there are facilities within QRhi for manually managing such a cache, allowing the retrieval of a serializable blob that can then be reloaded in the future runs of the application to ensure faster pipeline creation times. See QRhi::pipelineCacheData() and QRhi::setPipelineCacheData() for details. Note also that when working with a QRhi instance managed by a higher level Qt framework, such as Qt Quick, it is possible that such disk-based caching is taken care of automatically, for example QQuickWindow uses a disk-based pipeline cache by default (which comes in addition to any driver-level caching).

Implements QRhiGraphicsPipeline.

Definition at line 7510 of file qrhivulkan.cpp.

References QRhiVertexInputLayout::cbeginAttributes(), QRhiVertexInputLayout::cbeginBindings(), QRhiVertexInputLayout::cendAttributes(), QRhiVertexInputLayout::cendBindings(), destroy(), fillVkStencilOpState(), generation, it, lastActiveFrameSlot, layout, QRhiGraphicsPipeline::LineStrip, QRhiGraphicsPipeline::m_cullMode, QRhiGraphicsPipeline::m_depthBias, QRhiGraphicsPipeline::m_depthOp, QRhiGraphicsPipeline::m_depthTest, QRhiGraphicsPipeline::m_depthWrite, QRhiGraphicsPipeline::m_flags, QRhiGraphicsPipeline::m_frontFace, QRhiGraphicsPipeline::m_lineWidth, QRhiGraphicsPipeline::m_patchControlPointCount, QRhiGraphicsPipeline::m_polygonMode, QRhiGraphicsPipeline::m_renderPassDesc, QRhiGraphicsPipeline::m_sampleCount, QRhiGraphicsPipeline::m_shaderResourceBindings, QRhiGraphicsPipeline::m_shaderStages, QRhiGraphicsPipeline::m_slopeScaledDepthBias, QRhiGraphicsPipeline::m_stencilBack, QRhiGraphicsPipeline::m_stencilFront, QRhiGraphicsPipeline::m_stencilReadMask, QRhiGraphicsPipeline::m_stencilTest, QRhiGraphicsPipeline::m_stencilWriteMask, QRhiGraphicsPipeline::m_targetBlends, QRhiGraphicsPipeline::m_topology, QRhiGraphicsPipeline::m_vertexInputLayout, QRhiGraphicsPipeline::Patches, QRhiVertexInputBinding::PerInstance, QRhiVertexInputBinding::PerVertex, pipeline, Q_ASSERT, qFuzzyIsNull(), qMax(), QRHI_RES, QRHI_RES_RHI, qWarning, QShaderCode::shader(), QShader::shader(), QShader::SpirvShader, toVkAttributeFormat(), toVkBlendFactor(), toVkBlendOp(), toVkColorComponents(), toVkCompareOp(), toVkCullMode(), toVkFrontFace(), toVkPolygonMode(), toVkShaderStage(), toVkTopology(), QRhiGraphicsPipeline::TriangleStrip, QRhiGraphicsPipeline::UsesBlendConstants, and QRhiGraphicsPipeline::UsesStencilRef.

+ Here is the call graph for this function:

◆ destroy()

void QVkGraphicsPipeline::destroy ( )
overridevirtual

Releases (or requests deferred releasing of) the underlying native graphics resources.

Safe to call multiple times, subsequent invocations will be a no-op then.

Once destroy() is called, the QRhiResource instance can be reused, by calling create() again. That will then result in creating new native graphics resources underneath.

Note
Resources referenced by commands for the current frame should not be released until the frame is submitted by QRhi::endFrame().

The QRhiResource destructor also performs the same task, so calling this function is not necessary before deleting a QRhiResource.

See also
deleteLater()

Implements QRhiResource.

Definition at line 7488 of file qrhivulkan.cpp.

References lastActiveFrameSlot, QRhiVulkan::DeferredReleaseEntry::lastActiveFrameSlot, layout, pipeline, QRhiVulkan::DeferredReleaseEntry::Pipeline, QRhiVulkan::DeferredReleaseEntry::pipelineState, QRHI_RES_RHI, and QRhiVulkan::DeferredReleaseEntry::type.

Referenced by ~QVkGraphicsPipeline(), and create().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QRhiVulkan

friend class QRhiVulkan
friend

Definition at line 294 of file qrhivulkan_p.h.

Member Data Documentation

◆ generation

uint QVkGraphicsPipeline::generation = 0

Definition at line 293 of file qrhivulkan_p.h.

Referenced by create().

◆ lastActiveFrameSlot

int QVkGraphicsPipeline::lastActiveFrameSlot = -1

Definition at line 292 of file qrhivulkan_p.h.

Referenced by create(), and destroy().

◆ layout

VkPipelineLayout QVkGraphicsPipeline::layout = VK_NULL_HANDLE

Definition at line 290 of file qrhivulkan_p.h.

Referenced by create(), and destroy().

◆ pipeline

VkPipeline QVkGraphicsPipeline::pipeline = VK_NULL_HANDLE

Definition at line 291 of file qrhivulkan_p.h.

Referenced by create(), and destroy().


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