1 | // Copyright (C) 2015 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 | #include "qdispatchcompute.h" |
5 | #include "qdispatchcompute_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace Qt3DRender { |
10 | /*! |
11 | \class Qt3DRender::QDispatchCompute |
12 | \inmodule Qt3DRender |
13 | \since 5.7 |
14 | \ingroup framegraph |
15 | \brief FrameGraph node to issue work for the compute shader on GPU. |
16 | |
17 | A Qt3DRender::QDispatchCompute allows work to be issued for the compute shader to |
18 | run on the GPU. The workGroupX, workGroupY and workGroupZ properties specify the work group |
19 | sizes for the compute shader invocation. QComputeCommand components need to be added |
20 | to entities to instruct Qt3D to select the materials and geometry from the entities |
21 | for the compute invocation. The work group sizes for the shader invocation will be |
22 | the maximum of the work group sizes specified in QDispatchCompute and QComputeCommand. |
23 | |
24 | */ |
25 | |
26 | /*! |
27 | \qmltype DispatchCompute |
28 | \inqmlmodule Qt3D.Render |
29 | \instantiates Qt3DRender::QDispatchCompute |
30 | \inherits FrameGraphNode |
31 | \since 5.7 |
32 | \brief FrameGraph node to issue work for the compute shader on GPU. |
33 | |
34 | A DispatchCompute allows work to be issued for the compute shader to run on the GPU. |
35 | The workGroupX, workGroupY and workGroupZ properties specify the work group sizes for |
36 | the compute shader invocation. ComputeCommand components need to be added |
37 | to entities to instruct Qt3D to select the materials and geometry from the entities |
38 | for the compute invocation. The work group sizes for the shader invocation will be |
39 | the maximum of the work group sizes specified in DispatchCompute and ComputeCommand. |
40 | */ |
41 | |
42 | /*! |
43 | \qmlproperty int DispatchCompute::workGroupX |
44 | Specifies X workgroup size. |
45 | */ |
46 | |
47 | /*! |
48 | \qmlproperty int DispatchCompute::workGroupY |
49 | Specifies Y workgroup size. |
50 | */ |
51 | |
52 | /*! |
53 | \qmlproperty int DispatchCompute::workGroupZ |
54 | Specifies Z workgroup size. |
55 | */ |
56 | |
57 | /*! |
58 | The constructor creates an instance with the specified \a parent. |
59 | */ |
60 | QDispatchCompute::QDispatchCompute(Qt3DCore::QNode *parent) |
61 | : QFrameGraphNode(*new QDispatchComputePrivate(), parent) |
62 | { |
63 | } |
64 | |
65 | /*! \internal */ |
66 | QDispatchCompute::~QDispatchCompute() |
67 | { |
68 | } |
69 | |
70 | int QDispatchCompute::workGroupX() const |
71 | { |
72 | Q_D(const QDispatchCompute); |
73 | return d->m_workGroupX; |
74 | } |
75 | |
76 | int QDispatchCompute::workGroupY() const |
77 | { |
78 | Q_D(const QDispatchCompute); |
79 | return d->m_workGroupY; |
80 | } |
81 | |
82 | int QDispatchCompute::workGroupZ() const |
83 | { |
84 | Q_D(const QDispatchCompute); |
85 | return d->m_workGroupZ; |
86 | } |
87 | |
88 | /*! |
89 | \property Qt3DRender::QDispatchCompute::workGroupX |
90 | Specifies X workgroup. |
91 | */ |
92 | void QDispatchCompute::setWorkGroupX(int workGroupX) |
93 | { |
94 | Q_D(QDispatchCompute); |
95 | if (d->m_workGroupX != workGroupX) { |
96 | d->m_workGroupX = workGroupX; |
97 | emit workGroupXChanged(); |
98 | } |
99 | } |
100 | |
101 | /*! |
102 | \property Qt3DRender::QDispatchCompute::workGroupY |
103 | Specifies Y workgroup. |
104 | */ |
105 | void QDispatchCompute::setWorkGroupY(int workGroupY) |
106 | { |
107 | Q_D(QDispatchCompute); |
108 | if (d->m_workGroupY != workGroupY) { |
109 | d->m_workGroupY = workGroupY; |
110 | emit workGroupYChanged(); |
111 | } |
112 | } |
113 | |
114 | /*! |
115 | \property Qt3DRender::QDispatchCompute::workGroupZ |
116 | Specifies Z workgroup. |
117 | */ |
118 | void QDispatchCompute::setWorkGroupZ(int workGroupZ) |
119 | { |
120 | Q_D(QDispatchCompute); |
121 | if (d->m_workGroupZ != workGroupZ) { |
122 | d->m_workGroupZ = workGroupZ; |
123 | emit workGroupZChanged(); |
124 | } |
125 | |
126 | } |
127 | |
128 | } // Qt3DRender |
129 | |
130 | QT_END_NAMESPACE |
131 | |
132 | #include "moc_qdispatchcompute.cpp" |
133 | |
134 | |