{
// Final flush
Flush();
+
+ ClearTextureUpdateQueue();
+
+ // Remove all create queue and command queue.
+ // Note that all memory are already deallocated at Final flush.
+ mCreateTextureQueue = {};
+ mCreateBufferQueue = {};
+ mCreateFramebufferQueue = {};
+ mTextureMipmapGenerationRequests = {};
+ mCommandQueue = {};
+
+ if(mContext)
+ {
+ mContext->GlContextDestroyed();
+ }
+
+ for(auto&& context : mSurfaceContexts)
+ {
+ if(context.second)
+ {
+ context.second->GlContextDestroyed();
+ }
+ }
}
/**
}
/**
+ * @brief Clears the texture update queue
+ */
+ void ClearTextureUpdateQueue()
+ {
+ // Remove remained CPU-allocated texture memory
+ while(!mTextureUpdateRequests.empty())
+ {
+ auto& request = mTextureUpdateRequests.front();
+ auto& source = request.second;
+
+ if(source.sourceType == Graphics::TextureUpdateSourceInfo::Type::MEMORY)
+ {
+ // free staging memory
+ free(source.memorySource.memory);
+ }
+ mTextureUpdateRequests.pop();
+ }
+ }
+
+ /**
* @brief Flushes all pending updates
*
* Function flushes all pending resource constructions,
*/
void Flush()
{
- mGraphics->ActivateResourceContext();
+ if(DALI_LIKELY(!mIsShuttingDown))
+ {
+ if(!mCreateTextureQueue.empty() ||
+ !mCreateBufferQueue.empty() ||
+ !mCreateFramebufferQueue.empty() ||
+ !mTextureUpdateRequests.empty() ||
+ !mTextureMipmapGenerationRequests.empty())
+ {
+ mGraphics->ActivateResourceContext();
+ }
- // Process creations
- ProcessCreateQueues();
+ // Process creations
+ ProcessCreateQueues();
- // Process updates
- ProcessTextureUpdateQueue();
+ // Process updates
+ ProcessTextureUpdateQueue();
- // Process texture mipmap generation requests
- ProcessTextureMipmapGenerationQueue();
+ // Process texture mipmap generation requests
+ ProcessTextureMipmapGenerationQueue();
- // Process main command queue
- ProcessCommandQueues();
+ // 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();
}
/**
- * @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<class U, class T>
void ProcessDiscardQueue(T& queue)
}
/**
+ * @brief Processes a discard queue for pipeline
+ *
+ * @param[in,out] queue Reference to the create queue
+ */
+ void ProcessDiscardQueue(std::queue<GLES::Pipeline*>& queue)
+ {
+ while(!queue.empty())
+ {
+ auto* object = const_cast<GLES::Pipeline*>(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();
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 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::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr};
- Internal::Adaptor::EglSyncImplementation* mEglSyncImplementation;
+ Internal::Adaptor::EglSyncImplementation* mEglSyncImplementation{nullptr};
Internal::Adaptor::GraphicsInterface* mGraphics{nullptr}; // Pointer to owning structure via interface.
std::queue<GLES::Texture*> mCreateTextureQueue; ///< Create queue for texture resource
bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down
- // todo: to be removed after renderpass
- const Graphics::Framebuffer* currentFramebuffer{nullptr};
+ std::queue<const GLES::CommandBuffer*> mPresentationCommandBuffers{}; ///< Queue of reusable command buffers used by presentation engine
};
} // namespace Graphics