} // unnamed namespace
#endif
-const int partialUpdateMargin = 4u;
-const float partialUpdateRatio = 0.8f; // If the partial update area exceeds 80%, change to full update.
-
/**
* Structure to contain internal data
*/
Integration::GlSyncAbstraction& glSyncAbstraction,
Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
Integration::DepthBufferAvailable depthBufferAvailableParam,
- Integration::StencilBufferAvailable stencilBufferAvailableParam,
- Integration::PartialUpdateAvailable partialUpdateAvailableParam )
+ Integration::StencilBufferAvailable stencilBufferAvailableParam )
: context( glAbstraction, &surfaceContextContainer ),
currentContext( &context ),
glAbstraction( glAbstraction ),
lastFrameWasRendered( false ),
programController( glAbstraction ),
depthBufferAvailable( depthBufferAvailableParam ),
- stencilBufferAvailable( stencilBufferAvailableParam ),
- partialUpdateAvailable( partialUpdateAvailableParam ),
- defaultSurfaceOrientation( 0 )
+ stencilBufferAvailable( stencilBufferAvailableParam )
{
// 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() );
Integration::DepthBufferAvailable depthBufferAvailable; ///< Whether the depth buffer is available
Integration::StencilBufferAvailable stencilBufferAvailable; ///< Whether the stencil buffer is available
- Integration::PartialUpdateAvailable partialUpdateAvailable; ///< Whether the partial update is available
std::unique_ptr<Dali::ThreadPool> threadPool; ///< The thread pool
Vector<GLuint> boundTextures; ///< The textures bound for rendering
Vector<GLuint> textureDependencyList; ///< The dependency list of binded textures
- int defaultSurfaceOrientation; ///< defaultSurfaceOrientation for the default surface we are rendering to
-
};
RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction,
Integration::GlSyncAbstraction& glSyncAbstraction,
Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
Integration::DepthBufferAvailable depthBufferAvailable,
- Integration::StencilBufferAvailable stencilBufferAvailable,
- Integration::PartialUpdateAvailable partialUpdateAvailable )
+ Integration::StencilBufferAvailable stencilBufferAvailable )
{
RenderManager* manager = new RenderManager;
manager->mImpl = new Impl( glAbstraction,
glSyncAbstraction,
glContextHelperAbstraction,
depthBufferAvailable,
- stencilBufferAvailable,
- partialUpdateAvailable );
+ stencilBufferAvailable );
return manager;
}
mImpl->defaultSurfaceRect = rect;
}
-void RenderManager::SetDefaultSurfaceOrientation( int orientation )
-{
- mImpl->defaultSurfaceOrientation = orientation;
-}
-
void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
{
// Initialize the renderer as we are now in render thread
return &(mImpl->programController);
}
-void RenderManager::Render( Integration::RenderStatus& status, bool forceClear )
+void RenderManager::Render( Integration::RenderStatus& status, bool forceClear, bool uploadOnly )
{
DALI_PRINT_RENDER_START( mImpl->renderBufferIndex );
{
DALI_LOG_INFO( gLogFilter, Debug::General, "Render: Processing\n" );
- // Mark that we will require a post-render step to be performed (includes swap-buffers).
- status.SetNeedsPostRender( true );
+ if ( !uploadOnly )
+ {
+ // Mark that we will require a post-render step to be performed (includes swap-buffers).
+ status.SetNeedsPostRender( true );
+ }
// Switch to the shared context
if ( mImpl->currentContext != &mImpl->context )
}
}
- for( uint32_t i = 0; i < count; ++i )
+ if ( !uploadOnly )
{
- RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i );
+ for( uint32_t i = 0; i < count; ++i )
+ {
+ RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i );
- DoRender( instruction );
- }
+ DoRender( instruction );
+ }
- if ( mImpl->currentContext->IsSurfacelessContextSupported() )
- {
- mImpl->glContextHelperAbstraction.MakeSurfacelessContextCurrent();
- }
+ if ( mImpl->currentContext->IsSurfacelessContextSupported() )
+ {
+ mImpl->glContextHelperAbstraction.MakeSurfacelessContextCurrent();
+ }
- GLenum attachments[] = { GL_DEPTH, GL_STENCIL };
- mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
- for ( auto&& context : mImpl->surfaceContextContainer )
- {
- context->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+ GLenum attachments[] = { GL_DEPTH, GL_STENCIL };
+ mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+ for ( auto&& context : mImpl->surfaceContextContainer )
+ {
+ context->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+ }
}
//Notify RenderGeometries that rendering has finished
DALI_PRINT_RENDER_END();
}
-bool GetDamagedRect( Rect<int32_t> &viewportRect, RenderInstruction& instruction, Rect<int32_t> &damagedRect )
-{
- // merge bounding
- int dx1 = viewportRect.width, dx2 = 0, dy1 = viewportRect.height, dy2 = 0;
- int checkWidth = static_cast<int>( static_cast<float>( viewportRect.width ) * partialUpdateRatio );
- int checkHeight = static_cast<int>( static_cast<float>( viewportRect.height ) * partialUpdateRatio );
- Rect<int32_t> screenRect;
-
- bool isPartialUpdate = false;
-
- const RenderListContainer::SizeType renderListCount = instruction.RenderListCount();
- // Iterate through each render list.
-
- for( RenderListContainer::SizeType index = 0; index < renderListCount; ++index )
- {
- const RenderList* renderList = instruction.GetRenderList( index );
-
- if( renderList && !renderList->IsEmpty() && renderList->IsPartialUpdateEnabled() )
- {
- const std::size_t itemCount = renderList->Count();
- for( uint32_t itemIndex = 0u; itemIndex < itemCount; ++itemIndex )
- {
- const RenderItem& item = renderList->GetItem( itemIndex );
-
- if( item.mPartialUpdateEnabled )
- {
- isPartialUpdate = true;
-
- screenRect = item.CalculateViewportSpaceAABB( viewportRect.width, viewportRect.height, true );
-
- dx1 = std::min( screenRect.x, dx1 );
- dx2 = std::max( screenRect.x + screenRect.width, dx2);
- dy1 = std::min( screenRect.y, dy1 );
- dy2 = std::max( screenRect.y + screenRect.height, dy2 );
-
- if( ( dx2 - dx1 ) > checkWidth && ( dy2 - dy1 ) > checkHeight )
- {
- return false;
- }
- }
- }
- }
- }
-
- if( isPartialUpdate )
- {
- damagedRect.x = dx1 - partialUpdateMargin;
- damagedRect.y = dy1 - partialUpdateMargin;
- damagedRect.width = dx2 - dx1 + ( 2 * partialUpdateMargin );
- damagedRect.height = dy2 - dy1 + ( 2 * partialUpdateMargin );
- }
-
- return isPartialUpdate;
-}
-
void RenderManager::DoRender( RenderInstruction& instruction )
{
Rect<int32_t> viewportRect;
Vector4 clearColor;
- bool isPartialUpdate = false;
- Rect<int32_t> damagedRect;
- Rect<int32_t> mergedRect;
- Dali::ClippingBox scissorBox;
if ( instruction.mIsClearColorSet )
{
}
Rect<int32_t> surfaceRect = mImpl->defaultSurfaceRect;
- int surfaceOrientation = mImpl->defaultSurfaceOrientation;
Vector4 backgroundColor = mImpl->backgroundColor;
Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable;
Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable;
- Integration::PartialUpdateAvailable partialUpdateAvailable = mImpl->partialUpdateAvailable;
Render::SurfaceFrameBuffer* surfaceFrameBuffer = nullptr;
if ( instruction.mFrameBuffer != 0 )
mImpl->currentContext->BindFramebuffer( GL_FRAMEBUFFER, 0u );
}
-
- if( surfaceFrameBuffer &&
- partialUpdateAvailable == Integration::PartialUpdateAvailable::TRUE )
- {
- const RenderListContainer::SizeType renderListCount = instruction.RenderListCount();
- // Iterate through each render list.
- if( surfaceFrameBuffer->IsPartialUpdateEnabled() )
- {
- isPartialUpdate = GetDamagedRect( surfaceRect, instruction, damagedRect ) ;
- }
-
- if( !isPartialUpdate )
- {
- damagedRect = surfaceRect;
- }
-
- mergedRect = surfaceFrameBuffer->SetDamagedRect( damagedRect );
-
- if( mergedRect.IsEmpty() )
- {
- isPartialUpdate = false;
- }
- else
- {
- scissorBox.x = mergedRect.x;
- scissorBox.y = mergedRect.y;
- scissorBox.width = mergedRect.width;
- scissorBox.height = mergedRect.height;
- }
- }
-
if ( surfaceFrameBuffer )
{
- mImpl->currentContext->Viewport( surfaceRect.x,
- surfaceRect.y,
- surfaceRect.width,
- surfaceRect.height );
-
+ mImpl->currentContext->Viewport( surfaceRect.x,
+ surfaceRect.y,
+ surfaceRect.width,
+ surfaceRect.height );
- mImpl->currentContext->ClearColor( backgroundColor.r,
- backgroundColor.g,
- backgroundColor.b,
- backgroundColor.a );
+ mImpl->currentContext->ClearColor( backgroundColor.r,
+ backgroundColor.g,
+ backgroundColor.b,
+ backgroundColor.a );
}
// Clear the entire color, depth and stencil buffers for the default framebuffer, if required.
// It is important to clear all 3 buffers when they are being used, for performance on deferred renderers
// e.g. previously when the depth & stencil buffers were NOT cleared, it caused the DDK to exceed a "vertex count limit",
// and then stall. That problem is only noticeable when rendering a large number of vertices per frame.
- mImpl->currentContext->SetScissorTest( false );
- if( isPartialUpdate )
- {
- mImpl->currentContext->SetScissorTest( true );
- mImpl->currentContext->Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height );
- }
+ mImpl->currentContext->SetScissorTest( false );
GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR );
- if( isPartialUpdate )
- {
- mImpl->currentContext->SetScissorTest( false );
- }
-
-
if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) )
{
if ( instruction.mFrameBuffer->IsSurfaceBacked() ) // Surface rendering
// For glViewport the lower-left corner is (0,0)
// For glViewport 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 );
+ viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height );
}
else
{
{
viewportRect.Set( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() );
}
- surfaceOrientation = 0;
}
}
else // No Offscreen frame buffer rendering
{
// For glViewport 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 );
+ viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height );
}
else
{
}
}
- if ( surfaceOrientation == 90 || surfaceOrientation == 270 )
- {
- int temp = viewportRect.width;
- viewportRect.width = viewportRect.height;
- viewportRect.height = temp;
- }
-
mImpl->currentContext->Viewport(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height);
if ( instruction.mIsClearColorSet )
// Clear the viewport area only
mImpl->currentContext->SetScissorTest( true );
- if( isPartialUpdate )
- {
- mImpl->currentContext->Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height );
- }
- else
- {
- mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height );
- }
+ mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height );
mImpl->currentContext->ColorMask( true );
mImpl->currentContext->Clear( GL_COLOR_BUFFER_BIT , Context::CHECK_CACHED_VALUES );
mImpl->currentContext->SetScissorTest( false );
mImpl->renderBufferIndex,
depthBufferAvailable,
stencilBufferAvailable,
- mImpl->boundTextures,
- surfaceOrientation,
- scissorBox );
+ mImpl->boundTextures );
// Synchronise the FBO/Texture access when there are multiple contexts
if ( mImpl->currentContext->IsSurfacelessContextSupported() )