X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles-impl%2Fegl-graphics-controller.h;h=6af738393bb13a509f8ed72b2d1ee16ea32c4ba1;hb=b7fe991a69ed2f9daae09463deea6bcedc0a19c4;hp=b80612638b860cf0bcdd2cabfbba9ead66b99ae4;hpb=59e711cbb69c258397c49827804e3904af0f3ce8;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.h b/dali/internal/graphics/gles-impl/egl-graphics-controller.h index b806126..6af7383 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.h +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.h @@ -22,26 +22,26 @@ #include // INTERNAL INCLUDES +#include #include -#include "gles-context.h" -#include "gles-graphics-buffer.h" -#include "gles-graphics-command-buffer.h" -#include "gles-graphics-framebuffer.h" -#include "gles-graphics-pipeline-cache.h" -#include "gles-graphics-pipeline.h" -#include "gles-graphics-reflection.h" -#include "gles-graphics-sampler.h" -#include "gles-graphics-shader.h" -#include "gles-graphics-texture.h" -#include "gles-graphics-types.h" -#include "gles2-graphics-memory.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace Dali { namespace Integration { class GlAbstraction; -class GlSyncAbstraction; class GlContextHelperAbstraction; } // namespace Integration @@ -58,7 +58,7 @@ class PipelineCache; * * Temporarily holds the old GL abstractions whilst dali-core is migrated to the new API. */ -DALI_IMPORT_API class EglGraphicsController : public Graphics::Controller +class EglGraphicsController : public Graphics::Controller { public: /** @@ -81,13 +81,13 @@ public: * * Note, this is now executed in the render thread, after core initialization */ - void Initialize(Integration::GlSyncAbstraction& glSyncAbstraction, + void Initialize(Integration::GraphicsSyncAbstraction& syncImplementation, Integration::GlContextHelperAbstraction& glContextHelperAbstraction, Internal::Adaptor::GraphicsInterface& graphicsInterface); - Integration::GlAbstraction& GetGlAbstraction() override; - Integration::GlSyncAbstraction& GetGlSyncAbstraction() override; - Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override; + Integration::GlAbstraction& GetGlAbstraction() override; + Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override; + Internal::Adaptor::EglSyncImplementation& GetEglSyncImplementation(); /** * @copydoc Dali::Graphics::SubmitCommandBuffers() @@ -135,6 +135,19 @@ public: { // Final flush Flush(); + + if(mContext) + { + mContext->GlContextDestroyed(); + } + + for(auto&& context : mSurfaceContexts) + { + if(context.second) + { + context.second->GlContextDestroyed(); + } + } } /** @@ -144,6 +157,11 @@ public: const std::vector& sourceList) override; /** + * @copydoc Dali::Graphics::GenerateTextureMipmaps() + */ + void GenerateTextureMipmaps(const Texture& texture) override; + + /** * @copydoc Dali::Graphics::EnableDepthStencilBuffer() */ bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override @@ -232,6 +250,12 @@ public: Graphics::UniquePtr CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr&& oldRenderTarget) override; /** + * @copydoc Dali::Graphics::CreateSyncObject() + */ + Graphics::UniquePtr CreateSyncObject(const SyncObjectCreateInfo& syncObjectCreateInfo, + Graphics::UniquePtr&& oldSyncObject) override; + + /** * @copydoc Dali::Graphics::MapBufferRange() */ Graphics::UniquePtr MapBufferRange(const MapBufferInfo& mapInfo) override; @@ -368,6 +392,30 @@ public: } /** + * @brief Pushes RenderPass to the discard queue + * + * Function is called from the UniquePtr custom deleter. + * + * @param[in] program Pointer to the RenderPass + */ + void DiscardResource(GLES::RenderPass* renderPass) + { + mDiscardRenderPassQueue.push(renderPass); + } + + /** + * @brief Pushes RenderTarget to the discard queue + * + * Function is called from the UniquePtr custom deleter. + * + * @param[in] program Pointer to the RenderTarget + */ + void DiscardResource(GLES::RenderTarget* renderTarget) + { + mDiscardRenderTargetQueue.push(renderTarget); + } + + /** * @brief Pushes Shader to the discard queue * * Function is called from the UniquePtr custom deleter. @@ -423,7 +471,14 @@ public: */ void Flush() { - mGraphics->ActivateResourceContext(); + if(!mCreateTextureQueue.empty() || + !mCreateBufferQueue.empty() || + !mCreateFramebufferQueue.empty() || + !mTextureUpdateRequests.empty() || + !mTextureMipmapGenerationRequests.empty()) + { + mGraphics->ActivateResourceContext(); + } // Process creations ProcessCreateQueues(); @@ -431,9 +486,18 @@ public: // Process updates ProcessTextureUpdateQueue(); + // Process texture mipmap generation requests + ProcessTextureMipmapGenerationQueue(); + // Process main command queue ProcessCommandQueues(); + // Reset texture cache in the contexts while destroying textures + ResetTextureCache(); + + // Reset buffer cache in the contexts while destroying buffers + ResetBufferCache(); + // Process discards ProcessDiscardQueues(); @@ -469,9 +533,9 @@ public: } /** - * @brief Processes a create queue for type specified + * @brief Processes a discard queue for type specified * - * @param[in,out] queue Reference to the create queue + * @param[in,out] queue Reference to the discard queue */ template void ProcessDiscardQueue(T& queue) @@ -502,6 +566,53 @@ public: } /** + * @brief Processes a discard queue for pipeline + * + * @param[in,out] queue Reference to the create queue + */ + void ProcessDiscardQueue(std::queue& queue) + { + while(!queue.empty()) + { + auto* object = const_cast(queue.front()); + + // Inform the contexts to invalidate the pipeline if cached + if(mContext) + { + mContext->InvalidateCachedPipeline(object); + } + + for(auto&& context : mSurfaceContexts) + { + if(context.second) + { + context.second->InvalidateCachedPipeline(object); + } + } + + // Destroy + object->DestroyResource(); + + // Free + auto* clbk = object->GetCreateInfo().allocationCallbacks; + if(clbk) + { + // Call destructor + using GLESPipeline = GLES::Pipeline; + object->~GLESPipeline(); + + // Free memory + clbk->freeCallback(object, clbk->userData); + } + else + { + delete object; + } + queue.pop(); + } + } + + /** * @brief Processes all resource create queues */ void ProcessCreateQueues(); @@ -517,6 +628,11 @@ public: void ProcessTextureUpdateQueue(); /** + * @brief Executes all pending texture mipmap generation + */ + void ProcessTextureMipmapGenerationQueue(); + + /** * @brief Returns program custom parameter * * This function can be used as a backdoor in order to retrieve @@ -543,9 +659,17 @@ public: */ GLES::GLESVersion GetGLESVersion() const { - // TODO: return proper version but for now we can - // test fallbacks - return GLES::GLESVersion::GLES_20; + return mGLESVersion; + } + + /** + * @brief Sets runtime supported GLES version + * + * @param[in] glesVersion The runtime supported GLES version + */ + void SetGLESVersion(GLES::GLESVersion glesVersion) + { + mGLESVersion = glesVersion; } bool IsShuttingDown() const @@ -553,17 +677,91 @@ public: return mIsShuttingDown; } + /** + * @brief Reset texture cache in the contexts + */ + void ResetTextureCache() + { + if(mContext) + { + mContext->GetGLStateCache().ResetTextureCache(); + } + + for(auto& context : mSurfaceContexts) + { + if(context.second) + { + context.second->GetGLStateCache().ResetTextureCache(); + } + } + } + + /** + * @brief Reset buffer cache in the contexts + */ + void ResetBufferCache() + { + if(mContext) + { + mContext->GetGLStateCache().ResetBufferCache(); + } + + for(auto& context : mSurfaceContexts) + { + if(context.second) + { + context.second->GetGLStateCache().ResetBufferCache(); + } + } + } + void ProcessCommandBuffer(const GLES::CommandBuffer& commandBuffer); // Resolves presentation void ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget); + /** + * Creates a GLES context for the given render surface + * + * @param[in] surface The surface whose GLES context to be created. + */ + void CreateSurfaceContext(Dali::RenderSurfaceInterface* surface); + + /** + * Deletes a GLES context + * + * @param[in] surface The surface whose GLES context to be deleted. + */ + void DeleteSurfaceContext(Dali::RenderSurfaceInterface* surface); + + /** + * Activate the resource context (shared surfaceless context) + */ + void ActivateResourceContext(); + + /** + * Activate the surface context + * + * @param[in] surface The surface whose context to be switched to. + */ + void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface); + + /** + * @brief Returns the current context + * + * @return the current context + */ + GLES::Context* GetCurrentContext() const + { + return mCurrentContext; + } + private: Integration::GlAbstraction* mGlAbstraction{nullptr}; - Integration::GlSyncAbstraction* mGlSyncAbstraction{nullptr}; Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr}; - Internal::Adaptor::GraphicsInterface* mGraphics{nullptr}; + Internal::Adaptor::EglSyncImplementation* mEglSyncImplementation{nullptr}; + Internal::Adaptor::GraphicsInterface* mGraphics{nullptr}; // Pointer to owning structure via interface. std::queue mCreateTextureQueue; ///< Create queue for texture resource std::queue mDiscardTextureQueue; ///< Discard queue for texture resource @@ -573,6 +771,8 @@ private: std::queue mDiscardProgramQueue; ///< Discard queue for program resource std::queue mDiscardPipelineQueue; ///< Discard queue of pipelines + std::queue mDiscardRenderPassQueue; ///< Discard queue for renderpass resource + std::queue mDiscardRenderTargetQueue; ///< Discard queue for rendertarget resource std::queue mDiscardShaderQueue; ///< Discard queue of shaders std::queue mDiscardSamplerQueue; ///< Discard queue of samplers std::queue mDiscardCommandBufferQueue; ///< Discard queue of command buffers @@ -584,14 +784,21 @@ private: using TextureUpdateRequest = std::pair; std::queue mTextureUpdateRequests; - std::unique_ptr mContext{nullptr}; ///< Context object handling command buffers execution + std::queue mTextureMipmapGenerationRequests; ///< Queue for texture mipmap generation requests + + GLES::Context* mCurrentContext{nullptr}; ///< The current context + std::unique_ptr mContext{nullptr}; ///< Context object handling command buffers execution + using SurfaceContextPair = std::pair>; + std::vector mSurfaceContexts; ///< Vector of surface context objects handling command buffers execution std::unique_ptr mPipelineCache{nullptr}; ///< Internal pipeline cache + GLES::GLESVersion mGLESVersion{GLES::GLESVersion::GLES_20}; ///< Runtime supported GLES version + uint32_t mTextureUploadTotalCPUMemoryUsed{0u}; + bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down - // todo: to be removed after renderpass - const Graphics::Framebuffer* currentFramebuffer{nullptr}; + std::queue mPresentationCommandBuffers{}; ///< Queue of reusable command buffers used by presentation engine }; } // namespace Graphics