X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Fcommon%2Frender-manager.cpp;h=baa25607f19bbfa7dba2745d15d1ea35424bfe24;hb=b60c32b0c551f64424a26a22a15cf79735b36898;hp=b39196185a06f0ad1c2a41a477d763f2c8ee475a;hpb=70dee6f95b89f5de698fbe9cbbe3dd0f547ea481;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index b391961..baa2560 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -54,13 +54,16 @@ namespace SceneGraph struct RenderManager::Impl { Impl( Integration::GlAbstraction& glAbstraction, - Integration::GlSyncAbstraction& glSyncAbstraction ) + Integration::GlSyncAbstraction& glSyncAbstraction, + Integration::DepthBufferAvailable depthBufferAvailableParam, + Integration::StencilBufferAvailable stencilBufferAvailableParam ) : context( glAbstraction ), glSyncAbstraction( glSyncAbstraction ), renderQueue(), instructions(), + renderAlgorithms(), backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ), - frameCount( 0 ), + frameCount( 0u ), renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ), defaultSurfaceRect(), rendererContainer(), @@ -68,7 +71,9 @@ struct RenderManager::Impl textureContainer(), frameBufferContainer(), lastFrameWasRendered( false ), - programController( glAbstraction ) + programController( glAbstraction ), + depthBufferAvailable( depthBufferAvailableParam ), + stencilBufferAvailable( stencilBufferAvailableParam ) { } @@ -104,6 +109,7 @@ struct RenderManager::Impl // Render instructions describe what should be rendered during RenderManager::Render() // Owned by RenderManager. Update manager updates instructions for the next frame while we render the current one RenderInstructionContainer instructions; + Render::RenderAlgorithms renderAlgorithms; ///< The RenderAlgorithms object is used to action the renders required by a RenderInstruction Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame. @@ -125,14 +131,21 @@ struct RenderManager::Impl ProgramController programController; ///< Owner of the GL programs + Integration::DepthBufferAvailable depthBufferAvailable; ///< Whether the depth buffer is available + Integration::StencilBufferAvailable stencilBufferAvailable; ///< Whether the stencil buffer is available + }; RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction, - Integration::GlSyncAbstraction& glSyncAbstraction ) + Integration::GlSyncAbstraction& glSyncAbstraction, + Integration::DepthBufferAvailable depthBufferAvailable, + Integration::StencilBufferAvailable stencilBufferAvailable ) { RenderManager* manager = new RenderManager; manager->mImpl = new Impl( glAbstraction, - glSyncAbstraction ); + glSyncAbstraction, + depthBufferAvailable, + stencilBufferAvailable ); return manager; } @@ -384,7 +397,7 @@ ProgramCache* RenderManager::GetProgramCache() return &(mImpl->programController); } -void RenderManager::Render( Integration::RenderStatus& status ) +void RenderManager::Render( Integration::RenderStatus& status, bool forceClear ) { DALI_PRINT_RENDER_START( mImpl->renderBufferIndex ); @@ -392,7 +405,7 @@ void RenderManager::Render( Integration::RenderStatus& status ) DALI_ASSERT_DEBUG( mImpl->context.IsGlContextCreated() ); // Increment the frame count at the beginning of each frame - ++(mImpl->frameCount); + ++mImpl->frameCount; // Process messages queued during previous update mImpl->renderQueue.ProcessMessages( mImpl->renderBufferIndex ); @@ -401,13 +414,13 @@ void RenderManager::Render( Integration::RenderStatus& status ) const bool haveInstructions = count > 0u; // Only render if we have instructions to render, or the last frame was rendered (and therefore a clear is required). - if( haveInstructions || mImpl->lastFrameWasRendered ) + if( haveInstructions || mImpl->lastFrameWasRendered || forceClear ) { // Mark that we will require a post-render step to be performed (includes swap-buffers). status.SetNeedsPostRender( true ); // switch rendering to adaptor provided (default) buffer - mImpl->context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); + mImpl->context.BindFramebuffer( GL_FRAMEBUFFER, 0u ); mImpl->context.Viewport( mImpl->defaultSurfaceRect.x, mImpl->defaultSurfaceRect.y, @@ -419,17 +432,31 @@ void RenderManager::Render( Integration::RenderStatus& status ) mImpl->backgroundColor.b, mImpl->backgroundColor.a ); - mImpl->context.ClearStencil( 0 ); - - // Clear the entire color, depth and stencil buffers for the default framebuffer. - // It is important to clear all 3 buffers, for performance on deferred renderers like Mali + // 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->context.SetScissorTest( false ); + + GLbitfield clearMask = GL_COLOR_BUFFER_BIT; + mImpl->context.ColorMask( true ); - mImpl->context.DepthMask( true ); - mImpl->context.StencilMask( 0xFF ); // 8 bit stencil mask, all 1's - mImpl->context.Clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, Context::FORCE_CLEAR ); + + if( mImpl->depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ) + { + mImpl->context.DepthMask( true ); + clearMask |= GL_DEPTH_BUFFER_BIT; + } + + if( mImpl->stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE) + { + mImpl->context.ClearStencil( 0 ); + mImpl->context.StencilMask( 0xFF ); // 8 bit stencil mask, all 1's + clearMask |= GL_STENCIL_BUFFER_BIT; + } + + mImpl->context.Clear( clearMask, Context::FORCE_CLEAR ); // reset the program matrices for all programs once per frame // this ensures we will set view and projection matrix once per program per camera @@ -445,8 +472,6 @@ void RenderManager::Render( Integration::RenderStatus& status ) GLenum attachments[] = { GL_DEPTH, GL_STENCIL }; mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments); - mImpl->UpdateTrackers(); - //Notify RenderGeometries that rendering has finished for ( auto&& iter : mImpl->geometryContainer ) { @@ -454,6 +479,8 @@ void RenderManager::Render( Integration::RenderStatus& status ) } } + mImpl->UpdateTrackers(); + // If this frame was rendered due to instructions existing, we mark this so we know to clear the next frame. mImpl->lastFrameWasRendered = haveInstructions; @@ -481,7 +508,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) clearColor = Dali::RenderTask::DEFAULT_CLEAR_COLOR; } - if( instruction.mFrameBuffer != 0 ) + if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) ) { instruction.mFrameBuffer->Bind( mImpl->context ); if ( instruction.mIsViewportSet ) @@ -530,9 +557,12 @@ void RenderManager::DoRender( RenderInstruction& instruction ) mImpl->context.SetScissorTest( false ); } - Render::ProcessRenderInstruction( instruction, - mImpl->context, - mImpl->renderBufferIndex ); + mImpl->renderAlgorithms.ProcessRenderInstruction( + instruction, + mImpl->context, + mImpl->renderBufferIndex, + mImpl->depthBufferAvailable, + mImpl->stencilBufferAvailable ); if( instruction.mRenderTracker && ( instruction.mFrameBuffer != NULL ) ) {