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
QSSGFrameData Class Reference

\inmodule QtQuick3D More...

#include <qssgrenderextensions.h>

Collaboration diagram for QSSGFrameData:

Public Types

enum class  RenderResult : quint32 {
  AoTexture , DepthTexture , ScreenTexture , NormalTexture ,
  MotionVectorTexture
}
enum class  AttachmentSelector : quint32 {
  Attachment0 = 0 , Attachment1 = 1 , Attachment2 = 2 , Attachment3 = 3 ,
  DepthAttachment = 0x8000
}
 Selects an attachment of a \l {QtQuick3D::RenderPass}{RenderPass}. More...
using TypeMask = QSSGRenderGraphObject::TypeT

Public Member Functions

void scheduleRenderResults (RenderResults results) const
 Schedule the given results to be made available for this frame.
QSSGRhiResourceHandle getRhiResource (QSSGResourceId resourceId) const
QSSGRhiResourceHandle getRhiResource (RenderResult idid) const
QSSGRhiResourceHandle getRhiResource (QSSGResourceId userPassId, AttachmentSelector attachmentattachment) const
qsizetype getAttachmentCount (QSSGResourceId userPassId) const
QSSGRhiGraphicsPipelineState getPipelineState () const
QSSGCameraId activeCamera () const
QSSGRenderContextInterface * contextInterface () const
QSSGNodeIdList getLayerNodes (quint32 layerMask, TypeMask typeMask=NodeMask) const
QSSGNodeIdList getLayerNodes (QSSGCameraId cameraId, TypeMask typeMask=NodeMask) const

Static Public Attributes

static constexpr TypeMask NodeMask = QSSGRenderGraphObject::BaseType::Node

Friends

class QSSGLayerRenderData
class QSSGRenderOutputProviderExtension

Detailed Description

\inmodule QtQuick3D

Since
6.7

Storage class containing data collected for a frame.

Definition at line 68 of file qssgrenderextensions.h.

Member Typedef Documentation

◆ TypeMask

Member Enumeration Documentation

◆ AttachmentSelector

Selects an attachment of a \l {QtQuick3D::RenderPass}{RenderPass}.

\value Attachment0 The first color attachment. \value Attachment1 The second color attachment. \value Attachment2 The third color attachment. \value Attachment3 The fourth color attachment. \value [since 6.13] DepthAttachment The depth attachment. This is a texture when the render pass uses a DepthTextureAttachment, otherwise the depth-stencil render buffer.

See also
getRhiResource()
Enumerator
Attachment0 
Attachment1 
Attachment2 
Attachment3 
DepthAttachment 

Definition at line 81 of file qssgrenderextensions.h.

◆ RenderResult

enum class QSSGFrameData::RenderResult : quint32
strong
Enumerator
AoTexture 
DepthTexture 
ScreenTexture 
NormalTexture 
MotionVectorTexture 

Definition at line 71 of file qssgrenderextensions.h.

Member Function Documentation

◆ activeCamera()

QSSGCameraId QSSGFrameData::activeCamera ( ) const
nodiscard
Returns
The active camera for the scene, or null if non could be found.

Definition at line 403 of file qssgrenderextensions.cpp.

◆ contextInterface()

QSSGRenderContextInterface * QSSGFrameData::contextInterface ( ) const
nodiscard

Definition at line 414 of file qssgrenderextensions.cpp.

◆ getAttachmentCount()

qsizetype QSSGFrameData::getAttachmentCount ( QSSGResourceId userPassId) const

Definition at line 128 of file qssgrenderextensions.cpp.

◆ getLayerNodes() [1/2]

QSSGNodeIdList QSSGFrameData::getLayerNodes ( QSSGCameraId cameraId,
TypeMask typeMask = NodeMask ) const
nodiscard
Returns
A list of layer nodes for the given cameraId that match the typeMask. If the camera does not have a layer mask, an empty list is returned.

Definition at line 437 of file qssgrenderextensions.cpp.

◆ getLayerNodes() [2/2]

QSSGNodeIdList QSSGFrameData::getLayerNodes ( quint32 layerMask,
TypeMask typeMask = NodeMask ) const
nodiscard
Returns
A list of layer nodes that match the layerMask and typeMask.

Definition at line 422 of file qssgrenderextensions.cpp.

◆ getPipelineState()

QSSGRhiGraphicsPipelineState QSSGFrameData::getPipelineState ( ) const
nodiscard
Returns
Base pipeline state for this frame

Definition at line 393 of file qssgrenderextensions.cpp.

◆ getRhiResource() [1/3]

QSSGRhiResourceHandle QSSGFrameData::getRhiResource ( QSSGResourceId resourceId) const
nodiscard
Returns
A handle to the RHI resource currently backing the scene resource with the given resourceId, or an invalid handle if there is none.

