Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qssgrhiresourcehandle_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QSSGRHIRESOURCEHANDLE_P_H
6
#
define
QSSGRHIRESOURCEHANDLE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
ssg
/
qssgrenderextensions
.
h
>
20
21
#
include
<
QtCore
/
qhash
.
h
>
22
23
QT_BEGIN_NAMESPACE
24
25
class
QRhiResource;
26
27
// The engine side record a QSSGRhiResourceHandle observes. There is one record
28
// per RHI resource, owned by a QSSGRhiResourceRegistry, and the registry
29
// invalidates it when the resource is retired. The record keeps the id of the
30
// resource after that, so a stale handle can still be compared with a fresh
31
// one. Render thread only.
32
class
Q_QUICK3DRUNTIMERENDER_EXPORT
QSSGRhiResourceHandlePrivate
:
public
QSharedData
33
{
34
public
:
35
explicit
QSSGRhiResourceHandlePrivate(QRhiTexture *texture);
36
explicit
QSSGRhiResourceHandlePrivate(QRhiBuffer *buffer);
37
explicit
QSSGRhiResourceHandlePrivate(QRhiRenderBuffer *renderBuffer);
38
39
[[nodiscard]] QSSGRhiResourceHandle handle() {
return
QSSGRhiResourceHandle(
this
); }
40
41
void
invalidate()
noexcept
42
{
43
texture =
nullptr
;
44
buffer =
nullptr
;
45
renderBuffer =
nullptr
;
46
}
47
48
QRhiTexture *texture =
nullptr
;
49
QRhiBuffer *buffer =
nullptr
;
50
QRhiRenderBuffer *renderBuffer =
nullptr
;
51
quint64 id = 0;
52
};
53
54
// Maps live RHI resources to the records handed out for them. Records are only
55
// created when a handle is requested, so retiring a resource nobody asked for
56
// is a hash lookup.
57
class
Q_QUICK3DRUNTIMERENDER_EXPORT
QSSGRhiResourceRegistry
58
{
59
public
:
60
// The registry checks that it is used on the thread of the rhi.
61
explicit
QSSGRhiResourceRegistry(QRhi *rhi) : m_rhi(rhi) {}
62
~QSSGRhiResourceRegistry();
63
Q_DISABLE_COPY_MOVE(QSSGRhiResourceRegistry)
64
65
[[nodiscard]] QSSGRhiResourceHandle handle(QRhiTexture *texture);
66
[[nodiscard]] QSSGRhiResourceHandle handle(QRhiBuffer *buffer);
67
[[nodiscard]] QSSGRhiResourceHandle handle(QRhiRenderBuffer *renderBuffer);
68
69
// Must be called before the resource is released or replaced. Does not
70
// dereference the resource, so it may already have been deleted.
71
void
retire(
const
QRhiResource *resource);
72
// Retires the record at the address of the resource if it belongs to a
73
// resource that was destroyed without being retired, and whose address
74
// the given resource now reuses. The resource must be alive.
75
void
retireIfReplaced(
const
QRhiResource *resource);
76
void
retireAll();
77
78
// Whether a handle has been given out for the resource and the resource
79
// has not been retired since.
80
[[nodiscard]]
bool
contains(
const
QRhiResource *resource)
const
{
return
m_records.contains(resource); }
81
82
private
:
83
template
<
typename
T>
84
QSSGRhiResourceHandle handleImpl(T *resource);
85
86
QHash<
const
QRhiResource *, QExplicitlySharedDataPointer<QSSGRhiResourceHandlePrivate>> m_records;
87
QRhi *m_rhi =
nullptr
;
88
};
89
90
QT_END_NAMESPACE
91
92
#
endif
// QSSGRHIRESOURCEHANDLE_P_H
QSSGFrameData
\inmodule QtQuick3D
Definition
qssgrenderextensions.h:69
QSSGRenderContextInterface::QSSGLayerRenderData
friend class QSSGLayerRenderData
Definition
qssgrendercontextcore.h:80
QSSGRenderExtension
\inmodule QtQuick3D
Definition
qssgrenderextensions.h:146
QSSGRenderTextureProviderExtension
\inmodule QtQuick3D
Definition
qssgrenderextensions.h:177
QSSGRenderer::QSSGRenderContextInterface
friend class QSSGRenderContextInterface
Definition
qssgrenderer_p.h:105
QSSGRhiResourceHandlePrivate
Definition
qssgrhiresourcehandle_p.h:33
QSSGRhiResourceHandle
\inmodule QtQuick3D
Definition
qssgrenderextensions.h:37
QSSGRhiResourceRegistry
Definition
qssgrhiresourcehandle_p.h:58
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
resourceRegistry
static QSSGRhiResourceRegistry & resourceRegistry(const QSSGRenderContextInterface &ctx)
Definition
qssgrenderextensions.cpp:42
isRenderResultRequired
static bool isRenderResultRequired(const QSSGLayerRenderPreparationResultFlags &flags, QSSGFrameData::RenderResult id)
Definition
qssgrenderextensions.cpp:182
userPassRenderTarget
static QSSGRhiRenderableTextureV2Ptr userPassRenderTarget(const QSSGRenderContextInterface &ctx, QSSGResourceId userPassId)
Definition
qssgrenderextensions.cpp:49
qtquick3d
src
runtimerender
extensionapi
qssgrhiresourcehandle_p.h
Generated on
for Qt by
1.18.0