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
qssgrenderparticleshaderkeys_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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
6#ifndef QSSG_RENDER_PARTICLE_SHADER_KEY_H
7#define QSSG_RENDER_PARTICLE_SHADER_KEY_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
21
23
25{
36
38 : m_isSpriteLinear("isSpriteLinear")
39 , m_isColorTableLinear("isColorTableLinear")
40 , m_hasLighting("hasLighting")
41 , m_isLineParticle("isLineParticle")
42 , m_isMapped("isMapped")
43 , m_isAnimated("isAnimated")
44 , m_oitMSAA("oitMSAA")
45 , m_viewCount("viewCount")
46 , m_orderIndependentTransparency("orderIndependentTransparency")
47 {
48 init();
49 }
50
51 template<typename TVisitor>
52 void visitProperties(TVisitor &inVisitor)
53 {
54 inVisitor.visit(m_isSpriteLinear);
55 inVisitor.visit(m_isColorTableLinear);
56 inVisitor.visit(m_hasLighting);
57 inVisitor.visit(m_isLineParticle);
58 inVisitor.visit(m_isMapped);
59 inVisitor.visit(m_isAnimated);
60 inVisitor.visit(m_oitMSAA);
61 inVisitor.visit(m_viewCount);
62 inVisitor.visit(m_orderIndependentTransparency);
63 }
64
66 {
69 template<typename TPropType>
70 void visit(TPropType &inProp)
71 {
72 // if we cross the 32 bit border we just move
73 // to the next dword.
74 // This cost a few extra bits but prevents tedious errors like
75 // loosing shader key bits because they got moved beyond the 32 border
76 quint32 bit = m_offset % 32;
77 if (bit + TPropType::BitWidth > 32) {
78 m_offset += 32 - bit;
79 }
80
81 inProp.setOffset(m_offset);
82 m_offset += TPropType::BitWidth;
83 }
84 };
85
87 {
89 template<typename P>
90 constexpr void visit(const P &prop)
91 {
92 size += prop.name.size();
93 }
94 };
95
97 {
100
101 template<typename P>
102 void visit(P &prop)
103 {
104 offsetVisitor.visit(prop);
105 stringSizeVisitor.visit(prop);
106 }
107 };
108
109 void init()
110 {
111 InitVisitor visitor;
112 visitProperties(visitor);
113
114 // If this assert fires, then the material key needs more bits.
115 Q_ASSERT(visitor.offsetVisitor.m_offset < 32);
116 // This is so we can do some guestimate of how big the string buffer needs
117 // to be to avoid doing a lot of allocations when concatenating the strings.
118 m_stringBufferSizeHint = visitor.stringSizeVisitor.size;
119 }
120};
121
123
124Q_STATIC_ASSERT(std::is_trivially_destructible<QSSGShaderParticleMaterialKey>::value);
125
127{
128 return key.hash();
129}
130
131QT_END_NAMESPACE
132
133#endif
Combined button and popup list for selecting options.
QSSGShaderBaseMaterialKey< QSSGShaderParticleMaterialKeyProperties, 1 > QSSGShaderParticleMaterialKey
size_t qHash(const QSSGShaderParticleMaterialKey &key)