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
qssgshadermapkey_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 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 QSSGSHADERMAPKEY_P_H
8#define QSSGSHADERMAPKEY_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 <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrendershaderkeys_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderparticleshaderkeys_p.h>
24#include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h>
25
27
28template <typename T>
29struct TShaderMapKey
30{
31 QByteArray m_name;
32 const QSSGShaderFeatures m_featuresOrig;
33 const T *m_materialKeyOrig;
34 T m_materialKeyCopy;
35 size_t m_hashCode;
36
37 void detach()
38 {
39 if (m_materialKeyOrig) {
40 m_materialKeyCopy = *m_materialKeyOrig;
41 m_materialKeyOrig = nullptr;
42 }
43 }
44
45 TShaderMapKey(const QByteArray &inName,
46 const QSSGShaderFeatures &inFeatures,
47 const T &inMaterialKey)
48 : m_name(inName), m_featuresOrig(inFeatures), m_materialKeyOrig(&inMaterialKey)
49 {
50 m_hashCode = qHash(m_name) ^ qHash(m_featuresOrig) ^ qHash(m_materialKeyOrig->hash());
51 }
52};
53template <typename T>
54inline bool operator==(const TShaderMapKey<T> &a, const TShaderMapKey<T> &b) Q_DECL_NOTHROW
55{
56 if (a.m_name != b.m_name)
57 return false;
58
59 const T *keyA = a.m_materialKeyOrig ? a.m_materialKeyOrig : &a.m_materialKeyCopy;
60 const T *keyB = b.m_materialKeyOrig ? b.m_materialKeyOrig : &b.m_materialKeyCopy;
61 if (!(*keyA == *keyB))
62 return false;
63
64 return (a.m_featuresOrig == b.m_featuresOrig);
65}
66
67typedef TShaderMapKey<QSSGShaderDefaultMaterialKey> QSSGShaderMapKey;
69
70inline size_t qHash(const QSSGShaderMapKey &key, size_t seed)
71{
72 return key.m_hashCode ^ seed;
73}
74
75inline size_t qHash(const QSSGParticleShaderMapKey &key, size_t seed)
76{
77 return key.m_hashCode ^ seed;
78}
79
80QT_END_NAMESPACE
81
82#endif
friend class QSSGRenderContextInterface
Combined button and popup list for selecting options.
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192
static void cleanupResourcesImpl(const QSSGRenderContextInterface &rci, const Container &resources)
static void getPickableRecursive(const QSSGRenderNode &node, RenderableList &renderables, bool pickEverything=false)
static void dfs(const QSSGRenderNode &node, RenderableList &renderables)
static QByteArray rendererLogPrefix()
TShaderMapKey< QSSGShaderParticleMaterialKey > QSSGParticleShaderMapKey