-#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H
+#define DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
// INTERNAL INCLUDES
#include <dali/public-api/math/rect.h>
+#include <dali/integration-api/core-enumerations.h>
#include <dali/internal/common/shader-saver.h>
-#include <dali/internal/render/common/post-process-resource-dispatcher.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
#include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/event/rendering/texture-impl.h>
namespace Dali
{
namespace Integration
{
class GlAbstraction;
+class GlSyncAbstraction;
+class GlContextHelperAbstraction;
class RenderStatus;
+class Scene;
}
struct Vector4;
namespace Render
{
+class FrameBuffer;
class Renderer;
-class Sampler;
+struct Sampler;
+class RenderTracker;
+class Geometry;
+class Texture;
}
namespace SceneGraph
{
class RenderQueue;
-class TextureCache;
class RenderInstruction;
class RenderInstructionContainer;
-class RenderTracker;
class Shader;
-class RenderGeometry;
class PropertyBufferDataProvider;
+class Scene;
/**
* RenderManager is responsible for rendering the result of the previous "update", which
* is provided in a RenderCommand during UpdateManager::Update().
*/
-class RenderManager : public PostProcessResourceDispatcher
+class RenderManager
{
public:
/**
* Construct a new RenderManager.
- * @param[in] glAbstraction The GL abstraction used for rendering.
- * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.
+ * @param[in] glAbstraction The GL abstraction used for rendering.
+ * @param[in] glSyncAbstraction The GL sync abstraction used fence sync creation/deletion.
+ * @param[in] glContextHelperAbstraction The GL context helper abstraction for accessing GL context.
+ * @param[in] depthBufferAvailable Whether the depth buffer is available
+ * @param[in] stencilBufferAvailable Whether the stencil buffer is available
*/
- static RenderManager* New( Dali::Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQueue );
+ static RenderManager* New( Integration::GlAbstraction& glAbstraction,
+ Integration::GlSyncAbstraction& glSyncAbstraction,
+ Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable );
/**
* Non-virtual destructor; not intended as a base class
RenderQueue& GetRenderQueue();
/**
- * Retrieve the texture cache. Messages should only be sent to this from the update thread,
- * accessor methods should only be used from the render thread.
- * @return The texture cache
- */
- TextureCache& GetTextureCache();
-
- /**
* @copydoc Dali::Integration::Core::ContextCreated()
*/
void ContextCreated();
void ContextDestroyed();
/**
- * Dispatch requests onto the postProcessResourcesQueue
- * @param[in] request The request to dispatch
- */
- virtual void DispatchPostProcessRequest( ResourcePostProcessRequest& request );
-
- /**
* Set the upstream interface for compiled shader binaries to be sent back to for eventual
* caching and saving.
* @param[in] upstream The abstract interface to send any received ShaderDatas onwards to..
*/
void SetShaderSaver( ShaderSaver& upstream );
- /**
- * Retrieve the render instructions; these should be set during each "update" traversal.
- * @return The render instruction container.
- */
- RenderInstructionContainer& GetRenderInstructionContainer();
-
// The following methods should be called via RenderQueue messages
- /**
- * Set the background color i.e. the glClear color used at the beginning of each frame.
- * @param[in] color The new background color.
- */
- void SetBackgroundColor( const Vector4& color );
-
/*
* Set the frame time delta (time elapsed since the last frame.
* @param[in] deltaTime the delta time
* @param[in] renderer The renderer to add.
* @post renderer is owned by RenderManager
*/
- void AddRenderer( Render::Renderer* renderer );
+ void AddRenderer( OwnerPointer< Render::Renderer >& renderer );
/**
* Remove a Renderer from the render manager.
* @param[in] sampler The sampler to add.
* @post sampler is owned by RenderManager
*/
- void AddSampler( Render::Sampler* sampler );
+ void AddSampler( OwnerPointer< Render::Sampler >& sampler );
/**
* Remove a sampler from the render manager.
* @param[in] minFilterMode Filter mode to use when the texture is minificated
* @param[in] magFilterMode Filter mode to use when the texture is magnified
*/
- void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
+ void SetFilterMode( Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode );
/**
* Set wrapping mode for a sampler
+ * @param[in] rWrapMode Wrap mode in the z direction
* @param[in] uWrapMode Wrap mode in the x direction
* @param[in] vWrapMode Wrap mode in the y direction
*/
- void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
+ void SetWrapMode( Render::Sampler* sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode );
/**
* Add a property buffer to the render manager.
* @param[in] propertyBuffer The property buffer to add.
* @post propertBuffer is owned by RenderManager
*/
- void AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer );
+ void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer );
/**
* Remove a property buffer from the render manager.
* @param[in] geometry The geometry to add.
* @post geometry is owned by RenderManager
*/
- void AddGeometry( RenderGeometry* geometry );
+ void AddGeometry( OwnerPointer< Render::Geometry >& geometry );
/**
* Remove a geometry from the render manager.
* @param[in] geometry The geometry to remove.
* @post geometry is destroyed.
*/
- void RemoveGeometry( RenderGeometry* geometry );
+ void RemoveGeometry( Render::Geometry* geometry );
/**
- * Adds a property buffer to a RenderGeometry from the render manager.
+ * Adds a property buffer to a geometry from the render manager.
* @param[in] geometry The geometry
* @param[in] propertyBuffer The property buffer to remove.
- * @param[in] isIndexBuffer True if the property buffer is intended to be used as an index buffer
*/
- void AddPropertyBuffer( RenderGeometry* renderGeometry, Render::PropertyBuffer* propertyBuffer, bool isIndexBuffer );
+ void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
/**
- * Remove a property buffer from a RenderGeometry from the render manager.
+ * Remove a property buffer from a Render::Geometry from the render manager.
* @param[in] geometry The geometry
* @param[in] propertyBuffer The property buffer to remove.
* @post property buffer is destroyed.
*/
- void RemovePropertyBuffer( RenderGeometry* renderGeometry, Render::PropertyBuffer* propertyBuffer );
+ void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
/**
* Sets the format of an existing property buffer
* @param[in] propertyBuffer The property buffer.
* @param[in] format The new format of the buffer
*/
- void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format );
+ void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
/**
* Sets the data of an existing property buffer
* @param[in] propertyBuffer The property buffer.
* @param[in] data The new data of the buffer
+ * @param[in] size The new size of the buffer
*/
- void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data);
+ void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size );
/**
- * Sets the size of an existing property buffer
- * @param[in] propertyBuffer The property buffer.
- * @param[in] size The new size of the buffer
+ * Sets the data for the index buffer of an existing geometry
+ * @param[in] geometry The geometry
+ * @param[in] data A vector containing the indices
*/
- void SetPropertyBufferSize(Render::PropertyBuffer* propertyBuffer, size_t size );
+ void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<uint16_t>& data );
/**
* Set the geometry type of an existing render geometry
* @param[in] geometry The render geometry
* @param[in] geometryType The new geometry type
*/
- void SetGeometryType( RenderGeometry* geometry, int geometryType );
+ void SetGeometryType( Render::Geometry* geometry, uint32_t geometryType );
/**
- * Set if an existing geometry requires depth testing
- * @param[in] geometry The render geometry
- * @param[in] requiresDepthTest True if depth testing is required, false otherwise
+ * Adds a texture to the render manager
+ * @param[in] texture The texture to add
+ */
+ void AddTexture( OwnerPointer< Render::Texture >& texture );
+
+ /**
+ * Removes a texture from the render manager
+ * @param[in] texture The texture to remove
+ */
+ void RemoveTexture( Render::Texture* texture );
+
+ /**
+ * Uploads data to an existing texture
+ * @param[in] texture The texture
+ * @param[in] pixelData The pixel data object
+ * @param[in] params The parameters for the upload
+ */
+ void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
+
+ /**
+ * Generates mipmaps for a given texture
+ * @param[in] texture The texture
*/
- void SetGeometryRequiresDepthTest( RenderGeometry* geometry, bool requiresDepthTest );
+ void GenerateMipmaps( Render::Texture* texture );
+
+ /**
+ * Adds a framebuffer to the render manager
+ * @param[in] frameBuffer The framebuffer to add
+ */
+ void AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer );
+
+ /**
+ * Removes a framebuffer from the render manager
+ * @param[in] frameBuffer The framebuffer to remove
+ */
+ void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
+
+ /**
+ * Attaches a texture as color output to the existing frame buffer
+ * @param[in] frameBuffer The FrameBuffer
+ * @param[in] texture The texture that will be used as output when rendering
+ * @param[in] mipmapLevel The mipmap of the texture to be attached
+ * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
+ */
+ void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer );
+
+ /**
+ * Attaches a texture as depth output to the existing frame buffer
+ * @param[in] frameBuffer The FrameBuffer
+ * @param[in] texture The texture that will be used as output when rendering
+ * @param[in] mipmapLevel The mipmap of the texture to be attached
+ */
+ void AttachDepthTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel );
+
+ /**
+ * Attaches a texture as depth/stencil output to the existing frame buffer
+ * @param[in] frameBuffer The FrameBuffer
+ * @param[in] texture The texture that will be used as output when rendering
+ * @param[in] mipmapLevel The mipmap of the texture to be attached
+ */
+ void AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel );
+
+ /**
+ * Initializes a Scene to the render manager
+ * @param[in] scene The Scene to initialize
+ */
+ void InitializeScene( SceneGraph::Scene* scene );
+
+ /**
+ * Uninitializes a Scene to the render manager
+ * @param[in] scene The Scene to uninitialize
+ */
+ void UninitializeScene( SceneGraph::Scene* scene );
+
+ /**
+ * This is called when the surface of the scene has been replaced.
+ * @param[in] scene The scene.
+ */
+ void SurfaceReplaced( SceneGraph::Scene* scene );
/**
* Adds a render tracker to the RenderManager. RenderManager takes ownership of the
* object, usually an offscreen render task.
* @param[in] renderTracker The render tracker
*/
- void AddRenderTracker( RenderTracker* renderTracker );
+ void AddRenderTracker( Render::RenderTracker* renderTracker );
/**
* Removes a render tracker from the RenderManager.
* @param[in] renderTracker The render tracker to remove.
*/
- void RemoveRenderTracker( RenderTracker* renderTracker );
-
- /**
- * Set the default shader that is to be used in absence of custom shader
- * @param[in] shader that is the default one
- */
- void SetDefaultShader( Shader* shader );
+ void RemoveRenderTracker( Render::RenderTracker* renderTracker );
/**
* returns the Program controller for sending program messages
*/
ProgramCache* GetProgramCache();
- // This method should be called from Core::Render()
+ // This method should be called from Core::PreRender()
/**
- * Renders the results of the previous "update" traversal.
- * @param[out] status contains the flag that indicates if render instructions exist
- * @return true if a further update is required
+ * This is called before rendering any scene in the next frame. This method should be preceded
+ * by a call up Update.
+ * Multi-threading note: this method should be called from a dedicated rendering thread.
+ * @pre The GL context must have been created, and made current.
+ * @param[out] status showing whether update is required to run.
+ * @param[in] forceClear force the Clear on the framebuffer even if nothing is rendered.
+ * @param[in] uploadOnly uploadOnly Upload the resource only without rendering.
*/
- bool Render( Integration::RenderStatus& status );
+ void PreRender( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
-private:
+ // This method should be called from Core::RenderScene()
/**
- * Helper to process a single RenderInstruction.
- * @param[in] instruction A description of the rendering operation.
- * @param[in] defaultShader default shader to use.
+ * Render a scene in the next frame. This method should be preceded by a call up PreRender.
+ * This method should be called twice. The first pass to render off-screen frame buffers if any,
+ * and the second pass to render the surface.
+ * Multi-threading note: this method should be called from a dedicated rendering thread.
+ * @pre The GL context must have been created, and made current.
+ * @param[in] scene The scene to be rendered.
+ * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only.
*/
- void DoRender( RenderInstruction& instruction, Shader& defaultShader );
+ void RenderScene( Integration::Scene& scene, bool renderToFbo );
+
+ // This method should be called from Core::PostRender()
+
+ /**
+ * This is called after rendering all the scenes in the next frame. This method should be
+ * followed by a call up RenderScene.
+ * Multi-threading note: this method should be called from a dedicated rendering thread.
+ * @pre The GL context must have been created, and made current.
+ * @param[in] uploadOnly uploadOnly Upload the resource only without rendering.
+ */
+ void PostRender( bool uploadOnly );
+
+
+private:
private:
} // namespace Dali
-#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H