#define DALI_INTERNAL_RENDER_RENDERER_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.
#include <dali/public-api/math/matrix.h>
#include <dali/public-api/math/vector4.h>
#include <dali/public-api/rendering/texture-set.h>
+#include <dali/public-api/signals/render-callback.h>
#include <dali/graphics-api/graphics-controller.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/common/type-abstraction-enums.h>
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/render/data-providers/render-data-provider.h>
-#include <dali/internal/render/gl-resources/gl-resource-owner.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/render/renderers/uniform-buffer-manager.h>
#include <dali/internal/render/shaders/program.h>
class SceneController;
class Shader;
class NodeDataProvider;
-
-class RenderInstruction; //for relfection effect
+class RenderInstruction; //for reflection effect
} // namespace SceneGraph
namespace Render
{
struct ShaderCache;
+class PipelineCache;
class UniformBufferManager;
+class PipelineCache;
/**
* Renderers are used to render meshes
* @param[in] dataProviders The data providers for the renderer
* @param[in] geometry The geometry for the renderer
* @param[in] blendingBitmask A bitmask of blending options.
- * @param[in] blendColor The blend color to pass to GL
+ * @param[in] blendColor The blend color
* @param[in] faceCullingMode The face-culling mode.
* @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied.
* @param[in] depthWriteMode Depth buffer write mode
* @param[in] dataProviders The data providers for the renderer
* @param[in] geometry The geometry for the renderer
* @param[in] blendingBitmask A bitmask of blending options.
- * @param[in] blendColor The blend color to pass to GL
+ * @param[in] blendColor The blend color
* @param[in] faceCullingMode The face-culling mode.
* @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied.
* @param[in] depthWriteMode Depth buffer write mode
* @brief Returns a reference to an array of draw commands
* @return Valid array of draw commands (may be empty)
*/
- const std::vector<Dali::DevelRenderer::DrawCommand>& GetDrawCommands() const
+ [[nodiscard]] const std::vector<Dali::DevelRenderer::DrawCommand>& GetDrawCommands() const
{
return mDrawCommands;
}
* @param[in] programCache Cache of program objects
* @param[in] shaderCache Cache of shaders
* @param[in] uniformBufferManager Uniform buffer manager
+ * @param[in] pipelineCache Cache of pipelines
*/
void Initialize(Graphics::Controller& graphicsController,
ProgramCache& programCache,
Render::ShaderCache& shaderCache,
- Render::UniformBufferManager& uniformBufferManager);
+ Render::UniformBufferManager& uniformBufferManager,
+ Render::PipelineCache& pipelineCache);
/**
* Destructor
/**
* Set the blend color for blending options
- * @param[in] blendColor The blend color to pass to GL
+ * @param[in] blendColor The blend color
*/
void SetBlendColor(const Vector4& color);
* Query the Renderer's depth write mode
* @return The renderer depth write mode
*/
- DepthWriteMode::Type GetDepthWriteMode() const;
+ [[nodiscard]] DepthWriteMode::Type GetDepthWriteMode() const;
/**
* Sets the depth test mode
* Query the Renderer's depth test mode
* @return The renderer depth test mode
*/
- DepthTestMode::Type GetDepthTestMode() const;
+ [[nodiscard]] DepthTestMode::Type GetDepthTestMode() const;
/**
* Sets the depth function
* Query the Renderer's depth function
* @return The renderer depth function
*/
- DepthFunction::Type GetDepthFunction() const;
+ [[nodiscard]] DepthFunction::Type GetDepthFunction() const;
/**
* Sets the render mode
* Gets the render mode
* @return The render mode
*/
- RenderMode::Type GetRenderMode() const;
+ [[nodiscard]] RenderMode::Type GetRenderMode() const;
/**
* Sets the stencil function
* Gets the stencil function
* @return The stencil function
*/
- StencilFunction::Type GetStencilFunction() const;
+ [[nodiscard]] StencilFunction::Type GetStencilFunction() const;
/**
* Sets the stencil function mask
* Gets the stencil function mask
* @return The stencil function mask
*/
- int GetStencilFunctionMask() const;
+ [[nodiscard]] int GetStencilFunctionMask() const;
/**
* Sets the stencil function reference
* Gets the stencil function reference
* @return The stencil function reference
*/
- int GetStencilFunctionReference() const;
+ [[nodiscard]] int GetStencilFunctionReference() const;
/**
* Sets the stencil mask
* Gets the stencil mask
* @return The stencil mask
*/
- int GetStencilMask() const;
+ [[nodiscard]] int GetStencilMask() const;
/**
* Sets the stencil operation for when the stencil test fails
* Gets the stencil operation for when the stencil test fails
* @return The stencil operation
*/
- StencilOperation::Type GetStencilOperationOnFail() const;
+ [[nodiscard]] StencilOperation::Type GetStencilOperationOnFail() const;
/**
* Sets the stencil operation for when the depth test fails
* Gets the stencil operation for when the depth test fails
* @return The stencil operation
*/
- StencilOperation::Type GetStencilOperationOnZFail() const;
+ [[nodiscard]] StencilOperation::Type GetStencilOperationOnZFail() const;
/**
* Sets the stencil operation for when the depth test passes
* Gets the stencil operation for when the depth test passes
* @return The stencil operation
*/
- StencilOperation::Type GetStencilOperationOnZPass() const;
+ [[nodiscard]] StencilOperation::Type GetStencilOperationOnZPass() const;
/**
* Called to upload during RenderManager::Render().
uint32_t queueIndex);
/**
+ * Sets RenderCallback object
+ *
+ * @param[in] callback Valid pointer to RenderCallback object
+ */
+ void SetRenderCallback(RenderCallback* callback);
+
+ /**
+ * Returns currently set RenderCallback object
+ *
+ * @return Valid pointer to RenderCallback object or nullptr
+ */
+ RenderCallback* GetRenderCallback()
+ {
+ return mRenderCallback;
+ }
+
+ /**
* Write the renderer's sort attributes to the passed in reference
*
- * @param[in] bufferIndex The current update buffer index.
* @param[out] sortAttributes
*/
- void SetSortAttributes(BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const;
+ void SetSortAttributes(SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const;
/**
* Sets the flag indicating whether shader changed.
bool Updated(BufferIndex bufferIndex, const SceneGraph::NodeDataProvider* node);
template<class T>
- bool WriteDefaultUniform(const Graphics::UniformInfo* uniformInfo,
- Render::UniformBuffer& ubo,
- const std::vector<Graphics::UniformBufferBinding>& bindings,
- const T& data);
+ bool WriteDefaultUniform(const Graphics::UniformInfo* uniformInfo,
+ Render::UniformBufferView& ubo,
+ const T& data);
template<class T>
- void WriteUniform(Render::UniformBuffer& ubo,
- const std::vector<Graphics::UniformBufferBinding>& bindings,
- const Graphics::UniformInfo& uniformInfo,
- const T& data);
+ void WriteUniform(Render::UniformBufferView& ubo,
+ const Graphics::UniformInfo& uniformInfo,
+ const T& data);
- void WriteUniform(Render::UniformBuffer& ubo,
- const std::vector<Graphics::UniformBufferBinding>& bindings,
- const Graphics::UniformInfo& uniformInfo,
- const void* data,
- uint32_t size);
+ void WriteUniform(Render::UniformBufferView& ubo,
+ const Graphics::UniformInfo& uniformInfo,
+ const void* data,
+ uint32_t size);
- /**
- * Returns the pointer to valid command buffer
- *
- * CommandBuffer associated with Renderer contains baked commands
- * needed to issue draw call for this renderer.
- *
- * @return Pointer to valid CommandBuffer
- */
- [[nodiscard]] Graphics::CommandBuffer* GetGraphicsCommandBuffer() const
+ [[nodiscard]] FaceCullingMode::Type GetFaceCullMode() const
{
- return mGraphicsCommandBuffer.get();
+ return mFaceCullingMode;
}
private:
*/
void FillUniformBuffer(Program& program,
const SceneGraph::RenderInstruction& instruction,
- Render::UniformBuffer& ubo,
+ Render::UniformBufferView& ubo,
std::vector<Graphics::UniformBufferBinding>*& outBindings,
uint32_t& offset,
BufferIndex updateBufferIndex);
private:
- Graphics::Controller* mGraphicsController;
- OwnerPointer<SceneGraph::RenderDataProvider> mRenderDataProvider;
+ Graphics::Controller* mGraphicsController;
+ SceneGraph::RenderDataProvider* mRenderDataProvider;
- Context* mContext;
Render::Geometry* mGeometry;
- Graphics::UniquePtr<Graphics::CommandBuffer> mGraphicsCommandBuffer{};
-
ProgramCache* mProgramCache{nullptr};
Render::ShaderCache* mShaderCache{nullptr};
Render::UniformBufferManager* mUniformBufferManager{};
std::vector<Graphics::UniformBufferBinding> mUniformBufferBindings{};
- std::vector<Graphics::ShaderState> mShaderStates{};
+ Render::PipelineCache* mPipelineCache{nullptr};
using Hash = unsigned long;
+
+ typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
+
struct UniformIndexMap
{
- uint32_t uniformIndex; ///< The index of the cached location in the Program
- ConstString uniformName; ///< The uniform name
- const PropertyInputImpl* propertyValue; ///< The property value
+ ConstString uniformName; ///< The uniform name
+ const PropertyInputImpl* propertyValue{nullptr}; ///< The property value
Hash uniformNameHash{0u};
Hash uniformNameHashNoArray{0u};
- int32_t arrayIndex; ///< The array index
+ int32_t arrayIndex{-1}; ///< The array index
+
+ int16_t uniformLocation{0u};
+ uint16_t uniformOffset{0u};
+ uint16_t uniformSize{0u};
+ FuncGetter uniformFunc{0};
};
using UniformIndexMappings = Dali::Vector<UniformIndexMap>;
UniformIndexMappings mUniformIndexMap;
- Vector<int32_t> mAttributeLocations;
uint64_t mUniformsHash;
struct HashedPipeline
return (reinterpret_cast<uint64_t>(node) << 32) | ((reinterpret_cast<uint64_t>(instruction) & 0xFFFFFFF) << 1) | blend;
}
};
- std::vector<HashedPipeline> mGraphicsPipelines{};
StencilParameters mStencilParameters; ///< Struct containing all stencil related options
BlendingOptions mBlendingOptions; ///< Blending options including blend color, blend func and blend equation
uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw
uint32_t mIndexedDrawElementsCount; ///< Number of elements to draw
- 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 mUpdateAttributeLocations : 1; ///< Indicates attribute locations have changed
- bool mPremultipledAlphaEnabled : 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
+ 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
-
- struct LegacyProgram : Graphics::ExtensionCreateInfo
- {
- uint32_t programId{0};
- };
-
- LegacyProgram mLegacyProgram; ///< The structure to pass the program ID into Graphics::PipelineCreateInfo
-
- Graphics::UniquePtr<Render::UniformBuffer> mUniformBuffer[2]{nullptr, nullptr}; ///< The double-buffered uniform buffer
+ RenderCallback* mRenderCallback{nullptr};
+ RenderCallbackInput mRenderCallbackInput{};
};
} // namespace Render