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
29
30struct QSSGRenderEffect;
31
53
54class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGCommand
55{
56public:
57 CommandType m_type;
58 QSSGCommand(CommandType inType) : m_type(inType) {}
59 virtual ~QSSGCommand();
60 const char *typeAsString() const;
61 QString debugString() const;
62 void addDebug(QDebug &stream) const;
63};
64
70
72{
73 QSSGAllocateBufferFlags(quint32 inValues) : QFlags(inValues) {}
75 void setSceneLifetime(bool inValue) { setFlag(AllocateBufferFlagValues::SceneLifetime, inValue); }
76 // If isSceneLifetime is unset the buffer is assumed to be frame lifetime and will be
77 // released after this render operation.
78 bool isSceneLifetime() const { return this->operator&(AllocateBufferFlagValues::SceneLifetime); }
79};
80
82{
87 float m_sizeMultiplier = 1.0f;
90 QSSGAllocateBuffer(const QByteArray &inName,
91 QSSGRenderTextureFormat inFormat,
92 QSSGRenderTextureFilterOp inFilterOp,
93 QSSGRenderTextureCoordOp inCoordOp,
94 float inMultiplier,
97 , m_name(inName)
101 , m_sizeMultiplier(inMultiplier)
102 , m_bufferFlags(inFlags)
103 {
104 }
115 void addDebug(QDebug &stream) const {
116 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();
117 }
118};
119
121{
123
124 explicit QSSGBindTarget(QSSGRenderTextureFormat inFormat = QSSGRenderTextureFormat::RGBA8)
126 {
127 }
133 void addDebug(QDebug &stream) const {
134 stream << "format" << m_outputFormat.toString();
135 }
136};
137
139{
141 QSSGBindBuffer(const QByteArray &inBufName)
143 {
144 }
150 void addDebug(QDebug &stream) const {
151 stream << "name:" << m_bufferName;
152 }
153};
154
156{
157 QByteArray m_shaderPathKey; // something like "prefix>vertex_filename>fragment_filename:source_sha:y_up_in_fbo[:tonemapping]"
158 QSSGBindShader(const QByteArray &inShaderPathKey)
161 {
162 }
169 void addDebug(QDebug &stream) const {
170 stream << "key:" << m_shaderPathKey << "effect:";
171 }
172};
173
174// The value sits immediately after the 'this' object
175// in memory.
176// If propertyName is not valid then we attempt to apply all of the effect property values
177// to the shader, ignoring ones that don't match up.
179{
180 // Name of value to apply in shader
182 // type of value
184 // offset in the effect data section of value.
186 QSSGApplyInstanceValue(const QByteArray &inName, QSSGRenderShaderValue::Type inValueType, quint32 inValueOffset)
188 {
189 }
190 // Default will attempt to apply all effect values to the currently bound shader
202 void addDebug(QDebug &stream) const {
203 stream << "name:" << m_propertyName << "type:" << int(m_valueType) << "offset:" << m_valueOffset ;
204 }
205};
206
208{
211 explicit QSSGApplyValue(const QByteArray &inName)
213 {
214 }
221 // Default will attempt to apply all effect values to the currently bound shader
223 void addDebug(QDebug &stream) const {
224 stream << "name:" << m_propertyName << "value:" << m_value;
225 }
226};
227
229{
232
233 QSSGApplyBufferValue(const QByteArray &bufferName, const QByteArray &shaderSampler)
235 {
236 }
237 void addDebug(QDebug &stream) const {
238 stream << "name:" << m_bufferName << "sampler:" << m_samplerName;
239 }
246};
247
248struct QSSGRender : public QSSGCommand
249{
251
254 {
255 }
256 void addDebug(QDebug &stream) const {
257 stream << "(no parameters)";
258 }
259};
260
262{
263public:
264 enum class RenderableType : quint32 {
265 None = 0x0,
266 Opaque = 0x1,
268 };
269
272
273 quint32 layerMask = 0xffffffff;
275
280 void addDebug(QDebug &stream) const {
281 stream << "layerMask:" << layerMask << "renderableTypes:" << renderableTypes;
282 }
283};
284
285// This is pretty much the same as QSSGAllocateBuffer but
286// we'll keep them separate as we might want to diverge further later.
288{
289public:
294 QSSGAllocateTexture(QSSGRenderTextureFormat inFormat)
297 {
298 }
299
300 // Invalid until a pass has allocated the texture.
301 const QSSGManagedRhiTexture &texture() const { return m_tex; }
302 void setTexture(const QSSGManagedRhiTexture &tex) { m_tex = tex; }
303
305 {
306 return m_format;
307 }
308
309 void setFormat(QSSGRenderTextureFormat format)
310 {
311 m_format = format;
312 }
313
314 void addDebug(QDebug &stream) const
315 {
316 stream << "format:" << m_format.toString();
317 }
318
319private:
321
323 QSSGRenderTextureFormat m_format = QSSGRenderTextureFormat::RGBA8;
324};
325
326using QSSGAllocateTexturePtr = std::shared_ptr<QSSGAllocateTexture>;
327
329{
330public:
331 QSSGColorAttachment(const QByteArray &name)
333 , m_name(name)
334 {
335 }
336 void addDebug(QDebug &stream) const {
337 stream << "name:" << m_name;
338 }
339
341 {
342 if (m_textureCmd)
343 return m_textureCmd->format();
344
345 return QSSGRenderTextureFormat::Unknown;
346 }
347
349 QSSGAllocateTexturePtr m_textureCmd;
350
351protected:
352 QSSGColorAttachment(const QByteArray &name, CommandType type)
354 , m_name(name)
355 {
356 }
357};
358
360{
361public:
366 void addDebug(QDebug &stream) const {
367 stream << "name:" << m_name;
368 }
369};
370
372{
373public:
378 void addDebug(QDebug &stream) const {
379 stream << "(no parameters)";
380 }
381
383};
384
386{
387public:
393 QSSGAddShaderDefine(const QByteArray &name, int value = 0)
395 , m_name(name)
396 , m_value(value)
397 {
398 }
399 void addDebug(QDebug &stream) const {
400 stream << "define name:" << m_name << "value:" << m_value;
401 }
402
405};
406
408{
409public:
412 , m_groupCount{0,0,0}
413 {
414 }
415 QSSGDispatch(QSSGRenderShaderValue::ivec3 groupCount)
417 {
418 }
419 void addDebug(QDebug &stream) const {
420 stream << "dispatch: (" << m_groupCount.x << " " << m_groupCount.y << " " << m_groupCount.z << ")";
421 }
422
424};
425
427{
428public:
433
434 void setSubPass(QSSGResourceId userPassId) {
435 m_userPassId = userPassId;
436 }
437
438 void addDebug(QDebug &stream) const {
439 stream << "userPassId:" << static_cast<quint64>(m_userPassId);
440 }
441
443};
444
446{
447public:
473 void addDebug(QDebug &stream) const {
474 // Only print out the ones that exist
475 // Elipsis for complex types intentional
476 stream << "pipelineState:" << "{";
477 if (m_depthTestEnabled.has_value())
478 stream << " depthTestEnabled:" << m_depthTestEnabled.value();
479 if (m_depthWriteEnabled.has_value())
480 stream << " depthWriteEnabled:" << m_depthWriteEnabled.value();
481 if (m_blendEnabled.has_value())
482 stream << " blendEnabled:" << m_blendEnabled.value();
483 if (m_usesStencilReference.has_value())
484 stream << " usesStencilReference:" << m_usesStencilReference.value();
485 if (m_usesScissor.has_value())
486 stream << " usesScissor:" << m_usesScissor.value();
487 if (m_depthFunction.has_value())
488 stream << " depthFunction:" << int(m_depthFunction.value());
489 if (m_cullMode.has_value())
490 stream << " cullMode:" << int(m_cullMode.value());
491 if (m_polygonMode.has_value())
492 stream << " polygonMode:" << int(m_polygonMode.value());
493 if (m_stencilOpFrontState.has_value())
494 stream << " stencilOpFrontState:" << "{...}";
495 if (m_stencilWriteMask.has_value())
496 stream << " stencilWriteMask:" << m_stencilWriteMask.value();
497 if (m_stencilReference.has_value())
498 stream << " stencilReference:" << m_stencilReference.value();
499 if (m_viewport.has_value())
500 stream << " viewport:" << "{...}";
501 if (m_scissor.has_value())
502 stream << " scissor:" << "{...}";
503 if (m_targetBlend0.has_value())
504 stream << " targetBlend0:" << "{...}";
505 if (m_targetBlend1.has_value())
506 stream << " targetBlend1:" << "{...}";
507 if (m_targetBlend2.has_value())
508 stream << " targetBlend2:" << "{...}";
509 if (m_targetBlend3.has_value())
510 stream << " targetBlend3:" << "{...}";
511 if (m_targetBlend4.has_value())
512 stream << " targetBlend4:" << "{...}";
513 if (m_targetBlend5.has_value())
514 stream << " targetBlend5:" << "{...}";
515 if (m_targetBlend6.has_value())
516 stream << " targetBlend6:" << "{...}";
517 if (m_targetBlend7.has_value())
518 stream << " targetBlend7:" << "{...}";
519 stream << " }";
520 }
521};
522
523QT_END_NAMESPACE
524
525#endif
QSSGAddShaderDefine(const QByteArray &name, int value=0)
void addDebug(QDebug &stream) const
void setFormat(QSSGRenderTextureFormat format)
QSSGAllocateTexture(QSSGRenderTextureFormat inFormat)
const QSSGManagedRhiTexture & texture() const
void addDebug(QDebug &stream) const
QSSGRenderTextureFormat format() const
void setTexture(const QSSGManagedRhiTexture &tex)
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)
void addDebug(QDebug &stream) const
QSSGDispatch(QSSGRenderShaderValue::ivec3 groupCount)
QSSGRenderShaderValue::ivec3 m_groupCount
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
friend class QSSGRenderContextInterface
void addDebug(QDebug &stream) const
void setSubPass(QSSGResourceId userPassId)
QSSGResourceId m_userPassId
Combined button and popup list for selecting options.
static QSet< QByteArray > shaderIdentifiers(const QByteArray &shaderCode)
void prepareComputePass(QSSGRenderer &renderer, QSSGLayerRenderData &data, QSSGRenderComputePass *passNode, ComputeUserPassData &userData, QSSGPassKey key)
static const QByteArrayList rhiProperties
static const QByteArrayList cameraUniforms
static const QByteArrayList lightUniforms
static QT_BEGIN_NAMESPACE constexpr int s_maxDirectionalLights
static const QByteArrayList positionalShadows
static constexpr int s_maxPositionalLights
static QSSGRhiShaderPipelinePtr generateRhiShaderPipeline(const QByteArray &inKey, QSSGRenderContextInterface *cif, const QSSGRenderComputePass *pass, const QSSGComputeLightContext &lightContext, const bool multiview, int viewCount)
static const QByteArrayList screenTextures
bool finalizeComputeShader(QSSGUserComputeShader &computeShader)
static bool containsAny(const QSet< QByteArray > &identifiers, const QByteArrayList &list)
static quint32 softShadowQualityToInt(QSSGRenderLight::SoftShadowQuality quality)
void prepareComputePass(QSSGRenderer &renderer, QSSGLayerRenderData &data, QSSGRenderComputePass *passNode, ComputeUserPassData &passData, QSSGPassKey key)
AllocateBufferFlagValues
QSSGShaderDefineList m_shaderDefines
QSSGRhiShaderPipelinePtr m_computePipeline
QRhiShaderResourceBindings * m_computeBindings
QSSGRenderShaderValue::ivec3 m_groupCount
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 &)