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
qssgrendergraphobject_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2023 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6
7#ifndef QSSGRENDERGRAPHOBJECT_P_H
8#define QSSGRENDERGRAPHOBJECT_P_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <ssg/qssgrendergraphobject.h>
22
23#include <ssg/qssgrenderbasetypes.h>
24
25#include <QtQuick3DUtils/private/qssgassert_p.h>
26
28
30{
32};
33
34constexpr QSSGResourceId getResourceId(const QSSGRenderGraphObject &o)
35{
36 QSSG_ASSERT(QSSGRenderGraphObject::isResource(o.type), return QSSGResourceId::Invalid);
37 return QSSGResourceId{ quintptr(&o) };
38}
39
40template <typename T = QSSGRenderGraphObject>
41T *getResource(QSSGResourceId resId)
42{
43 return static_cast<T *>(reinterpret_cast<QSSGRenderGraphObject *>(resId));
44}
45
46constexpr QSSGNodeId getNodeId(const QSSGRenderGraphObject &o)
47{
48 QSSG_ASSERT(QSSGRenderGraphObject::isNodeType(o.type), return QSSGNodeId::Invalid);
49 return QSSGNodeId{ quintptr(&o) };
50}
51
52template <typename T = QSSGRenderGraphObject>
53T *getNode(QSSGNodeId nodeId)
54{
55 return static_cast<T *>(reinterpret_cast<QSSGRenderGraphObject *>(nodeId));
56}
57
58constexpr QSSGCameraId getCameraId(const QSSGRenderGraphObject &o)
59{
60 QSSG_ASSERT(QSSGRenderGraphObject::isCamera(o.type), return QSSGCameraId::Invalid);
61 return QSSGCameraId{ quintptr(&o) };
62}
63
64template <typename T = QSSGRenderGraphObject>
65T *getCamera(QSSGCameraId cameraId)
66{
67 return static_cast<T *>(reinterpret_cast<QSSGRenderGraphObject *>(cameraId));
68}
69
70constexpr QSSGExtensionId getExtensionId(const QSSGRenderGraphObject &o)
71{
72 QSSG_ASSERT(QSSGRenderGraphObject::isExtension(o.type), return QSSGExtensionId::Invalid);
73 return QSSGExtensionId{ quintptr(&o) };
74}
75
76template <typename T = QSSGRenderGraphObject>
77T *getExtension(QSSGExtensionId extensionId)
78{
79 return static_cast<T *>(reinterpret_cast<QSSGRenderGraphObject *>(extensionId));
80}
81
82template <typename QSSGTypeId>
83constexpr bool isNull(QSSGTypeId id) { return (id == QSSGTypeId::Invalid); }
84
85[[nodiscard]] static constexpr QSSGRenderGraphObject::BaseType getBaseType(QSSGRenderGraphObject::Type type) noexcept
86{
87 constexpr auto BaseTypeMask = QSSGRenderGraphObject::TypeT(~0xFFF);
88 return static_cast<QSSGRenderGraphObject::BaseType>(QSSGRenderGraphObject::TypeT(type) & BaseTypeMask);
89}
90
91// The TextureProvider type is not a BaseType but it's a special type of Extension that is user
92// facing and requires special handling in some places, so we keep this helper here for convenience.
93[[nodiscard]] static constexpr bool isTextureProvider(QSSGRenderGraphObject::Type type) noexcept
94{
95 return (QSSGRenderGraphObject::TypeT(type) & QSSGRenderGraphObject::TypeT(QSSGRenderGraphObject::Type::TextureProvider));
96}
97
98// A scene root is a special node that acts as the root of a single viewport's part of the scene graph.
99[[nodiscard]] static constexpr bool isSceneRoot(QSSGRenderGraphObject::Type type) noexcept
100{
101 return (type == QSSGRenderGraphObject::Type::SceneRoot);
102}
103
104[[nodiscard]] static constexpr bool isUserRenderPass(QSSGRenderGraphObject::Type type) noexcept
105{
106 return (type == QSSGRenderGraphObject::Type::RenderPass);
107}
108
109[[nodiscard]] static constexpr bool hasInternalFlags(const QSSGRenderGraphObject &obj)
110{
111 return (obj.flags & QSSGRenderGraphObject::FlagT(QSSGRenderGraphObject::Flags::InternallyReserved));
112}
113
114[[nodiscard]] static constexpr bool hasInternalFlag(const QSSGRenderGraphObject &obj, InternalFlags flag)
115{
116 return (obj.flags & QSSGRenderGraphObject::FlagT(flag));
117
118}
119
120} // namespace QSSGRenderGraphObjectUtils
121
122#endif // QSSGRENDERGRAPHOBJECT_P_H
constexpr QSSGCameraId getCameraId(const QSSGRenderGraphObject &o)
constexpr QSSGResourceId getResourceId(const QSSGRenderGraphObject &o)
T * getExtension(QSSGExtensionId extensionId)
static constexpr bool isSceneRoot(QSSGRenderGraphObject::Type type) noexcept
T * getResource(QSSGResourceId resId)
static constexpr bool isUserRenderPass(QSSGRenderGraphObject::Type type) noexcept
constexpr QSSGExtensionId getExtensionId(const QSSGRenderGraphObject &o)
static constexpr bool hasInternalFlag(const QSSGRenderGraphObject &obj, InternalFlags flag)
constexpr bool isNull(QSSGTypeId id)
static constexpr bool hasInternalFlags(const QSSGRenderGraphObject &obj)
T * getCamera(QSSGCameraId cameraId)
static constexpr bool isTextureProvider(QSSGRenderGraphObject::Type type) noexcept
constexpr QSSGNodeId getNodeId(const QSSGRenderGraphObject &o)
static constexpr QSSGRenderGraphObject::BaseType getBaseType(QSSGRenderGraphObject::Type type) noexcept
Combined button and popup list for selecting options.
Q_QUICK3DRUNTIMERENDER_EXPORT void setStatusCallback(StatusCallback cb)
void(*)(const QByteArray &descKey, Status status, const QString &err, QShader::Stage stage) StatusCallback
Q_QUICK3DRUNTIMERENDER_EXPORT void setAutomaticDiskCache(bool enable)
Q_QUICK3DRUNTIMERENDER_EXPORT bool isAutomaticDiskCacheEnabled()
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)
static QString persistentQsbcFileName()
static bool isAutoDiskCacheEnabled()
size_t qHash(QSSGShaderFeatures features) noexcept
static bool ensureWritableDir(const QString &name)
static bool s_autoDiskCacheEnabled
static QString dumpFilename(QShader::Stage stage)
static QString persistentQsbcDir()
static void initBakerForNonPersistentUse(QShaderBaker *, QRhi *)
static constexpr DefineEntry DefineTable[]