1// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DRENDER_RENDER_RHI_SHADERVARIABLES_P_H
5#define QT3DRENDER_RENDER_RHI_SHADERVARIABLES_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <Qt3DRender/qt3drender_global.h>
19#include <QtGui/private/qshaderdescription_p.h>
20#include <QOpenGLContext>
21
22QT_BEGIN_NAMESPACE
23
24namespace Qt3DRender {
25
26namespace Render {
27
28namespace Rhi {
29
30struct ShaderAttribute
31{
32 QString m_name;
33 int m_nameId { -1 };
34 QShaderDescription::VariableType m_type {};
35 int m_size {};
36 int m_location { -1 };
37};
38QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderAttribute, Q_RELOCATABLE_TYPE)
39
40struct ShaderUniform
41{
42 QString m_name;
43 int m_nameId { -1 };
44 QShaderDescription::VariableType m_type { QShaderDescription::Unknown };
45 int m_size { 0 };
46 int m_offset { -1 }; // -1 default, >= 0 if uniform defined in uniform block
47 int m_location { -1 }; // -1 if uniform defined in a uniform block
48 int m_blockIndex { -1 }; // -1 is the default, >= 0 if uniform defined in uniform block
49 int m_arrayStride {
50 -1
51 }; // -1 is the default, >= 0 if uniform defined in uniform block and if it's an array
52 int m_matrixStride {
53 -1
54 }; // -1 is the default, >= 0 uniform defined in uniform block and is a matrix
55 uint m_rawByteSize { 0 }; // contains byte size (size / type / strides)
56 // size, offset and strides are in bytes
57};
58QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderUniform, Q_RELOCATABLE_TYPE)
59
60struct ShaderUniformBlock
61{
62 QString m_name;
63 int m_nameId { -1 };
64 int m_index { -1 };
65 int m_binding { -1 };
66 int m_activeUniformsCount { 0 };
67 int m_size { 0 };
68};
69QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderUniformBlock, Q_RELOCATABLE_TYPE)
70
71struct ShaderStorageBlock
72{
73 QString m_name;
74 int m_nameId { -1 };
75 int m_index { -1 };
76 int m_binding { -1 };
77 int m_size { 0 };
78 int m_activeVariablesCount { 0 };
79};
80QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, Rhi, ShaderStorageBlock, Q_RELOCATABLE_TYPE)
81
82} // namespace Rhi
83
84} // namespace Render
85
86} // namespace Qt3DRender
87
88QT_END_NAMESPACE
89
90#endif // QT3DRENDER_RENDER_RHI_SHADERVARIABLES_P_H
91

source code of qt3d/src/plugins/renderers/rhi/renderer/shadervariables_p.h