Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QVkRenderPassDescriptor Struct Reference

#include <qrhivulkan_p.h>

Inheritance diagram for QVkRenderPassDescriptor:
Collaboration diagram for QVkRenderPassDescriptor:

Public Member Functions

 QVkRenderPassDescriptor (QRhiImplementation *rhi)
 ~QVkRenderPassDescriptor ()
void destroy () override
 Releases (or requests deferred releasing of) the underlying native graphics resources.
bool isCompatible (const QRhiRenderPassDescriptor *other) const override
QRhiRenderPassDescriptornewCompatibleRenderPassDescriptor () const override
QVector< quint32serializedFormat () const override
const QRhiNativeHandlesnativeHandles () override
void updateSerializedFormat ()
Public Member Functions inherited from QRhiRenderPassDescriptor
QRhiResource::Type resourceType () const override
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

VkRenderPass rp = VK_NULL_HANDLE
bool ownsRp = false
QVarLengthArray< VkAttachmentDescription, 8 > attDescs
QVarLengthArray< VkAttachmentReference, 8 > colorRefs
QVarLengthArray< VkAttachmentReference, 8 > resolveRefs
QVarLengthArray< VkSubpassDependency, 2 > subpassDeps
bool hasDepthStencil = false
bool hasDepthStencilResolve = false
bool hasShadingRateMap = false
uint32_t multiViewCount = 0
VkAttachmentReference dsRef
VkAttachmentReference dsResolveRef
VkAttachmentReference shadingRateRef
QVector< quint32serializedFormatData
QRhiVulkanRenderPassNativeHandles nativeHandlesStruct
int lastActiveFrameSlot = -1

Additional Inherited Members

Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer ,
  ShadingRateMap
}
 Specifies type of the resource. More...
Protected Member Functions inherited from QRhiRenderPassDescriptor
 QRhiRenderPassDescriptor (QRhiImplementation *rhi)
Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)
Protected Attributes inherited from QRhiResource
QRhiImplementationm_rhi = nullptr
quint64 m_id
QByteArray m_objectName

Detailed Description

Definition at line 163 of file qrhivulkan_p.h.

Constructor & Destructor Documentation

◆ QVkRenderPassDescriptor()

QVkRenderPassDescriptor::QVkRenderPassDescriptor ( QRhiImplementation * rhi)

Definition at line 7450 of file qrhivulkan.cpp.

References QVkRenderPassDescriptor().

Referenced by QVkRenderPassDescriptor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~QVkRenderPassDescriptor()

QVkRenderPassDescriptor::~QVkRenderPassDescriptor ( )

Definition at line 7456 of file qrhivulkan.cpp.

References destroy().

Here is the call graph for this function:

Member Function Documentation

◆ destroy()

void QVkRenderPassDescriptor::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 7461 of file qrhivulkan.cpp.

References QRhiVulkan::DeferredReleaseEntry::lastActiveFrameSlot, lastActiveFrameSlot, ownsRp, QRhiVulkan::DeferredReleaseEntry::RenderPass, and QRhiVulkan::DeferredReleaseEntry::type.

Referenced by ~QVkRenderPassDescriptor().

Here is the caller graph for this function:

◆ isCompatible()

bool QVkRenderPassDescriptor::isCompatible ( const QRhiRenderPassDescriptor * other) const
overridevirtual
Returns
true if the other QRhiRenderPassDescriptor is compatible with this one, meaning this and other can be used interchangebly in QRhiGraphicsPipeline::setRenderPassDescriptor().

The concept of the compatibility of renderpass descriptors is similar to the \l{QRhiShaderResourceBindings::isLayoutCompatible}{layout compatibility} of QRhiShaderResourceBindings instances. They allow better reuse of QRhiGraphicsPipeline instances: for example, a QRhiGraphicsPipeline instance cache is expected to use these functions to look for a matching pipeline, instead of just comparing pointers, thus allowing a different QRhiRenderPassDescriptor and QRhiShaderResourceBindings to be used in combination with the pipeline, as long as they are compatible.

