#define DALI_INTERNAL_RENDER_RENDERER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
{
struct ShaderCache;
class PipelineCache;
+class PipelineCacheL2;
class UniformBufferManager;
-class PipelineCache;
+class Renderer;
+
+using RendererKey = MemoryPoolKey<Render::Renderer>;
+} //namespace Render
+} //namespace Internal
+
+// Ensure RendererKey can be used in Dali::Vector
+template<>
+struct TypeTraits<Internal::Render::RendererKey> : public BasicTypes<Internal::Render::RendererKey>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+namespace Internal
+{
+namespace Render
+{
/**
* Renderers are used to render meshes
* These objects are used during RenderManager::Render(), so properties modified during
};
/**
+ * @brief Global static initialize for Render::Renderer before new CommandBuffer's Render fill start.
+ */
+ static void PrepareCommandBuffer();
+
+ /**
* Create a new renderer instance
* @param[in] dataProviders The data providers for the renderer
* @param[in] geometry The geometry for the renderer
* @param[in] depthFunction Depth function
* @param[in] stencilParameters Struct containing all stencil related options
*/
- static Renderer* New(SceneGraph::RenderDataProvider* dataProviders,
- Render::Geometry* geometry,
- uint32_t blendingBitmask,
- const Vector4& blendColor,
- FaceCullingMode::Type faceCullingMode,
- bool preMultipliedAlphaEnabled,
- DepthWriteMode::Type depthWriteMode,
- DepthTestMode::Type depthTestMode,
- DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters);
+ static RendererKey NewKey(SceneGraph::RenderDataProvider* dataProviders,
+ Render::Geometry* geometry,
+ uint32_t blendingBitmask,
+ const Vector4& blendColor,
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction,
+ StencilParameters& stencilParameters);
/**
* Constructor.
StencilParameters& stencilParameters);
/**
- * Change the geometry used by the renderer
- * @param[in] geometry The new geometry
- */
- void SetGeometry(Render::Geometry* geometry);
-
- void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
-
- /**
- * @brief Returns a reference to an array of draw commands
- * @return Valid array of draw commands (may be empty)
- */
- [[nodiscard]] const std::vector<Dali::DevelRenderer::DrawCommand>& GetDrawCommands() const
- {
- return mDrawCommands;
- }
-
- /**
* Second-phase construction.
* This is called when the renderer is inside render thread
* @param[in] graphicsController The graphics controller to use
~Renderer();
/**
+ * Overriden delete operator
+ * Deletes the renderer from its global memory pool
+ */
+ void operator delete(void* ptr);
+
+ /**
+ * Get a pointer to the object from the given key.
+ * Used by MemoryPoolKey to provide pointer semantics.
+ */
+ static Renderer* Get(RendererKey::KeyType rendererKey);
+
+ /**
+ * Change the geometry used by the renderer
+ * @param[in] geometry The new geometry
+ */
+ void SetGeometry(Render::Geometry* geometry);
+
+ void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
+
+ /**
+ * @brief Returns a reference to an array of draw commands
+ * @return Valid array of draw commands (may be empty)
+ */
+ [[nodiscard]] const std::vector<Dali::DevelRenderer::DrawCommand>& GetDrawCommands() const
+ {
+ return mDrawCommands;
+ }
+
+ /**
* Set the face-culling mode.
* @param[in] mode The face-culling mode.
*/
*/
RenderCallbackInput& GetRenderCallbackInput()
{
- return mRenderCallbackInput;
+ if(!mRenderCallbackInput)
+ {
+ mRenderCallbackInput = std::unique_ptr<RenderCallbackInput>(new RenderCallbackInput);
+ }
+ return *mRenderCallbackInput;
}
/**
* Check if the renderer attributes/uniforms are updated and returns the flag
*
* @param[in] bufferIndex The current update buffer index.
- * @param[in] node The node using this renderer
*/
- bool Updated(BufferIndex bufferIndex, const SceneGraph::NodeDataProvider* node);
+ bool Updated(BufferIndex bufferIndex);
template<class T>
bool WriteDefaultUniform(const Graphics::UniformInfo* uniformInfo,
return mFaceCullingMode;
}
+ /**
+ * @brief Gets update area after visual properties applied.
+ *
+ * @param[in] bufferIndex The index of the previous update buffer.
+ * @param[in] originalUpdateArea The original update area before apply the visual properties.
+ *
+ * @return The recalculated update area after visual properties applied.
+ */
+ Vector4 GetVisualTransformedUpdateArea(BufferIndex bufferIndex, const Vector4& originalUpdateArea) const noexcept;
+
private:
struct UniformIndexMap;
std::vector<Graphics::UniformBufferBinding> mUniformBufferBindings{};
Render::PipelineCache* mPipelineCache{nullptr};
+ PipelineCacheL2* mPipeline{nullptr};
using Hash = std::size_t;
using UniformIndexMappings = std::vector<UniformIndexMap>;
std::vector<UniformIndexMappings> mUniformIndexMaps; ///< Cached map per node/renderer/shader.
- uint64_t mUniformsHash{0}; ///< Hash of uniform map property values
-
DepthFunction::Type mDepthFunction : 4; ///< The depth function
FaceCullingMode::Type mFaceCullingMode : 3; ///< The mode of face culling
DepthWriteMode::Type mDepthWriteMode : 3; ///< The depth write mode
DepthTestMode::Type mDepthTestMode : 3; ///< The depth test mode
bool mPremultipliedAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
bool mShaderChanged : 1; ///< Flag indicating the shader changed and uniform maps have to be updated
- bool mUpdated : 1;
std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands; // Devel stuff
RenderCallback* mRenderCallback{nullptr};
- RenderCallbackInput mRenderCallbackInput{};
+ std::unique_ptr<RenderCallbackInput> mRenderCallbackInput{nullptr};
std::vector<Graphics::Texture*> mRenderCallbackTextureBindings{};
};