// Copyright (C) 2008-2012 NVIDIA Corporation. // Copyright (C) 2019 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QSSG_RENDER_CONTEXT_CORE_H #define QSSG_RENDER_CONTEXT_CORE_H // // W A R N I N G // ------------- // // This file is part of the QtQuick3D API, with limited compatibility guarantees. // Usage of this API may make your code source and binary incompatible with // future versions of Qt. // #include #include #include #include QT_BEGIN_NAMESPACE class QSSGRhiContext; class QSSGBufferManager; class QSSGRenderer; class QSSGShaderLibraryManager; class QSSGShaderCache; class QSSGProgramGenerator; class QSSGCustomMaterialSystem; class QSSGRendererInterface; class QSSGDebugDrawSystem; class QSSGPerFrameAllocator; class QQuickWindow; class QRhi; class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderContextInterface { Q_DISABLE_COPY(QSSGRenderContextInterface) public: // The commonly used version (from QQuick3DSceneRenderer). There is one // rendercontext per QQuickWindow (and so scenegraph render thread). explicit QSSGRenderContextInterface(QRhi *rhi); // This overload must only be used in special cases, e.g. by the genshaders tool. QSSGRenderContextInterface(std::unique_ptr bufferManager, std::unique_ptr renderer, std::shared_ptr shaderLibraryManager, std::unique_ptr shaderCache, std::unique_ptr customMaterialSystem, std::unique_ptr shaderProgramGenerator, std::unique_ptr ctx, std::unique_ptr debugDrawSystem = nullptr); ~QSSGRenderContextInterface(); const std::unique_ptr &renderer() const; const std::unique_ptr &bufferManager() const; const std::unique_ptr &rhiContext() const; const std::unique_ptr &shaderCache() const; const std::shared_ptr &shaderLibraryManager() const; const std::unique_ptr &customMaterialSystem() const; const std::unique_ptr &shaderProgramGenerator() const; const std::unique_ptr &debugDrawSystem() const; private: friend class QQuick3DSceneRenderer; friend class QQuick3DWindowAttachment; friend class QSSGLayerRenderData; friend class QSSGRenderer; QRhi *rhi() const; // Internal convenience function void init(); void releaseCachedResources(); // The memory used for the per frame allocator is released as the first step in BeginFrame. // This is useful for short lived objects and datastructures. // NOTE: Only used internally and not replaceable for now. const std::unique_ptr &perFrameAllocator() const; std::unique_ptr m_rhiContext; std::unique_ptr m_shaderCache; std::unique_ptr m_bufferManager; std::unique_ptr m_renderer; std::shared_ptr m_shaderLibraryManager; std::unique_ptr m_customMaterialSystem; std::unique_ptr m_shaderProgramGenerator; std::unique_ptr m_debugDrawSystem; std::unique_ptr m_perFrameAllocator; }; QT_END_NAMESPACE #endif