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
qssgrendercommands_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 QSSG_RENDER_COMMANDS_H
8#define QSSG_RENDER_COMMANDS_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 <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderuserpass_p.h>
24
25#include <QDebug>
26#include <QVariant>
27
28QT_BEGIN_NAMESPACE
29
30struct QSSGRenderEffect;
31
52
53class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGCommand
54{
55public:
56 CommandType m_type;
57 QSSGCommand(CommandType inType) : m_type(inType) {}
58 virtual ~QSSGCommand();
59 const char *typeAsString() const;
60 QString debugString() const;
61 void addDebug(QDebug &stream) const;
62};
63
69
71{
72 QSSGAllocateBufferFlags(quint32 inValues) : QFlags(inValues) {}
74 void setSceneLifetime(bool inValue) { setFlag(AllocateBufferFlagValues::SceneLifetime, inValue); }
75 // If isSceneLifetime is unset the buffer is assumed to be frame lifetime and will be
76 // released after this render operation.
77 bool isSceneLifetime() const { return this->operator&(AllocateBufferFlagValues::SceneLifetime); }
78};
79
81{
86 float m_sizeMultiplier = 1.0f;
89 QSSGAllocateBuffer(const QByteArray &inName,
90 QSSGRenderTextureFormat inFormat,
91 QSSGRenderTextureFilterOp inFilterOp,
92 QSSGRenderTextureCoordOp inCoordOp,
93 float inMultiplier,
96 , m_name(inName)
100 , m_sizeMultiplier(inMultiplier)
101 , m_bufferFlags(inFlags)
102 {
103 }
114 void addDebug(QDebug &stream) const {
115 stream << "name:" << m_name << "format:" << m_format.toString() << "size multiplier:" << m_sizeMultiplier << "filter:" << QSSGBaseTypeHelpers::toString(m_filterOp) << "tiling:" << QSSGBaseTypeHelpers::toString(m_texCoordOp) << "sceneLifetime:" << m_bufferFlags.isSceneLifetime();
116 }
117};
118
120{
122
123 explicit QSSGBindTarget(QSSGRenderTextureFormat inFormat = QSSGRenderTextureFormat::RGBA8)
125 {
126 }
132 void addDebug(QDebug &stream) const {
133 stream << "format" << m_outputFormat.toString();
134 }
135};
136
138{
140 QSSGBindBuffer(const QByteArray &inBufName)
142 {
143 }
149 void addDebug(QDebug &stream) const {
150 stream << "name:" << m_bufferName;
151 }
152};
153
155{
156 QByteArray m_shaderPathKey; // something like "prefix>vertex_filename>fragment_filename:source_sha:y_up_in_fbo[:tonemapping]"
157 QSSGBindShader(const QByteArray &inShaderPathKey)
160 {
161 }
168 void addDebug(QDebug &stream) const {
169 stream << "key:" << m_shaderPathKey << "effect:";
170 }
171};
172
173// The value sits immediately after the 'this' object
174// in memory.
175// If propertyName is not valid then we attempt to apply all of the effect property values
176// to the shader, ignoring ones that don't match up.
178{
179 // Name of value to apply in shader
181 // type of value
183 // offset in the effect data section of value.
185 QSSGApplyInstanceValue(const QByteArray &inName, QSSGRenderShaderValue::Type inValueType, quint32 inValueOffset)
187 {
188 }
189 // Default will attempt to apply all effect values to the currently bound shader
201 void addDebug(QDebug &stream) const {
202 stream << "name:" << m_propertyName << "type:" << int(m_valueType) << "offset:" << m_valueOffset ;
203 }
204};
205
207{
210 explicit QSSGApplyValue(const QByteArray &inName)
212 {
213 }
220 // Default will attempt to apply all effect values to the currently bound shader
222 void addDebug(QDebug &stream) const {
223 stream << "name:" << m_propertyName << "value:" << m_value;
224 }
225};
226
228{
231
232 QSSGApplyBufferValue(const QByteArray &bufferName, const QByteArray &shaderSampler)
234 {
235 }
236 void addDebug(QDebug &stream) const {
237 stream << "name:" << m_bufferName << "sampler:" << m_samplerName;
238 }
245};
246
247struct QSSGRender : public QSSGCommand
248{
250
253 {
254 }
255 void addDebug(QDebug &stream) const {
256 stream << "(no parameters)";
257 }
258};
259
261{
262public:
263 enum class RenderableType : quint32 {
264 None = 0x0,
265 Opaque = 0x1,
267 };
268
271
272 quint32 layerMask = 0xffffffff;
274
279 void addDebug(QDebug &stream) const {
280 stream << "layerMask:" << layerMask << "renderableTypes:" << renderableTypes;
281 }
282};
283
284// This is pretty much the same as QSSGAllocateBuffer but
285// we'll keep them separate as we might want to diverge further later.
287{
288public:
293 QSSGAllocateTexture(QSSGRenderTextureFormat inFormat)
296 {
297 }
298
299 const QSSGManagedRhiTexturePtr &texture() const { return m_tex; }
300 void setTexture(const QSSGManagedRhiTexturePtr &tex) { m_tex = QSSGManagedRhiTexture::make_copy(tex); }
301
303 {
304 return m_format;
305 }
306
307 void setFormat(QSSGRenderTextureFormat format)
308 {
309 m_format = format;
310 }
311
312 void addDebug(QDebug &stream) const
313 {
314 stream << "format:" << m_format.toString();
315 }
316
317private:
319
321 QSSGRenderTextureFormat m_format = QSSGRenderTextureFormat::RGBA8;
322};
323
324using QSSGAllocateTexturePtr = std::shared_ptr<QSSGAllocateTexture>;
325
327{
328public:
329 QSSGColorAttachment(const QByteArray &name)
331 , m_name(name)
332 {
333 }
334 void addDebug(QDebug &stream) const {
335 stream << "name:" << m_name;
336 }
337
339 {
340 if (m_textureCmd)
341 return m_textureCmd->format();
342
343 return QSSGRenderTextureFormat::Unknown;
344 }
345
348
349protected:
350 QSSGColorAttachment(const QByteArray &name, CommandType type)
352 , m_name(name)
353 {
354 }
355};
356
358{
359public:
364 void addDebug(QDebug &stream) const {
365 stream << "name:" << m_name;
366 }
367};
368
370{
371public:
376 void addDebug(QDebug &stream) const {
377 stream << "(no parameters)";
378 }
379
381};
382
384{
385public:
391 QSSGAddShaderDefine(const QByteArray &name, int value = 0)
393 , m_name(name)
394 , m_value(value)
395 {
396 }
397 void addDebug(QDebug &stream) const {
398 stream << "define name:" << m_name << "value:" << m_value;
399 }
400
403};
404
406{
407public:
412
413 void setSubPass(QSSGResourceId userPassId) {
414 m_userPassId = userPassId;
415 }
416
417 void addDebug(QDebug &stream) const {
418 stream << "userPassId:" << static_cast<quint64>(m_userPassId);
419 }
420
422};
423
425{
426public:
452 void addDebug(QDebug &stream) const {
453 // Only print out the ones that exist
454 // Elipsis for complex types intentional
455 stream << "pipelineState:" << "{";
456 if (m_depthTestEnabled.has_value())
457 stream << " depthTestEnabled:" << m_depthTestEnabled.value();
458 if (m_depthWriteEnabled.has_value())
459 stream << " depthWriteEnabled:" << m_depthWriteEnabled.value();
460 if (m_blendEnabled.has_value())
461 stream << " blendEnabled:" << m_blendEnabled.value();
462 if (m_usesStencilReference.has_value())
463 stream << " usesStencilReference:" << m_usesStencilReference.value();
464 if (m_usesScissor.has_value())
465 stream << " usesScissor:" << m_usesScissor.value();
466 if (m_depthFunction.has_value())
467 stream << " depthFunction:" << int(m_depthFunction.value());
468 if (m_cullMode.has_value())
469 stream << " cullMode:" << int(m_cullMode.value());
470 if (m_polygonMode.has_value())
471 stream << " polygonMode:" << int(m_polygonMode.value());
472 if (m_stencilOpFrontState.has_value())
473 stream << " stencilOpFrontState:" << "{...}";
474 if (m_stencilWriteMask.has_value())
475 stream << " stencilWriteMask:" << m_stencilWriteMask.value();
476 if (m_stencilReference.has_value())
477 stream << " stencilReference:" << m_stencilReference.value();
478 if (m_viewport.has_value())
479 stream << " viewport:" << "{...}";
480 if (m_scissor.has_value())
481 stream << " scissor:" << "{...}";
482 if (m_targetBlend0.has_value())
483 stream << " targetBlend0:" << "{...}";
484 if (m_targetBlend1.has_value())
485 stream << " targetBlend1:" << "{...}";
486 if (m_targetBlend2.has_value())
487 stream << " targetBlend2:" << "{...}";
488 if (m_targetBlend3.has_value())
489 stream << " targetBlend3:" << "{...}";
490 if (m_targetBlend4.has_value())
491 stream << " targetBlend4:" << "{...}";
492 if (m_targetBlend5.has_value())
493 stream << " targetBlend5:" << "{...}";
494 if (m_targetBlend6.has_value())
495 stream << " targetBlend6:" << "{...}";
496 if (m_targetBlend7.has_value())
497 stream << " targetBlend7:" << "{...}";
498 stream << " }";
499 }
500};
501
502QT_END_NAMESPACE
503
504#endif
QSSGAddShaderDefine(const QByteArray &name, int value=0)
void addDebug(QDebug &stream) const
void setFormat(QSSGRenderTextureFormat format)
QSSGAllocateTexture(QSSGRenderTextureFormat inFormat)
void addDebug(QDebug &stream) const
void setTexture(const QSSGManagedRhiTexturePtr &tex)
QSSGRenderTextureFormat format() const
const QSSGManagedRhiTexturePtr & texture() const
void addDebug(QDebug &stream) const
QSSGColorAttachment(const QByteArray &name)
QSSGAllocateTexturePtr m_textureCmd
QSSGRenderTextureFormat format() const
QSSGColorAttachment(const QByteArray &name, CommandType type)
void addDebug(QDebug &stream) const
void addDebug(QDebug &stream) const
QSSGDepthTextureAttachment(const QByteArray &name)
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend2
std::optional< QRhiGraphicsPipeline::CompareOp > m_depthFunction
std::optional< QRhiGraphicsPipeline::PolygonMode > m_polygonMode
std::optional< QRhiViewport > m_viewport
std::optional< bool > m_usesStencilReference
std::optional< quint32 > m_stencilReference
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend1
std::optional< QRhiGraphicsPipeline::StencilOpState > m_stencilOpFrontState
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend5
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend7
std::optional< QRhiGraphicsPipeline::CullMode > m_cullMode
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend4
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend0
std::optional< QRhiScissor > m_scissor
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend6
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend3
void addDebug(QDebug &stream) const
std::optional< quint32 > m_stencilWriteMask
void addDebug(QDebug &stream) const
static constexpr RenderableTypeT AllRenderableTypes
void addDebug(QDebug &stream) const
void setSubPass(QSSGResourceId userPassId)
QSSGResourceId m_userPassId
AllocateBufferFlagValues
QSSGAllocateBufferFlags(quint32 inValues)
void setSceneLifetime(bool inValue)
QSSGRenderTextureFormat m_format
QSSGAllocateBuffer(const QByteArray &inName, QSSGRenderTextureFormat inFormat, QSSGRenderTextureFilterOp inFilterOp, QSSGRenderTextureCoordOp inCoordOp, float inMultiplier, QSSGAllocateBufferFlags inFlags)
void addDebug(QDebug &stream) const
QSSGRenderTextureFilterOp m_filterOp
QSSGRenderTextureCoordOp m_texCoordOp
QSSGAllocateBufferFlags m_bufferFlags
QSSGAllocateBuffer(const QSSGAllocateBuffer &command)
void addDebug(QDebug &stream) const
QSSGApplyBufferValue(const QByteArray &bufferName, const QByteArray &shaderSampler)
QSSGApplyBufferValue(const QSSGApplyBufferValue &command)
QSSGApplyInstanceValue(const QSSGApplyInstanceValue &command)
QSSGApplyInstanceValue(const QByteArray &inName, QSSGRenderShaderValue::Type inValueType, quint32 inValueOffset)
QSSGRenderShaderValue::Type m_valueType
void addDebug(QDebug &stream) const
QSSGApplyValue(const QByteArray &inName)
void addDebug(QDebug &stream) const
QSSGApplyValue(const QSSGApplyValue &command)
void addDebug(QDebug &stream) const
QSSGBindBuffer(const QSSGBindBuffer &command)
QSSGBindBuffer(const QByteArray &inBufName)
QSSGBindShader(const QSSGBindShader &command)
void addDebug(QDebug &stream) const
QSSGBindShader(const QByteArray &inShaderPathKey)
QSSGBindTarget(const QSSGBindTarget &command)
QSSGRenderTextureFormat m_outputFormat
void addDebug(QDebug &stream) const
QSSGBindTarget(QSSGRenderTextureFormat inFormat=QSSGRenderTextureFormat::RGBA8)
void addDebug(QDebug &stream) const
QSSGRender(const QSSGRender &)