The exact details of compatibility depend on the underlying graphics API. Two renderpass descriptors \l{QRhiTextureRenderTarget::newCompatibleRenderPassDescriptor()}{created} from the same QRhiTextureRenderTarget are always compatible.

Similarly to QRhiShaderResourceBindings, compatibility can also be tested without having two existing objects available. Extracting the opaque blob by calling serializedFormat() allows testing for compatibility by comparing the returned vector to another QRhiRenderPassDescriptor's serializedFormat(). This has benefits in certain situations, because it allows testing the compatibility of a QRhiRenderPassDescriptor with a QRhiGraphicsPipeline even when the QRhiRenderPassDescriptor the pipeline was originally built was is no longer available (but the data returned from its serializedFormat() still is).

See also
newCompatibleRenderPassDescriptor(), serializedFormat()

Implements QRhiRenderPassDescriptor.

Definition at line 7498 of file qrhivulkan.cpp.

References hasDepthStencil, hasDepthStencilResolve, and hasShadingRateMap.

◆ nativeHandles()

const QRhiNativeHandles * QVkRenderPassDescriptor::nativeHandles ( )
overridevirtual
Returns
a pointer to a backend-specific QRhiNativeHandles subclass, such as QRhiVulkanRenderPassNativeHandles. The returned value is \nullptr when exposing the underlying native resources is not supported by the backend.
See also
QRhiVulkanRenderPassNativeHandles

Reimplemented from QRhiRenderPassDescriptor.

Definition at line 7689 of file qrhivulkan.cpp.

◆ newCompatibleRenderPassDescriptor()

QRhiRenderPassDescriptor * QVkRenderPassDescriptor::newCompatibleRenderPassDescriptor ( ) const
overridevirtual
Returns
a new QRhiRenderPassDescriptor that is \l{isCompatible()}{compatible} with this one.

This function allows cloning a QRhiRenderPassDescriptor. The returned object is ready to be used, and the ownership is transferred to the caller. Cloning a QRhiRenderPassDescriptor object can become useful in situations where the object is stored in data structures related to graphics pipelines (in order to allow creating new pipelines which in turn requires a renderpass descriptor object), and the lifetime of the renderpass descriptor created from a render target may be shorter than the pipelines. (for example, because the engine manages and destroys renderpasses together with the textures and render targets it was created from) In such a situation, it can be beneficial to store a cloned version in the data structures, and thus transferring ownership as well.

See also
isCompatible()

Implements QRhiRenderPassDescriptor.

Definition at line 7625 of file qrhivulkan.cpp.

References QRhiVulkan::df, hasDepthStencil, hasDepthStencilResolve, hasShadingRateMap, ownsRp, and updateSerializedFormat().

Here is the call graph for this function:

◆ serializedFormat()

QVector< quint32 > QVkRenderPassDescriptor::serializedFormat ( ) const
overridevirtual
Returns
a vector of integers containing an opaque blob describing the data relevant for \l{isCompatible()}{compatibility}.

Given two QRhiRenderPassDescriptor objects rp1 and rp2, if the data returned from this function is identical, then {rp1->isCompatible(rp2)}, and vice versa hold true as well.

Note
The returned data is meant to be used for storing in memory and comparisons during the lifetime of the QRhi the object belongs to. It is not meant for storing on disk, reusing between processes, or using with multiple QRhi instances with potentially different backends.
Calling this function is expected to be a cheap operation since the backends are not supposed to calculate the data in this function, but rather return an already calculated series of data.

