1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QT3DRENDER_RENDER_OPENGL_RENDERCOMMAND_H
6#define QT3DRENDER_RENDER_OPENGL_RENDERCOMMAND_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 for the convenience
13// of other Qt classes. 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 <qglobal.h>
20#include <shaderparameterpack_p.h>
21#include <gl_handle_types_p.h>
22#include <Qt3DRender/private/renderviewjobutils_p.h>
23#include <Qt3DCore/private/vector_helper_p.h>
24#include <Qt3DRender/private/handle_types_p.h>
25#include <Qt3DRender/qgeometryrenderer.h>
26#include <QOpenGLShaderProgram>
27#include <QOpenGLTexture>
28#include <QMatrix4x4>
29#include <vector>
30
31QT_BEGIN_NAMESPACE
32
33class QOpenGLVertexArrayObject;
34
35namespace Qt3DRender {
36
37namespace Render {
38
39class RenderStateSet;
40using RenderStateSetPtr = QSharedPointer<RenderStateSet>;
41
42namespace OpenGL {
43
44class GLShader;
45
46class Q_AUTOTEST_EXPORT RenderCommand
47{
48public:
49 RenderCommand();
50
51 HVao m_vao; // VAO used during the submission step to store all states and VBOs
52 HMaterial m_material; // Purely used to ease sorting (minimize stage changes, binding changes ....)
53 GLShader *m_glShader; // GL Shader to be used at render time
54 Qt3DCore::QNodeId m_shaderId; // Shader for given pass and mesh
55 ShaderParameterPack m_parameterPack; // Might need to be reworked so as to be able to destroy the
56 // Texture while submission is happening.
57 RenderStateSetPtr m_stateSet;
58
59 HGeometry m_geometry;
60 HGeometryRenderer m_geometryRenderer;
61
62 HBuffer m_indirectDrawBuffer; // Reference to indirect draw buffer (valid only m_drawIndirect == true)
63 HComputeCommand m_computeCommand;
64
65 // A QAttribute pack might be interesting
66 // This is a temporary fix in the meantime, to remove the hacked methods in Technique
67 std::vector<int> m_activeAttributes;
68
69 float m_depth;
70 int m_changeCost;
71
72 enum CommandType {
73 Draw,
74 Compute
75 };
76
77 CommandType m_type;
78 int m_workGroups[3];
79
80 // Values filled for draw calls by Renderer (in prepare Submission)
81 GLsizei m_primitiveCount;
82 QGeometryRenderer::PrimitiveType m_primitiveType;
83 int m_restartIndexValue;
84 int m_firstInstance;
85 int m_firstVertex;
86 int m_verticesPerPatch;
87 int m_instanceCount;
88 int m_indexOffset;
89 uint m_indexAttributeByteOffset;
90 GLint m_indexAttributeDataType;
91 uint m_indirectAttributeByteOffset;
92 bool m_drawIndexed;
93 bool m_drawIndirect;
94 bool m_primitiveRestartEnabled;
95 bool m_isValid;
96};
97
98Q_AUTOTEST_EXPORT bool operator==(const RenderCommand &a, const RenderCommand &b) noexcept;
99
100inline bool operator!=(const RenderCommand &lhs, const RenderCommand &rhs) noexcept
101{ return !operator==(a: lhs, b: rhs); }
102
103} // namespace OpenGL
104
105} // namespace Render
106
107} // namespace Qt3DRender
108
109QT_END_NAMESPACE
110
111#endif // QT3DRENDER_RENDER_OPENGL_RENDERCOMMAND_H
112

source code of qt3d/src/plugins/renderers/opengl/renderer/rendercommand_p.h