resourceId identifies the scene resource, a \l {QtQuick3D::ShaderImage}{ShaderImage} or a \l {QtQuick3D::ShaderStorageBuffer}{ShaderStorageBuffer}; use \l QQuick3DExtensionHelpers::getResourceId() to get it. For the attachments of a \l {QtQuick3D::RenderPass}{RenderPass}, use the overload that takes an AttachmentSelector instead. The returned handle refers to the QRhiTexture or QRhiBuffer the renderer created for it, see QSSGRhiResourceHandle::texture() and QSSGRhiResourceHandle::buffer(). The scene resource keeps its id when the renderer replaces that RHI resource, so call this function again rather than storing the result; see \l {QSSGRhiResourceHandle#Scene resources and RHI resources}{Scene resources and RHI resources}.

The resource is shared by every View3D in the window, independent of which one uses it. When called from \l QSSGRenderExtension::prepareData(), the resource is created, or recreated if the scene resource changed, before the handle is returned, so the handle refers to the resource used for the rest of the frame. For a ShaderStorageBuffer, new content from \l {QtQuick3D::ShaderStorageBuffer::bufferData}{bufferData} and a \l {QtQuick3D::ShaderStorageBuffer::requestClear()}{requestClear()} are applied then as well. When called later in the frame, the function only looks up the resource and returns an invalid handle if no pass has used it yet. Pending changes are not applied then, and until a pass uses the resource, it can still have its previous size and content.

If the ShaderStorageBuffer has a \l {QtQuick3D::ShaderStorageBuffer::bufferProvider}{buffer provider} that has registered a buffer with \l QSSGRenderExtensionHelpers::registerRenderResultBuffer(), the handle refers to that buffer. It becomes invalid when the provider registers a different buffer, unregisters it or is destroyed. How long the buffer itself lives depends on its \l {QSSGRenderExtensionHelpers::ResultOwnership}{ownership}.

The handle does not keep the resource alive. Check QSSGRhiResourceHandle::isValid() before using a handle kept from an earlier frame, and compare it with the result of a new call to find out whether the resource has been replaced.

Note
The content of the resource is only what the passes using it have written so far. To see what a ComputePass in the same View3D wrote this frame, read the resource from an extension that runs after the user passes, such as one with the Main \l {QSSGRenderExtension::RenderMode}{render mode} and the PostColor \l {QSSGRenderExtension::RenderStage}{render stage}. The order in which different View3Ds are rendered is not defined.
Since
6.13
See also
QSSGRhiResourceHandle

Definition at line 339 of file qssgrenderextensions.cpp.

◆ getRhiResource() [2/3]

QSSGRhiResourceHandle QSSGFrameData::getRhiResource ( QSSGResourceId userPassId,
AttachmentSelector attachment ) const
nodiscard
Returns
A handle to the attachment of the \l {QtQuick3D::RenderPass}{RenderPass} with the given userPassId, or an invalid handle if the render pass has no such attachment.

For a color attachment, QSSGRhiResourceHandle::texture() returns the texture. For \l {QSSGFrameData::AttachmentSelector}{DepthAttachment}, the handle refers to a texture if the render pass has a DepthTextureAttachment, and to a render buffer, returned by QSSGRhiResourceHandle::renderBuffer(), otherwise.

The handle can be kept across frames. It becomes invalid when the render pass replaces the attachment, for example when the size of the View3D changes, or when the render pass is destroyed. Compare it with the result of a new call to find out whether the attachment has changed, see QSSGRhiResourceHandle.

Since
6.13
See also
getAttachmentCount(), QSSGRhiResourceHandle

Definition at line 264 of file qssgrenderextensions.cpp.

◆ getRhiResource() [3/3]

QSSGRhiResourceHandle QSSGFrameData::getRhiResource ( RenderResult id) const
nodiscard
Returns
A handle to the texture of the render result id, or an invalid handle if the result is not produced in the current frame.

The renderer only produces the results that something in the frame needs, so request the result with scheduleRenderResults() during \l QSSGRenderExtension::prepareData(), in every frame it is needed, and before calling this function. The texture contains the result once the pass producing it has run, so it is typically read by an extension with the Main \l {QSSGRenderExtension::RenderMode}{render mode}.

The handle can be kept across frames. The renderer can replace or rebuild the texture, for example when the size of the View3D changes, and can release it once the result is no longer produced. The handle then becomes invalid, so compare it with the result of a new call to find out whether the texture has changed, see QSSGRhiResourceHandle. In a frame where the result is not produced, this function returns an invalid handle even if a handle kept from an earlier frame is still valid, and the content of the texture is undefined.

Since
6.13
See also
scheduleRenderResults(), QSSGRhiResourceHandle

Definition at line 223 of file qssgrenderextensions.cpp.

◆ scheduleRenderResults()

void QSSGFrameData::scheduleRenderResults ( RenderResults results) const

Schedule the given results to be made available for this frame.

This function should only be called during the prepare phase in \l QSSGRenderExtension::prepareData().

Note
The requested results might not be available if the underlying layer does not support them or if the layer does not contain any data that would make it necessary to produce the requested results, in which case \l getRhiResource() returns an invalid handle.
See also
getRhiResource()

Definition at line 102 of file qssgrenderextensions.cpp.

◆ QSSGLayerRenderData

friend class QSSGLayerRenderData
friend

Definition at line 131 of file qssgrenderextensions.h.

◆ QSSGRenderOutputProviderExtension

friend class QSSGRenderOutputProviderExtension
friend

Definition at line 132 of file qssgrenderextensions.h.

Member Data Documentation

◆ NodeMask

TypeMask QSSGFrameData::NodeMask = QSSGRenderGraphObject::BaseType::Node
staticconstexpr

Definition at line 102 of file qssgrenderextensions.h.


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