When creating reusable components as part of a library, where graphics pipelines are created and maintained while targeting a QRhiRenderTarget (be it a swapchain or a texture) managed by the client of the library, the components must be able to deal with a changing QRhiRenderPassDescriptor. For example, because the render target changes and so invalidates the previously QRhiRenderPassDescriptor (with regards to the new render target at least) due to having a potentially different color format and attachments now. Or because \l{QRhiShadingRateMap}{variable rate shading} is taken into use dynamically. A simple pattern that helps dealing with this is performing the following check on every frame, to recognize the case when the pipeline needs to be associated with a new QRhiRenderPassDescriptor, because something is different about the render target now, compared to earlier frames:

QRhiRenderPassDescriptor *rp = m_renderTarget->renderPassDescriptor();
if (m_pipeline && rp->serializedFormat() != m_renderPassFormat) {
m_pipeline->setRenderPassDescriptor(rp);
m_renderPassFormat = rp->serializedFormat();
m_pipeline->create();
}
// remember to store m_renderPassFormat also when creating m_pipeline the first time
QRhiRenderPassDescriptor(QRhiImplementation *rhi)
Definition qrhi.cpp:5147
See also
isCompatible()

Implements QRhiRenderPassDescriptor.

Definition at line 7684 of file qrhivulkan.cpp.

◆ updateSerializedFormat()

void QVkRenderPassDescriptor::updateSerializedFormat ( )

Definition at line 7568 of file qrhivulkan.cpp.

References hasDepthStencil, hasDepthStencilResolve, and hasShadingRateMap.

Referenced by newCompatibleRenderPassDescriptor(), QVkSwapChain::newCompatibleRenderPassDescriptor(), and QVkTextureRenderTarget::newCompatibleRenderPassDescriptor().

Here is the caller graph for this function:

Member Data Documentation

◆ attDescs

QVarLengthArray<VkAttachmentDescription, 8> QVkRenderPassDescriptor::attDescs

Definition at line 177 of file qrhivulkan_p.h.

◆ colorRefs

QVarLengthArray<VkAttachmentReference, 8> QVkRenderPassDescriptor::colorRefs

Definition at line 178 of file qrhivulkan_p.h.

◆ dsRef

VkAttachmentReference QVkRenderPassDescriptor::dsRef

Definition at line 185 of file qrhivulkan_p.h.

◆ dsResolveRef

VkAttachmentReference QVkRenderPassDescriptor::dsResolveRef

Definition at line 186 of file qrhivulkan_p.h.

◆ hasDepthStencil

◆ hasDepthStencilResolve

bool QVkRenderPassDescriptor::hasDepthStencilResolve = false

◆ hasShadingRateMap

bool QVkRenderPassDescriptor::hasShadingRateMap = false

◆ lastActiveFrameSlot

int QVkRenderPassDescriptor::lastActiveFrameSlot = -1

Definition at line 190 of file qrhivulkan_p.h.

Referenced by destroy().

◆ multiViewCount

uint32_t QVkRenderPassDescriptor::multiViewCount = 0

Definition at line 184 of file qrhivulkan_p.h.

◆ nativeHandlesStruct

QRhiVulkanRenderPassNativeHandles QVkRenderPassDescriptor::nativeHandlesStruct

Definition at line 189 of file qrhivulkan_p.h.

◆ ownsRp

◆ resolveRefs

QVarLengthArray<VkAttachmentReference, 8> QVkRenderPassDescriptor::resolveRefs

Definition at line 179 of file qrhivulkan_p.h.

◆ rp

VkRenderPass QVkRenderPassDescriptor::rp = VK_NULL_HANDLE

Definition at line 175 of file qrhivulkan_p.h.

◆ serializedFormatData

QVector<quint32> QVkRenderPassDescriptor::serializedFormatData

Definition at line 188 of file qrhivulkan_p.h.

◆ shadingRateRef

VkAttachmentReference QVkRenderPassDescriptor::shadingRateRef

Definition at line 187 of file qrhivulkan_p.h.

◆ subpassDeps

QVarLengthArray<VkSubpassDependency, 2> QVkRenderPassDescriptor::subpassDeps

Definition at line 180 of file qrhivulkan_p.h.


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