| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGRENDEREXTENSIIONS_H |
| 5 | #define QSSGRENDEREXTENSIIONS_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is part of the QtQuick3D API, with limited compatibility guarantees. |
| 12 | // Usage of this API may make your code source and binary incompatible with |
| 13 | // future versions of Qt. |
| 14 | // |
| 15 | |
| 16 | #include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h> |
| 17 | #include <ssg/qssgrenderbasetypes.h> |
| 18 | #include <ssg/qssgrendergraphobject.h> |
| 19 | #include <ssg/qssgrhicontext.h> |
| 20 | #include <QtCore/qobject.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QSSGRenderContextInterface; |
| 25 | class QSSGLayerRenderData; |
| 26 | class QRhiTexture; |
| 27 | class QRhiRenderBuffer; |
| 28 | |
| 29 | class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGFrameData |
| 30 | { |
| 31 | public: |
| 32 | enum class RenderResult : quint32 |
| 33 | { |
| 34 | AoTexture, |
| 35 | DepthTexture, |
| 36 | ScreenTexture |
| 37 | }; |
| 38 | |
| 39 | struct Result |
| 40 | { |
| 41 | QRhiTexture *texture = nullptr; |
| 42 | QRhiRenderBuffer *buffer = nullptr; |
| 43 | }; |
| 44 | |
| 45 | Result getRenderResult(RenderResult id) const; |
| 46 | |
| 47 | [[nodiscard]] QSSGRhiGraphicsPipelineState getPipelineState() const; |
| 48 | |
| 49 | [[nodiscard]] QSSGCameraId activeCamera() const; |
| 50 | |
| 51 | [[nodiscard]] QSSGRenderContextInterface *contextInterface() const; |
| 52 | |
| 53 | private: |
| 54 | friend class QSSGLayerRenderData; |
| 55 | friend class QSSGRenderHelpers; |
| 56 | |
| 57 | void clear(); |
| 58 | |
| 59 | [[nodiscard]] QSSGLayerRenderData *getCurrent() const; |
| 60 | |
| 61 | QSSGFrameData() = default; |
| 62 | explicit QSSGFrameData(QSSGRenderContextInterface *ctx); |
| 63 | QSSGRenderContextInterface *m_ctx = nullptr; |
| 64 | }; |
| 65 | |
| 66 | class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderExtension : public QSSGRenderGraphObject |
| 67 | { |
| 68 | public: |
| 69 | enum class RenderMode |
| 70 | { |
| 71 | Standalone, |
| 72 | Main |
| 73 | }; |
| 74 | |
| 75 | enum class RenderStage |
| 76 | { |
| 77 | PreColor, |
| 78 | PostColor |
| 79 | }; |
| 80 | |
| 81 | QSSGRenderExtension(); |
| 82 | virtual ~QSSGRenderExtension(); |
| 83 | |
| 84 | virtual bool prepareData(QSSGFrameData &data) = 0; |
| 85 | virtual void prepareRender(QSSGFrameData &data) = 0; |
| 86 | virtual void render(QSSGFrameData &data) = 0; |
| 87 | |
| 88 | virtual void resetForFrame() = 0; |
| 89 | |
| 90 | virtual RenderMode mode() const = 0; |
| 91 | virtual RenderStage stage() const = 0; |
| 92 | }; |
| 93 | |
| 94 | QT_END_NAMESPACE |
| 95 | |
| 96 | #endif // QSSGRENDEREXTENSIIONS_H |
| 97 | |