// INTERNAL INCLUDES
#include <dali/devel-api/threading/thread-pool.h>
#include <dali/integration-api/core.h>
-#include <dali/integration-api/gl-context-helper-abstraction.h>
#include <dali/internal/event/common/scene-impl.h>
#include <dali/internal/render/renderers/render-texture.h>
#include <dali/internal/render/renderers/shader-cache.h>
#include <dali/internal/render/renderers/uniform-buffer-manager.h>
+#include <dali/internal/render/renderers/uniform-buffer-view-pool.h>
#include <dali/internal/render/shaders/program-controller.h>
+#include <dali/internal/render/renderers/pipeline-cache.h>
+
+#include <memory>
namespace Dali
{
} // unnamed namespace
#endif
+namespace
+{
+inline Graphics::Rect2D RecalculateScissorArea(Graphics::Rect2D scissorArea, int orientation, Rect<int32_t> viewportRect)
+{
+ Graphics::Rect2D newScissorArea;
+
+ if(orientation == 90)
+ {
+ newScissorArea.x = viewportRect.height - (scissorArea.y + scissorArea.height);
+ newScissorArea.y = scissorArea.x;
+ newScissorArea.width = scissorArea.height;
+ newScissorArea.height = scissorArea.width;
+ }
+ else if(orientation == 180)
+ {
+ newScissorArea.x = viewportRect.width - (scissorArea.x + scissorArea.width);
+ newScissorArea.y = viewportRect.height - (scissorArea.y + scissorArea.height);
+ newScissorArea.width = scissorArea.width;
+ newScissorArea.height = scissorArea.height;
+ }
+ else if(orientation == 270)
+ {
+ newScissorArea.x = scissorArea.y;
+ newScissorArea.y = viewportRect.width - (scissorArea.x + scissorArea.width);
+ newScissorArea.width = scissorArea.height;
+ newScissorArea.height = scissorArea.width;
+ }
+ else
+ {
+ newScissorArea.x = scissorArea.x;
+ newScissorArea.y = scissorArea.y;
+ newScissorArea.width = scissorArea.width;
+ newScissorArea.height = scissorArea.height;
+ }
+ return newScissorArea;
+}
+} // namespace
/**
* Structure to contain internal data
*/
partialUpdateAvailable(partialUpdateAvailableParam)
{
// Create thread pool with just one thread ( there may be a need to create more threads in the future ).
- threadPool = std::unique_ptr<Dali::ThreadPool>(new Dali::ThreadPool());
+ threadPool = std::make_unique<Dali::ThreadPool>();
threadPool->Initialize(1u);
- uniformBufferManager.reset(new Render::UniformBufferManager(&graphicsController));
+ uniformBufferManager = std::make_unique<Render::UniformBufferManager>(&graphicsController);
+ pipelineCache = std::make_unique<Render::PipelineCache>(graphicsController);
}
~Impl()
OwnerContainer<Render::RenderTracker*> mRenderTrackers; ///< List of render trackers
- ProgramController programController; ///< Owner of the GL programs
+ ProgramController programController; ///< Owner of the programs
Render::ShaderCache shaderCache; ///< The cache for the graphics shaders
std::unique_ptr<Render::UniformBufferManager> uniformBufferManager; ///< The uniform buffer manager
+ std::unique_ptr<Render::PipelineCache> pipelineCache;
Integration::DepthBufferAvailable depthBufferAvailable; ///< Whether the depth buffer is available
Integration::StencilBufferAvailable stencilBufferAvailable; ///< Whether the stencil buffer is available
void RenderManager::AddRenderer(OwnerPointer<Render::Renderer>& renderer)
{
// Initialize the renderer as we are now in render thread
- renderer->Initialize(mImpl->graphicsController, mImpl->programController, mImpl->shaderCache, *(mImpl->uniformBufferManager.get()));
+ renderer->Initialize(mImpl->graphicsController, mImpl->programController, mImpl->shaderCache, *(mImpl->uniformBufferManager.get()),
+ *(mImpl->pipelineCache.get()));
mImpl->rendererContainer.PushBack(renderer.Release());
}
{
DALI_PRINT_RENDER_START(mImpl->renderBufferIndex);
+ // Rollback
+ mImpl->uniformBufferManager->GetUniformBufferViewPool(mImpl->renderBufferIndex)->Rollback();
+
// Increment the frame count at the beginning of each frame
++mImpl->frameCount;
// Offscreen buffer rendering
if(instruction.mIsViewportSet)
{
- // For glViewport the lower-left corner is (0,0)
+ // For Viewport the lower-left corner is (0,0)
const int32_t y = (instruction.mFrameBuffer->GetHeight() - instruction.mViewport.height) - instruction.mViewport.y;
viewportRect.Set(instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height);
}
// Check whether a viewport is specified, otherwise the full surface size is used
if(instruction.mIsViewportSet)
{
- // For glViewport the lower-left corner is (0,0)
+ // For Viewport the lower-left corner is (0,0)
const int32_t y = (surfaceRect.height - instruction.mViewport.height) - instruction.mViewport.y;
viewportRect.Set(instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height);
}
}
}
+ // Scissor's value should be set based on the default system coordinates.
+ // When the surface is rotated, the input values already were set with the rotated angle.
+ // So, re-calculation is needed.
+ scissorArea = RecalculateScissorArea(scissorArea, surfaceOrientation, viewportRect);
+
// Begin render pass
mainCommandBuffer->BeginRenderPass(
currentRenderPass,
clippingRect,
surfaceOrientation);
- // Synchronise the FBO/Texture access
-
- // Check whether any bound texture is in the dependency list
- bool textureFound = false;
-
- if(mImpl->boundTextures.Count() > 0u && mImpl->textureDependencyList.Count() > 0u)
- {
- for(auto texture : mImpl->textureDependencyList)
- {
- textureFound = std::find_if(mImpl->boundTextures.Begin(), mImpl->boundTextures.End(), [texture](Graphics::Texture* graphicsTexture) {
- return texture == graphicsTexture;
- }) != mImpl->boundTextures.End();
- }
- }
-
- if(textureFound)
- {
- if(instruction.mFrameBuffer)
- {
- // For off-screen buffer
-
- // Clear the dependency list
- mImpl->textureDependencyList.Clear();
- }
- else
- {
- // Worker thread lambda function
- auto& glContextHelperAbstraction = mImpl->graphicsController.GetGlContextHelperAbstraction();
- auto workerFunction = [&glContextHelperAbstraction](int workerThread) {
- // Switch to the shared context in the worker thread
- glContextHelperAbstraction.MakeSurfacelessContextCurrent();
-
- // Wait until all rendering calls for the shared context are executed
- glContextHelperAbstraction.WaitClient();
-
- // Must clear the context in the worker thread
- // Otherwise the shared context cannot be switched to from the render thread
- glContextHelperAbstraction.MakeContextNull();
- };
-
- auto future = mImpl->threadPool->SubmitTask(0u, workerFunction);
- if(future)
- {
- mImpl->threadPool->Wait();
-
- // Clear the dependency list
- mImpl->textureDependencyList.Clear();
- }
- }
- }
-
+ Graphics::SyncObject* syncObject{nullptr};
+ // If the render instruction has an associated render tracker (owned separately)
+ // and framebuffer, create a one shot sync object, and use it to determine when
+ // the render pass has finished executing on GPU.
if(instruction.mRenderTracker && instruction.mFrameBuffer)
{
- // This will create a sync object every frame this render tracker
- // is alive (though it should be now be created only for
- // render-once render tasks)
- // @todo Add syncing to Graphics API
- instruction.mRenderTracker->CreateSyncObject(mImpl->graphicsController.GetGlSyncAbstraction());
- instruction.mRenderTracker = nullptr; // Only create once.
+ syncObject = instruction.mRenderTracker->CreateSyncObject(mImpl->graphicsController);
+ instruction.mRenderTracker = nullptr;
}
-
- // End render pass
- mainCommandBuffer->EndRenderPass();
+ mainCommandBuffer->EndRenderPass(syncObject);
}
mImpl->renderAlgorithms.SubmitCommandBuffer();