#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/common/render-manager.h>
-using Dali::Internal::SceneGraph::DiscardQueue;
using Dali::Internal::SceneGraph::RenderManager;
using Dali::Internal::SceneGraph::RenderQueue;
using Dali::Internal::SceneGraph::UpdateManager;
RenderQueue& renderQueue = mRenderManager->GetRenderQueue();
- mDiscardQueue = new DiscardQueue(renderQueue);
-
mUpdateManager = new UpdateManager(*mNotificationManager,
*mAnimationPlaylist,
*mPropertyNotificationManager,
- *mDiscardQueue,
renderController,
*mRenderManager,
renderQueue,
{
class UpdateManager;
class RenderManager;
-class DiscardQueue;
class RenderTaskProcessor;
} // namespace SceneGraph
OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
- OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
${internal_src_dir}/update/animation/scene-graph-animation.cpp
${internal_src_dir}/update/animation/scene-graph-constraint-base.cpp
${internal_src_dir}/update/common/collected-uniform-map.cpp
- ${internal_src_dir}/update/common/discard-queue.cpp
${internal_src_dir}/update/common/property-base.cpp
${internal_src_dir}/update/common/property-owner-messages.cpp
${internal_src_dir}/update/common/property-condition-functions.cpp
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/common/discard-queue.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/message.h>
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/renderers/render-renderer.h>
-#include <dali/internal/render/shaders/render-shader.h>
-#include <dali/internal/update/common/scene-graph-scene.h>
-#include <dali/internal/update/nodes/node.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-DiscardQueue::DiscardQueue(RenderQueue& renderQueue)
-: mRenderQueue(renderQueue),
- mNodeQueue(),
- mShaderQueue(),
- mRendererQueue(),
- mSceneQueue()
-{
-}
-
-DiscardQueue::~DiscardQueue() = default;
-
-void DiscardQueue::Add(BufferIndex updateBufferIndex, Node* node)
-{
- DALI_ASSERT_DEBUG(NULL != node);
-
- // The GL resources will now be freed in frame N
- // The Update for frame N+1 may occur in parallel with the rendering of frame N
- // Queue the node for destruction in frame N+2
- mNodeQueue[updateBufferIndex].PushBack(node);
-}
-
-void DiscardQueue::Add(BufferIndex updateBufferIndex, Shader* shader)
-{
- DALI_ASSERT_DEBUG(NULL != shader);
-
- // Programs are cached for the lifetime of DALi so no need for GL cleanup for shader for now.
-
- // The GL resources will now be freed in frame N
- // The Update for frame N+1 may occur in parallel with the rendering of frame N
- // Queue the node for destruction in frame N+2
- mShaderQueue[updateBufferIndex].PushBack(shader);
-}
-
-void DiscardQueue::Add(BufferIndex updateBufferIndex, Renderer* renderer)
-{
- DALI_ASSERT_DEBUG(NULL != renderer);
-
- // The GL resources will now be freed in frame N
- // The Update for frame N+1 may occur in parallel with the rendering of frame N
- // Queue the node for destruction in frame N+2
- mRendererQueue[updateBufferIndex].PushBack(renderer);
-}
-
-void DiscardQueue::Add(BufferIndex updateBufferIndex, Scene* scene)
-{
- DALI_ASSERT_DEBUG(NULL != scene);
-
- mSceneQueue[updateBufferIndex].PushBack(scene);
-}
-
-void DiscardQueue::Clear(BufferIndex updateBufferIndex)
-{
- // Destroy some discarded objects; these should no longer own any GL resources
- mNodeQueue[updateBufferIndex].Clear();
- mRendererQueue[updateBufferIndex].Clear();
- mShaderQueue[updateBufferIndex].Clear();
- mSceneQueue[updateBufferIndex].Clear();
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
*/
// INTERNAL INCLUDES
-#include <dali/devel-api/common/owner-container.h>
#include <dali/internal/common/buffer-index.h>
-#include <dali/internal/update/nodes/node-declarations.h>
-#include <dali/internal/update/rendering/scene-graph-renderer.h>
-#include <dali/internal/update/rendering/scene-graph-texture-set.h>
-#include <dali/public-api/object/ref-object.h>
namespace Dali
{
{
namespace SceneGraph
{
-class RenderQueue;
-class Shader;
-class Camera;
-class Scene;
-
-/**
- * DiscardQueue is used to cleanup nodes & resources when no longer in use.
- * Unwanted objects are added here during UpdateManager::Update().
- * When added, messages will be sent to clean-up GL resources in the next Render.
- * The Update for frame N+1 may occur in parallel with the rendering of frame N.
- * Therefore objects queued for destruction in frame N, are destroyed frame N+2.
- */
+template<class Type, class TypeContainer>
class DiscardQueue
{
public:
- using ShaderQueue = OwnerContainer<Shader*>;
- using RendererQueue = OwnerContainer<Renderer*>;
- using SceneQueue = OwnerContainer<Scene*>;
-
- /**
- * Create a new DiscardQueue.
- * @param[in] renderQueue Used to send GL clean-up messages for the next Render.
- */
- DiscardQueue(RenderQueue& renderQueue);
-
- /**
- * Non-virtual destructor; DiscardQueue is not suitable as a base class.
- */
- ~DiscardQueue();
-
- /**
- * Adds an unwanted Node and its children to the discard queue.
- * If necessary, a message will be sent to clean-up GL resources in the next Render.
- * @pre This method is not thread-safe, and should only be called from the update-thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] node The discarded node; DiscardQueue takes ownership.
- */
- void Add(BufferIndex updateBufferIndex, Node* node);
-
- /**
- * Adds an unwanted shader to the discard queue.
- * A message will be sent to clean-up GL resources in the next Render.
- * @pre This method is not thread-safe, and should only be called from the update-thread.
- * @param[in] bufferIndex The current update buffer index.
- * @param[in] shader The shader to queue; DiscardQueue takes ownership.
- */
- void Add(BufferIndex bufferIndex, Shader* shader);
-
- /**
- * Adds an unwanted Renderer to the discard queue.
- * A message will be sent to clean up GL resources in the next Render.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] renderer The discarded renderer; DiscardQueue takes ownership.
- */
- void Add(BufferIndex updateBufferIndex, Renderer* renderer);
-
- /**
- * Adds an unwanted Scene to the discard queue.
- * A message will be sent to clean up GL resources in the next Render.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] scene The discarded scene; DiscardQueue takes ownership.
- */
- void Add(BufferIndex updateBufferIndex, Scene* scene);
-
- /**
- * Release the nodes which were queued in the frame N-2.
- * @pre This method should be called (once) at the beginning of every Update.
- * @param[in] updateBufferIndex The current update buffer index.
- */
- void Clear(BufferIndex updateBufferIndex);
-
-private:
- // Undefined
- DiscardQueue(const DiscardQueue&);
-
- // Undefined
- DiscardQueue& operator=(const DiscardQueue& rhs);
+ DiscardQueue() = default;
+
+ void Add(BufferIndex updateBufferIndex, Type object)
+ {
+ mDiscardQueue[updateBufferIndex].PushBack(object);
+ }
+ void add(BufferIndex updateBufferIndex, Type object)
+ {
+ mDiscardQueue[updateBufferIndex].push_back(object);
+ }
+ void Clear(BufferIndex updateBufferIndex)
+ {
+ mDiscardQueue[updateBufferIndex].Clear();
+ }
+ void clear(BufferIndex updateBufferIndex)
+ {
+ mDiscardQueue[updateBufferIndex].clear();
+ }
private:
- RenderQueue& mRenderQueue; ///< Used to send GL clean-up messages for the next Render.
-
- // Messages are queued here following the current update buffer number
- OwnerContainer<Node*> mNodeQueue[2];
- ShaderQueue mShaderQueue[2];
- RendererQueue mRendererQueue[2];
- SceneQueue mSceneQueue[2];
+ TypeContainer mDiscardQueue[2];
};
} // namespace SceneGraph
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
namespace SceneGraph
{
SceneControllerImpl::SceneControllerImpl(RenderMessageDispatcher& renderMessageDispatcher,
- RenderQueue& renderQueue,
- DiscardQueue& discardQueue)
+ RenderQueue& renderQueue)
: mRenderMessageDispatcher(renderMessageDispatcher),
- mRenderQueue(renderQueue),
- mDiscardQueue(discardQueue)
+ mRenderQueue(renderQueue)
{
}
#define DALI_INTERNAL_SCENE_GRAPH_SCENE_CONTROLLER_IMPL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Constructor
* @param[in] rendererDispatcher Used for passing ownership of renderers to the render-thread.
* @param[in] renderQueue The renderQueue
- * @param[in] discardQueue The discardQueue
*/
SceneControllerImpl(RenderMessageDispatcher& renderMessageDispatcher,
- RenderQueue& renderQueue,
- DiscardQueue& discardQueue);
+ RenderQueue& renderQueue);
/**
* Destructor
return mRenderQueue;
}
- /**
- * @copydoc SceneController::GetDiscardQueue()
- */
- DiscardQueue& GetDiscardQueue() override
- {
- return mDiscardQueue;
- }
-
private:
// Undefined copy constructor.
SceneControllerImpl(const SceneControllerImpl&);
private:
RenderMessageDispatcher& mRenderMessageDispatcher; ///< Used for passing messages to the render-thread
RenderQueue& mRenderQueue; ///< render queue
- DiscardQueue& mDiscardQueue; ///< discard queue
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_SCENE_CONTROLLER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
class RenderMessageDispatcher;
class RenderQueue;
-class DiscardQueue;
/**
* Abstract interface for the scene controller
*/
virtual RenderQueue& GetRenderQueue() = 0;
- /**
- * Return the discard queue
- * @return A reference to the discard queue
- */
- virtual DiscardQueue& GetDiscardQueue() = 0;
-
private:
// Undefined copy constructor.
SceneController(const SceneController&);
* @param discardQueue to put the object to
* @param updateBufferIndex to use
*/
-template<class T>
-inline void EraseUsingDiscardQueue(OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex)
+template<class Type>
+inline void EraseUsingDiscardQueue(OwnerContainer<Type*>& container, Type* object, DiscardQueue<Type*, OwnerContainer<Type*>>& discardQueue, BufferIndex updateBufferIndex)
{
DALI_ASSERT_DEBUG(object && "NULL object not allowed");
Impl(NotificationManager& notificationManager,
CompleteNotificationInterface& animationPlaylist,
PropertyNotifier& propertyNotifier,
- DiscardQueue& discardQueue,
RenderController& renderController,
RenderManager& renderManager,
RenderQueue& renderQueue,
animationPlaylist(animationPlaylist),
propertyNotifier(propertyNotifier),
shaderSaver(nullptr),
- discardQueue(discardQueue),
renderController(renderController),
sceneController(nullptr),
renderManager(renderManager),
renderersAdded(false),
renderingRequired(false)
{
- sceneController = new SceneControllerImpl(renderMessageDispatcher, renderQueue, discardQueue);
+ sceneController = new SceneControllerImpl(renderMessageDispatcher, renderQueue);
// create first 'dummy' node
nodes.PushBack(nullptr);
CompleteNotificationInterface& animationPlaylist; ///< Holds handles to all the animations
PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified.
ShaderSaver* shaderSaver; ///< Saves shader binaries.
- DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph.
RenderController& renderController; ///< render controller
SceneControllerImpl* sceneController; ///< scene controller
RenderManager& renderManager; ///< This is responsible for rendering the results of each "update"
OwnerContainer<Renderer*> renderers; ///< A container of owned renderers
OwnerContainer<TextureSet*> textureSets; ///< A container of owned texture sets
OwnerContainer<Shader*> shaders; ///< A container of owned shaders
- OwnerPointer<PanGesture> panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
+
+ DiscardQueue<Node*, OwnerContainer<Node*>> nodeDiscardQueue; ///< Nodes are added here when disconnected from the scene-graph.
+ DiscardQueue<Shader*, OwnerContainer<Shader*>> shaderDiscardQueue;
+ DiscardQueue<Renderer*, OwnerContainer<Renderer*>> rendererDiscardQueue;
+ DiscardQueue<Scene*, OwnerContainer<Scene*>> sceneDiscardQueue;
+
+ OwnerPointer<PanGesture> panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
MessageQueue messageQueue; ///< The messages queued from the event-thread
std::vector<Internal::ShaderDataPtr> renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
UpdateManager::UpdateManager(NotificationManager& notificationManager,
CompleteNotificationInterface& animationFinishedNotifier,
PropertyNotifier& propertyNotifier,
- DiscardQueue& discardQueue,
RenderController& controller,
RenderManager& renderManager,
RenderQueue& renderQueue,
mImpl = new Impl(notificationManager,
animationFinishedNotifier,
propertyNotifier,
- discardQueue,
controller,
renderManager,
renderQueue,
}
}
- mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), layer);
+ mImpl->nodeDiscardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), layer);
// Notify the layer about impending destruction
layer->OnDestroy();
RemoveCamera(static_cast<Camera*>(node));
}
- mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), node);
+ mImpl->nodeDiscardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), node);
// Notify the Node about impending destruction
node->OnDestroy();
{
if(sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene)
{
- mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release()); // take the address of the reference to a pointer
+ mImpl->sceneDiscardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release()); // take the address of the reference to a pointer
break;
}
}
void UpdateManager::RemoveShader(Shader* shader)
{
// Find the shader and destroy it
- EraseUsingDiscardQueue(mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
+ EraseUsingDiscardQueue(mImpl->shaders, shader, mImpl->shaderDiscardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
}
void UpdateManager::SaveBinary(Internal::ShaderDataPtr shaderData)
DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] RemoveRenderer\n", renderer);
// Find the renderer and destroy it
- EraseUsingDiscardQueue(mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
+ EraseUsingDiscardQueue(mImpl->renderers, renderer, mImpl->rendererDiscardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
// Need to remove the render object as well
renderer->DisconnectFromSceneGraph(*mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex());
}
const BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
// Clear nodes/resources which were previously discarded
- mImpl->discardQueue.Clear(bufferIndex);
+ mImpl->nodeDiscardQueue.Clear(bufferIndex);
+ mImpl->shaderDiscardQueue.Clear(bufferIndex);
+ mImpl->rendererDiscardQueue.Clear(bufferIndex);
+ mImpl->sceneDiscardQueue.Clear(bufferIndex);
bool isAnimationRunning = IsAnimationRunning();
void UpdateManager::AddSampler(OwnerPointer<Render::Sampler>& sampler)
{
// Message has ownership of Sampler while in transit from update to render
- using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Sampler> >;
+ using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Sampler>>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
void UpdateManager::AddVertexBuffer(OwnerPointer<Render::VertexBuffer>& vertexBuffer)
{
// Message has ownership of format while in transit from update -> render
- using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::VertexBuffer> >;
+ using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::VertexBuffer>>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
void UpdateManager::SetVertexBufferFormat(Render::VertexBuffer* vertexBuffer, OwnerPointer<Render::VertexBuffer::Format>& format)
{
// Message has ownership of format while in transit from update -> render
- using DerivedType = MessageValue2<RenderManager, Render::VertexBuffer*, OwnerPointer<Render::VertexBuffer::Format> >;
+ using DerivedType = MessageValue2<RenderManager, Render::VertexBuffer*, OwnerPointer<Render::VertexBuffer::Format>>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetVertexBufferFormat, vertexBuffer, format);
}
-void UpdateManager::SetVertexBufferData(Render::VertexBuffer* vertexBuffer, OwnerPointer<Vector<uint8_t> >& data, uint32_t size)
+void UpdateManager::SetVertexBufferData(Render::VertexBuffer* vertexBuffer, OwnerPointer<Vector<uint8_t>>& data, uint32_t size)
{
// Message has ownership of format while in transit from update -> render
- using DerivedType = MessageValue3<RenderManager, Render::VertexBuffer*, OwnerPointer<Dali::Vector<uint8_t> >, uint32_t>;
+ using DerivedType = MessageValue3<RenderManager, Render::VertexBuffer*, OwnerPointer<Dali::Vector<uint8_t>>, uint32_t>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
void UpdateManager::AddGeometry(OwnerPointer<Render::Geometry>& geometry)
{
// Message has ownership of format while in transit from update -> render
- using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Geometry> >;
+ using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Geometry>>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
void UpdateManager::AddTexture(OwnerPointer<Render::Texture>& texture)
{
// Message has ownership of Texture while in transit from update -> render
- using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Texture> >;
+ using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Texture>>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
void UpdateManager::AddFrameBuffer(OwnerPointer<Render::FrameBuffer>& frameBuffer)
{
- using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::FrameBuffer> >;
+ using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::FrameBuffer>>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
namespace SceneGraph
{
class Animation;
-class DiscardQueue;
class RenderManager;
class RenderTaskList;
class RenderTaskProcessor;
* @param[in] notificationManager This should be notified when animations have finished.
* @param[in] animationPlaylist The CompleteNotificationInterface that handles the animations
* @param[in] propertyNotifier The PropertyNotifier
- * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
* @param[in] controller After messages are flushed, we request a render from the RenderController.
* @param[in] renderManager This is responsible for rendering the results of each "update".
* @param[in] renderQueue Used to queue messages for the next render.
UpdateManager(NotificationManager& notificationManager,
CompleteNotificationInterface& animationPlaylist,
PropertyNotifier& propertyNotifier,
- DiscardQueue& discardQueue,
Integration::RenderController& controller,
RenderManager& renderManager,
RenderQueue& renderQueue,
namespace SceneGraph
{
-class DiscardQueue;
class Layer;
class RenderTask;
class UpdateManager;