84 Q_PROPERTY(TextureFormat format READ format WRITE setFormat NOTIFY changed)
85 Q_PROPERTY(TextureFilterOperation textureFilterOperation READ textureFilterOperation WRITE setTextureFilterOperation NOTIFY changed)
86 Q_PROPERTY(TextureCoordOperation textureCoordOperation READ textureCoordOperation WRITE setTextureCoordOperation NOTIFY changed)
87 Q_PROPERTY(
float sizeMultiplier MEMBER sizeMultiplier NOTIFY changed)
88 Q_PROPERTY(AllocateBufferFlagValues bufferFlags READ bufferFlags WRITE setBufferFlags NOTIFY changed)
89 Q_PROPERTY(QByteArray name MEMBER name NOTIFY changed)
91 QML_NAMED_ELEMENT(Buffer)
94 QQuick3DShaderUtilsBuffer() =
default;
95 ~QQuick3DShaderUtilsBuffer() override =
default;
97 enum class TextureFilterOperation
103 Q_ENUM(TextureFilterOperation)
105 enum class TextureCoordOperation
112 Q_ENUM(TextureCoordOperation)
114 enum class AllocateBufferFlagValues
119 Q_ENUM(AllocateBufferFlagValues)
121 enum class TextureFormat {
131 Q_ENUM(TextureFormat)
133 QSSGAllocateBuffer command {};
134 TextureFilterOperation textureFilterOperation()
const {
return TextureFilterOperation(command.m_filterOp); }
135 void setTextureFilterOperation(TextureFilterOperation op);
137 TextureCoordOperation textureCoordOperation()
const {
return TextureCoordOperation(command.m_texCoordOp); }
138 void setTextureCoordOperation(TextureCoordOperation texCoordOp);
139 float &sizeMultiplier = command.m_sizeMultiplier;
140 QSSGCommand *cloneCommand() {
return new QSSGAllocateBuffer(command); }
142 TextureFormat format()
const;
143 void setFormat(TextureFormat format);
145 AllocateBufferFlagValues bufferFlags()
const {
return AllocateBufferFlagValues(
int(command.m_bufferFlags)); }
146 void setBufferFlags(AllocateBufferFlagValues flag);
148 QByteArray &name = command.m_name;
150 static QSSGRenderTextureFormat::Format mapTextureFormat(QQuick3DShaderUtilsBuffer::TextureFormat fmt);
151 static QQuick3DShaderUtilsBuffer::TextureFormat mapRenderTextureFormat(QSSGRenderTextureFormat::Format fmt);
177 Q_PROPERTY(QQuick3DShaderUtilsBuffer *buffer READ buffer WRITE setBuffer)
178 Q_PROPERTY(QByteArray sampler MEMBER sampler)
180 QML_NAMED_ELEMENT(BufferInput)
183 QQuick3DShaderUtilsBufferInput() =
default;
184 ~QQuick3DShaderUtilsBufferInput() override =
default;
185 QSSGApplyBufferValue command { QByteArray(), QByteArray() };
186 QByteArray &sampler = command.m_samplerName;
187 QSSGCommand *cloneCommand() override {
return new QSSGApplyBufferValue(command); }
189 int bufferCount()
const override {
return (m_buffer !=
nullptr) ? 1 : 0; }
190 QQuick3DShaderUtilsBuffer *bufferAt(
int idx)
const override
192 Q_ASSERT(idx < 1 && idx >= 0);
193 return (m_buffer && idx == 0) ? m_buffer :
nullptr;
196 QQuick3DShaderUtilsBuffer *buffer()
const {
return m_buffer; }
197 void setBuffer(QQuick3DShaderUtilsBuffer *buffer) {
198 if (m_buffer == buffer)
202 Q_ASSERT(!buffer->name.isEmpty());
203 command.m_bufferName = buffer->name;
208 QQuick3DShaderUtilsBuffer *m_buffer =
nullptr;
215 Q_PROPERTY(
bool enable MEMBER enable)
216 Q_PROPERTY(ColorMask colorWrite MEMBER colorWrite)
217 Q_PROPERTY(BlendFactor srcColor MEMBER srcColor)
218 Q_PROPERTY(BlendFactor dstColor MEMBER dstColor)
219 Q_PROPERTY(BlendOperation opColor MEMBER opColor)
220 Q_PROPERTY(BlendFactor srcAlpha MEMBER srcAlpha)
221 Q_PROPERTY(BlendFactor dstAlpha MEMBER dstAlpha)
222 Q_PROPERTY(BlendOperation opAlpha MEMBER opAlpha)
223 QML_VALUE_TYPE(renderTargetBlend)
224 QML_ADDED_IN_VERSION(6, 11)
227 enum ColorMaskComponent : quint32 {
233 Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
235 enum class BlendFactor {
247 OneMinusConstantColor,
249 OneMinusConstantAlpha,
258 enum class BlendOperation {
265 Q_ENUM(BlendOperation)
267 ColorMask colorWrite = ColorMask(0xF);
269 BlendFactor srcColor = BlendFactor::One;
270 BlendFactor dstColor = BlendFactor::OneMinusSrcAlpha;
271 BlendOperation opColor = BlendOperation::Add;
272 BlendFactor srcAlpha = BlendFactor::One;
273 BlendFactor dstAlpha = BlendFactor::OneMinusSrcAlpha;
274 BlendOperation opAlpha = BlendOperation::Add;
276 bool operator==(
const QQuick3DRenderPassTargetBlend &other)
const
278 return colorWrite == other.colorWrite
279 && enable == other.enable
280 && srcColor == other.srcColor
281 && dstColor == other.dstColor
282 && opColor == other.opColor
283 && srcAlpha == other.srcAlpha
284 && dstAlpha == other.dstAlpha
285 && opAlpha == other.opAlpha;
288 QQuick3DRenderPassTargetBlend() =
default;
289 QQuick3DRenderPassTargetBlend(QRhiGraphicsPipeline::TargetBlend targetBlend)
290 : colorWrite(ColorMask(targetBlend.colorWrite.toInt()))
291 , enable(targetBlend.enable)
292 , srcColor(BlendFactor(targetBlend.srcColor))
293 , dstColor(BlendFactor(targetBlend.dstColor))
294 , opColor(BlendOperation(targetBlend.opColor))
295 , srcAlpha(BlendFactor(targetBlend.srcAlpha))
296 , dstAlpha(BlendFactor(targetBlend.dstAlpha))
297 , opAlpha(BlendOperation(targetBlend.opAlpha))
301 QRhiGraphicsPipeline::TargetBlend toRhiTargetBlend()
const
303 QRhiGraphicsPipeline::TargetBlend tb;
304 tb.colorWrite = QRhiGraphicsPipeline::ColorMask(colorWrite.toInt());
306 tb.srcColor = QRhiGraphicsPipeline::BlendFactor(
int(srcColor));
307 tb.dstColor = QRhiGraphicsPipeline::BlendFactor(
int(dstColor));
308 tb.opColor = QRhiGraphicsPipeline::BlendOp(
int(opColor));
309 tb.srcAlpha = QRhiGraphicsPipeline::BlendFactor(
int(srcAlpha));
310 tb.dstAlpha = QRhiGraphicsPipeline::BlendFactor(
int(dstAlpha));
311 tb.opAlpha = QRhiGraphicsPipeline::BlendOp(
int(opAlpha));
327 Q_PROPERTY(
bool depthTestEnabled READ depthTestEnabled WRITE setDepthTestEnabled RESET resetDepthTestEnabled NOTIFY depthTestEnabledChanged)
328 Q_PROPERTY(
bool depthWriteEnabled READ depthWriteEnabled WRITE setDepthWriteEnabled RESET resetDepthWriteEnabled NOTIFY depthWriteEnabledChanged)
329 Q_PROPERTY(
bool blendEnabled READ blendEnabled WRITE setBlendEnabled RESET resetBlendEnabled NOTIFY blendEnabledChanged FINAL)
330 Q_PROPERTY(
bool usesStencilReference READ usesStencilReference WRITE setUsesStencilReference RESET resetUsesStencilReference NOTIFY usesStencilReferenceChanged)
331 Q_PROPERTY(
bool usesScissor READ usesScissor WRITE setUsesScissor RESET resetUsesScissor NOTIFY usesScissorChanged)
332 Q_PROPERTY(CompareOperation depthFunction READ depthFunction WRITE setDepthFunction RESET resetDepthFunction NOTIFY depthFunctionChanged)
333 Q_PROPERTY(CullMode cullMode READ cullMode WRITE setCullMode RESET resetCullMode NOTIFY cullModeChanged)
334 Q_PROPERTY(PolygonMode polygonMode READ polygonMode WRITE setPolygonMode RESET resetPolygonMode NOTIFY polygonModeChanged)
335 Q_PROPERTY(quint32 stencilWriteMask READ stencilWriteMask WRITE setStencilWriteMask RESET resetStencilWriteMask NOTIFY stencilWriteMaskChanged)
336 Q_PROPERTY(quint32 stencilReference READ stencilReference WRITE setStencilReference RESET resetStencilReference NOTIFY stencilReferenceChanged)
337 Q_PROPERTY(QRectF viewport READ viewport WRITE setViewport RESET resetViewport NOTIFY viewportChanged)
338 Q_PROPERTY(QRect scissor READ scissor WRITE setScissor RESET resetScissor NOTIFY scissorChanged)
339 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend0 READ targetBlend0 WRITE setTargetBlend0 RESET resetTargetBlend0 NOTIFY targetBlend0Changed)
340 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend1 READ targetBlend1 WRITE setTargetBlend1 RESET resetTargetBlend1 NOTIFY targetBlend1Changed)
341 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend2 READ targetBlend2 WRITE setTargetBlend2 RESET resetTargetBlend2 NOTIFY targetBlend2Changed)
342 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend3 READ targetBlend3 WRITE setTargetBlend3 RESET resetTargetBlend3 NOTIFY targetBlend3Changed)
343 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend4 READ targetBlend4 WRITE setTargetBlend4 RESET resetTargetBlend4 NOTIFY targetBlend4Changed)
344 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend5 READ targetBlend5 WRITE setTargetBlend5 RESET resetTargetBlend5 NOTIFY targetBlend5Changed)
345 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend6 READ targetBlend6 WRITE setTargetBlend6 RESET resetTargetBlend6 NOTIFY targetBlend6Changed)
346 Q_PROPERTY(QQuick3DRenderPassTargetBlend targetBlend7 READ targetBlend7 WRITE setTargetBlend7 RESET resetTargetBlend7 NOTIFY targetBlend7Changed)
347 QML_NAMED_ELEMENT(PipelineStateOverride)
348 QML_ADDED_IN_VERSION(6, 11)
351 enum class CompareOperation {
361 Q_ENUM(CompareOperation)
363 enum class CullMode {
370 enum class PolygonMode {
376 QQuick3DShaderUtilsPipelineStateOverride();
377 ~QQuick3DShaderUtilsPipelineStateOverride() override;
379 bool depthTestEnabled()
const;
380 void setDepthTestEnabled(
bool newDepthTestEnabled);
381 void resetDepthTestEnabled();
382 bool depthWriteEnabled()
const;
383 void setDepthWriteEnabled(
bool newDepthWriteEnabled);
384 void resetDepthWriteEnabled();
386 bool blendEnabled()
const;
387 void setBlendEnabled(
bool newBlendEnabled);
388 void resetBlendEnabled();
390 bool usesStencilReference()
const;
391 void setUsesStencilReference(
bool newUsesStencilReference);
392 void resetUsesStencilReference();
394 bool usesScissor()
const;
395 void setUsesScissor(
bool newUsesScissor);
396 void resetUsesScissor();
398 CompareOperation depthFunction()
const;
399 void setDepthFunction(CompareOperation newDepthFunction);
400 void resetDepthFunction();
402 CullMode cullMode()
const;
403 void setCullMode(CullMode newCullMode);
404 void resetCullMode();
406 PolygonMode polygonMode()
const;
407 void setPolygonMode(PolygonMode newPolygonMode);
408 void resetPolygonMode();
410 quint32 stencilWriteMask()
const;
411 void setStencilWriteMask(quint32 newStencilWriteMask);
412 void resetStencilWriteMask();
414 quint32 stencilReference()
const;
415 void setStencilReference(quint32 newStencilReference);
416 void resetStencilReference();
418 QRectF viewport()
const;
419 void setViewport(
const QRectF &newViewport);
420 void resetViewport();
422 QRect scissor()
const;
423 void setScissor(
const QRect &newScissor);
426 QQuick3DRenderPassTargetBlend targetBlend0()
const;
427 void setTargetBlend0(
const QQuick3DRenderPassTargetBlend &newTargetBlend0);
428 void resetTargetBlend0();
430 QQuick3DRenderPassTargetBlend targetBlend1()
const;
431 void setTargetBlend1(
const QQuick3DRenderPassTargetBlend &newTargetBlend1);
432 void resetTargetBlend1();
434 QQuick3DRenderPassTargetBlend targetBlend2()
const;
435 void setTargetBlend2(
const QQuick3DRenderPassTargetBlend &newTargetBlend2);
436 void resetTargetBlend2();
438 QQuick3DRenderPassTargetBlend targetBlend3()
const;
439 void setTargetBlend3(
const QQuick3DRenderPassTargetBlend &newTargetBlend3);
440 void resetTargetBlend3();
442 QQuick3DRenderPassTargetBlend targetBlend4()
const;
443 void setTargetBlend4(
const QQuick3DRenderPassTargetBlend &newTargetBlend4);
444 void resetTargetBlend4();
446 QQuick3DRenderPassTargetBlend targetBlend5()
const;
447 void setTargetBlend5(
const QQuick3DRenderPassTargetBlend &newTargetBlend5);
448 void resetTargetBlend5();
450 QQuick3DRenderPassTargetBlend targetBlend6()
const;
451 void setTargetBlend6(
const QQuick3DRenderPassTargetBlend &newTargetBlend6);
452 void resetTargetBlend6();
454 QQuick3DRenderPassTargetBlend targetBlend7()
const;
455 void setTargetBlend7(
const QQuick3DRenderPassTargetBlend &newTargetBlend7);
456 void resetTargetBlend7();
459 void depthTestEnabledChanged();
460 void depthWriteEnabledChanged();
461 void blendEnabledChanged();
462 void usesStencilReferenceChanged();
463 void usesScissorChanged();
464 void depthFunctionChanged();
465 void cullModeChanged();
466 void polygonModeChanged();
467 void stencilWriteMaskChanged();
468 void stencilReferenceChanged();
469 void viewportChanged();
470 void scissorChanged();
471 void targetBlend0Changed();
472 void targetBlend1Changed();
473 void targetBlend2Changed();
474 void targetBlend3Changed();
475 void targetBlend4Changed();
476 void targetBlend5Changed();
477 void targetBlend6Changed();
478 void targetBlend7Changed();
481 QSSGCommand *cloneCommand() override {
return new QSSGPipelineStateOverrideCommand(command); }
482 QSSGPipelineStateOverrideCommand command { };
507 Q_PROPERTY(quint32 layerMask MEMBER layerMask)
508 Q_PROPERTY(RenderableTypes renderableTypes READ renderableTypes WRITE setRenderableTypes)
509 QML_NAMED_ELEMENT(RenderablesFilter)
510 QML_ADDED_IN_VERSION(6, 11)
513 enum class RenderableType : quint32 {
518 Q_DECLARE_FLAGS(RenderableTypes, RenderableType)
519 Q_FLAG(RenderableTypes)
521 QQuick3DShaderUtilsRenderablesFilter() =
default;
522 ~QQuick3DShaderUtilsRenderablesFilter() override;
524 RenderableTypes renderableTypes()
const;
525 void setRenderableTypes(RenderableTypes types);
527 QSSGCommand *cloneCommand() override {
return new QSSGRenderablesFilterCommand(command); }
528 QSSGRenderablesFilterCommand command { };
530 quint32 &layerMask = command.layerMask;
536 Q_PROPERTY(TextureFormat format READ format WRITE setFormat FINAL)
537 QML_NAMED_ELEMENT(RenderPassTexture)
538 QML_ADDED_IN_VERSION(6, 11)
541 enum class TextureFormat {
555 Q_ENUM(TextureFormat)
557 QQuick3DShaderUtilsRenderPassTexture() =
default;
558 ~QQuick3DShaderUtilsRenderPassTexture() override;
560 TextureFormat format()
const;
561 void setFormat(TextureFormat newFormat);
563 std::shared_ptr<QSSGAllocateTexture> command;
566 friend class QQuick3DShaderUtilsRenderPassColorAttachment;
567 friend class QQuick3DShaderUtilsRenderPassDepthTextureAttachment;
571 static QSSGRenderTextureFormat asRenderTextureFormat(QQuick3DShaderUtilsRenderPassTexture::TextureFormat fmt);
572 static QQuick3DShaderUtilsRenderPassTexture::TextureFormat fromRenderTextureFormat(QSSGRenderTextureFormat fmt);
658 Q_PROPERTY(QQuick3DRenderPass *renderPass READ renderPass WRITE setRenderPass NOTIFY renderPassChanged FINAL)
659 QML_NAMED_ELEMENT(SubRenderPass)
660 QML_ADDED_IN_VERSION(6, 11)
663 QQuick3DShaderUtilsSubRenderPass() =
default;
664 ~QQuick3DShaderUtilsSubRenderPass() override;
666 QQuick3DRenderPass *renderPass()
const;
667 void setRenderPass(QQuick3DRenderPass *newRenderPass);
669 QSSGCommand *cloneCommand() override;
672 void renderPassChanged();
675 virtual QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) final;
676 virtual void itemChange(ItemChange change,
const ItemChangeData &value) final;
679 void updateSceneManager(QQuick3DSceneManager *sceneManager);
681 QQuick3DRenderPass *m_renderPass =
nullptr;
682 mutable bool m_hasWarnedAboutInvalidId =
false;
688 Q_PROPERTY(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> commands READ commands)
689 Q_PROPERTY(QQuick3DShaderUtilsBuffer *output MEMBER outputBuffer)
690 Q_PROPERTY(QQmlListProperty<QQuick3DShaderUtilsShader> shaders READ shaders)
691 QML_NAMED_ELEMENT(Pass)
692 QML_ADDED_IN_VERSION(6, 11)
695 QQuick3DShaderUtilsRenderPass() =
default;
696 ~QQuick3DShaderUtilsRenderPass() override;
698 static void qmlAppendCommand(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list, QQuick3DShaderUtilsRenderCommand *command);
699 static QQuick3DShaderUtilsRenderCommand *qmlCommandAt(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list, qsizetype index);
700 static qsizetype qmlCommandCount(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list);
701 static void qmlCommandClear(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list);
703 static void qmlAppendShader(QQmlListProperty<QQuick3DShaderUtilsShader> *list, QQuick3DShaderUtilsShader *shader);
704 static QQuick3DShaderUtilsShader *qmlShaderAt(QQmlListProperty<QQuick3DShaderUtilsShader> *list, qsizetype index);
705 static qsizetype qmlShaderCount(QQmlListProperty<QQuick3DShaderUtilsShader> *list);
706 static void qmlShaderClear(QQmlListProperty<QQuick3DShaderUtilsShader> *list);
708 QQmlListProperty<QQuick3DShaderUtilsRenderCommand> commands();
709 QVector<QQuick3DShaderUtilsRenderCommand *> m_commands;
710 QQuick3DShaderUtilsBuffer *outputBuffer =
nullptr;
711 QQmlListProperty<QQuick3DShaderUtilsShader> shaders();
712 QVarLengthArray<QQuick3DShaderUtilsShader *, 2> m_shaders;
776 enum class DirtyPropertyHint
783 explicit QQuick3DPropertyChangedTracker(QQuick3DObject *owner, QQuick3DSuperClassInfo<T> info)
785 , m_superClassName(info.superClassName())
787 Q_ASSERT(m_owner !=
nullptr);
789 virtual ~QQuick3DPropertyChangedTracker();
791 using UniformProperty = QSSGUserShaderAugmentation::Property;
792 using UniformPropertyList = QVector<UniformProperty>;
794 friend class QQuick3DPropertyWatcher;
797 QList<UniformProperty> extractProperties();
799 void addPropertyWatcher(QMetaProperty property, DirtyPropertyHint hint, QQuick3DObject *object =
nullptr);
801 virtual void markTrackedPropertyDirty(QMetaProperty property, DirtyPropertyHint hint) = 0;
805 QQuick3DPropertyWatcher *watcher =
nullptr;
806 QPointer<QQuick3DObject> object;
810 QHash<
int, Tracked> m_trackedProperties;
811 QQuick3DObject *m_owner =
nullptr;
812 const char *m_superClassName =
nullptr;
813 QList<UniformProperty> m_propertyList;
816 std::optional<UniformProperty> createOrUpdateTrackedProperty(
const QMetaProperty property,
bool addWatchers);
817 std::vector<
int> m_dirtyProperties;
818 bool m_extracted =
false;