/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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/internal/render/common/render-tracker.h>
#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/internal/render/common/render-instruction.h>
-#include <dali/internal/render/data-providers/uniform-name-cache.h>
#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/renderers/render-frame-buffer.h>
#include <dali/internal/render/renderers/render-geometry.h>
namespace SceneGraph
{
-typedef OwnerContainer< Render::Renderer* > RendererOwnerContainer;
-typedef RendererOwnerContainer::Iterator RendererOwnerIter;
-
-typedef OwnerContainer< Render::Geometry* > GeometryOwnerContainer;
-typedef GeometryOwnerContainer::Iterator GeometryOwnerIter;
-
-typedef OwnerContainer< Render::Sampler* > SamplerOwnerContainer;
-typedef SamplerOwnerContainer::Iterator SamplerOwnerIter;
-
-typedef OwnerContainer< Render::NewTexture* > TextureOwnerContainer;
-typedef TextureOwnerContainer::Iterator TextureOwnerIter;
-
-typedef OwnerContainer< Render::FrameBuffer* > FrameBufferOwnerContainer;
-typedef FrameBufferOwnerContainer::Iterator FrameBufferOwnerIter;
-
-typedef OwnerContainer< Render::PropertyBuffer* > PropertyBufferOwnerContainer;
-typedef PropertyBufferOwnerContainer::Iterator PropertyBufferOwnerIter;
-
-typedef OwnerContainer< Render::RenderTracker* > RenderTrackerContainer;
-typedef RenderTrackerContainer::Iterator RenderTrackerIter;
-typedef RenderTrackerContainer::ConstIterator RenderTrackerConstIter;
-
/**
* Structure to contain internal data
*/
{
Impl( Integration::GlAbstraction& glAbstraction,
Integration::GlSyncAbstraction& glSyncAbstraction,
- LockedResourceQueue& textureUploadedQ,
- TextureUploadedDispatcher& postProcessDispatcher )
+ Integration::DepthBufferAvailable depthBufferAvailableParam,
+ Integration::StencilBufferAvailable stencilBufferAvailableParam )
: context( glAbstraction ),
glSyncAbstraction( glSyncAbstraction ),
renderQueue(),
- textureCache( renderQueue, postProcessDispatcher, context ),
- textureUploadedQueue( textureUploadedQ ),
instructions(),
+ renderAlgorithms(),
backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
- frameCount( 0 ),
+ frameCount( 0u ),
renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ),
defaultSurfaceRect(),
rendererContainer(),
samplerContainer(),
textureContainer(),
frameBufferContainer(),
- renderersAdded( false ),
- firstRenderCompleted( false ),
- defaultShader( NULL ),
- programController( glAbstraction )
+ lastFrameWasRendered( false ),
+ programController( glAbstraction ),
+ depthBufferAvailable( depthBufferAvailableParam ),
+ stencilBufferAvailable( stencilBufferAvailableParam )
{
}
void RemoveRenderTracker( Render::RenderTracker* renderTracker )
{
- DALI_ASSERT_DEBUG( renderTracker != NULL );
- for(RenderTrackerIter iter = mRenderTrackers.Begin(), end = mRenderTrackers.End(); iter != end; ++iter)
- {
- if( *iter == renderTracker )
- {
- mRenderTrackers.Erase( iter );
- break;
- }
- }
+ mRenderTrackers.EraseObject( renderTracker );
}
void UpdateTrackers()
{
- for(RenderTrackerIter iter = mRenderTrackers.Begin(), end = mRenderTrackers.End(); iter != end; ++iter)
+ for( auto&& iter : mRenderTrackers )
{
- (*iter)->PollSyncObject();
+ iter->PollSyncObject();
}
}
// the order is important for destruction,
// programs are owned by context at the moment.
- Context context; ///< holds the GL state
- Integration::GlSyncAbstraction& glSyncAbstraction; ///< GL sync abstraction
- RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread.
- TextureCache textureCache; ///< Cache for all GL textures
- Render::UniformNameCache uniformNameCache; ///< Cache to provide unique indices for uniforms
- LockedResourceQueue& textureUploadedQueue; ///< A queue for requesting resource post processing in update thread
+ Context context; ///< holds the GL state
+ Integration::GlSyncAbstraction& glSyncAbstraction; ///< GL sync abstraction
+ RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread.
// 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;
+ 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.
- Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
+ unsigned int frameCount; ///< The current frame count
+ BufferIndex renderBufferIndex; ///< The index of the buffer to read from; this is opposite of the "update" buffer
- unsigned int frameCount; ///< The current frame count
- BufferIndex renderBufferIndex; ///< The index of the buffer to read from; this is opposite of the "update" buffer
+ Rect<int> defaultSurfaceRect; ///< Rectangle for the default surface we are rendering to
- Rect<int> defaultSurfaceRect; ///< Rectangle for the default surface we are rendering to
+ OwnerContainer< Render::Renderer* > rendererContainer; ///< List of owned renderers
+ OwnerContainer< Render::Sampler* > samplerContainer; ///< List of owned samplers
+ OwnerContainer< Render::Texture* > textureContainer; ///< List of owned textures
+ OwnerContainer< Render::FrameBuffer* > frameBufferContainer; ///< List of owned framebuffers
+ OwnerContainer< Render::PropertyBuffer* > propertyBufferContainer; ///< List of owned property buffers
+ OwnerContainer< Render::Geometry* > geometryContainer; ///< List of owned Geometries
- RendererOwnerContainer rendererContainer; ///< List of owned renderers
- SamplerOwnerContainer samplerContainer; ///< List of owned samplers
- TextureOwnerContainer textureContainer; ///< List of owned textures
- FrameBufferOwnerContainer frameBufferContainer; ///< List of owned framebuffers
- PropertyBufferOwnerContainer propertyBufferContainer; ///< List of owned property buffers
- GeometryOwnerContainer geometryContainer; ///< List of owned Geometries
+ bool lastFrameWasRendered; ///< Keeps track of the last frame being rendered due to having render instructions
- bool renderersAdded;
+ OwnerContainer< Render::RenderTracker* > mRenderTrackers; ///< List of render trackers
- RenderTrackerContainer mRenderTrackers; ///< List of render trackers
+ 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
- bool firstRenderCompleted; ///< False until the first render is done
- Shader* defaultShader; ///< Default shader to use
- ProgramController programController; ///< Owner of the GL programs
};
RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction,
Integration::GlSyncAbstraction& glSyncAbstraction,
- LockedResourceQueue& textureUploadedQ )
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable )
{
RenderManager* manager = new RenderManager;
- manager->mImpl = new Impl( glAbstraction, glSyncAbstraction, textureUploadedQ, *manager );
+ manager->mImpl = new Impl( glAbstraction,
+ glSyncAbstraction,
+ depthBufferAvailable,
+ stencilBufferAvailable );
return manager;
}
RenderManager::~RenderManager()
{
- for ( TextureOwnerIter iter = mImpl->textureContainer.Begin(); iter != mImpl->textureContainer.End(); ++iter )
- {
- (*iter)->Destroy( mImpl->context );
- }
-
- for ( FrameBufferOwnerIter iter = mImpl->frameBufferContainer.Begin(); iter != mImpl->frameBufferContainer.End(); ++iter )
- {
- (*iter)->Destroy( mImpl->context );
- }
-
delete mImpl;
}
return mImpl->renderQueue;
}
-TextureCache& RenderManager::GetTextureCache()
-{
- return mImpl->textureCache;
-}
-
void RenderManager::ContextCreated()
{
mImpl->context.GlContextCreated();
mImpl->context.GlContextDestroyed();
mImpl->programController.GlContextDestroyed();
- // inform texture cache
- mImpl->textureCache.GlContextDestroyed(); // Clears gl texture ids
+ //Inform textures
+ for( auto&& texture : mImpl->textureContainer )
+ {
+ texture->GlContextDestroyed();
+ }
- // inform renderers
- RendererOwnerContainer::Iterator end = mImpl->rendererContainer.End();
- RendererOwnerContainer::Iterator iter = mImpl->rendererContainer.Begin();
- for( ; iter != end; ++iter )
+ //Inform framebuffers
+ for( auto&& framebuffer : mImpl->frameBufferContainer )
{
- GlResourceOwner* renderer = *iter;
- renderer->GlContextDestroyed(); // Clear up vertex buffers
+ framebuffer->GlContextDestroyed();
}
-}
-void RenderManager::DispatchTextureUploaded(ResourceId request)
-{
- mImpl->textureUploadedQueue.PushBack( request );
+ // inform renderers
+ for( auto&& renderer : mImpl->rendererContainer )
+ {
+ renderer->GlContextDestroyed();
+ }
}
void RenderManager::SetShaderSaver( ShaderSaver& upstream )
mImpl->defaultSurfaceRect = rect;
}
-void RenderManager::AddRenderer( Render::Renderer* renderer )
+void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
{
// Initialize the renderer as we are now in render thread
- renderer->Initialize( mImpl->context, mImpl->textureCache, mImpl->uniformNameCache );
+ renderer->Initialize( mImpl->context );
- mImpl->rendererContainer.PushBack( renderer );
-
- if( !mImpl->renderersAdded )
- {
- mImpl->renderersAdded = true;
- }
+ mImpl->rendererContainer.PushBack( renderer.Release() );
}
void RenderManager::RemoveRenderer( Render::Renderer* renderer )
{
- DALI_ASSERT_DEBUG( NULL != renderer );
-
- RendererOwnerContainer& renderers = mImpl->rendererContainer;
-
- // Find the renderer
- for ( RendererOwnerIter iter = renderers.Begin(); iter != renderers.End(); ++iter )
- {
- if ( *iter == renderer )
- {
- renderers.Erase( iter ); // Renderer found; now destroy it
- break;
- }
- }
+ mImpl->rendererContainer.EraseObject( renderer );
}
-void RenderManager::AddSampler( Render::Sampler* sampler )
+void RenderManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )
{
- mImpl->samplerContainer.PushBack( sampler );
+ mImpl->samplerContainer.PushBack( sampler.Release() );
}
void RenderManager::RemoveSampler( Render::Sampler* sampler )
{
- DALI_ASSERT_DEBUG( NULL != sampler );
-
- SamplerOwnerContainer& samplers = mImpl->samplerContainer;
-
- // Find the sampler
- for ( SamplerOwnerIter iter = samplers.Begin(); iter != samplers.End(); ++iter )
- {
- if ( *iter == sampler )
- {
- samplers.Erase( iter ); // Sampler found; now destroy it
- break;
- }
- }
+ mImpl->samplerContainer.EraseObject( sampler );
}
-void RenderManager::AddTexture( Render::NewTexture* texture )
+void RenderManager::AddTexture( OwnerPointer< Render::Texture >& texture )
{
- mImpl->textureContainer.PushBack( texture );
- texture->Initialize(mImpl->context);
+ texture->Initialize( mImpl->context );
+ mImpl->textureContainer.PushBack( texture.Release() );
}
-void RenderManager::RemoveTexture( Render::NewTexture* texture )
+void RenderManager::RemoveTexture( Render::Texture* texture )
{
DALI_ASSERT_DEBUG( NULL != texture );
- TextureOwnerContainer& textures = mImpl->textureContainer;
-
- // Find the texture
- for ( TextureOwnerIter iter = textures.Begin(); iter != textures.End(); ++iter )
+ // Find the texture, use reference to pointer so we can do the erase safely
+ for ( auto&& iter : mImpl->textureContainer )
{
- if ( *iter == texture )
+ if ( iter == texture )
{
texture->Destroy( mImpl->context );
- textures.Erase( iter ); // Texture found; now destroy it
- break;
+ mImpl->textureContainer.Erase( &iter ); // Texture found; now destroy it
+ return;
}
}
}
-void RenderManager::UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
+void RenderManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
{
texture->Upload( mImpl->context, pixelData, params );
}
-void RenderManager::GenerateMipmaps( Render::NewTexture* texture )
+void RenderManager::GenerateMipmaps( Render::Texture* texture )
{
texture->GenerateMipmaps( mImpl->context );
}
{
DALI_ASSERT_DEBUG( NULL != frameBuffer );
- FrameBufferOwnerContainer& framebuffers = mImpl->frameBufferContainer;
-
- // Find the sampler
- for ( FrameBufferOwnerIter iter = framebuffers.Begin(); iter != framebuffers.End(); ++iter )
+ // Find the sampler, use reference so we can safely do the erase
+ for ( auto&& iter : mImpl->frameBufferContainer )
{
- if ( *iter == frameBuffer )
+ if ( iter == frameBuffer )
{
frameBuffer->Destroy( mImpl->context );
- framebuffers.Erase( iter ); // frameBuffer found; now destroy it
+ mImpl->frameBufferContainer.Erase( &iter ); // frameBuffer found; now destroy it
break;
}
}
}
-void RenderManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
+void RenderManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
{
frameBuffer->AttachColorTexture( mImpl->context, texture, mipmapLevel, layer );
}
-void RenderManager::AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer )
+void RenderManager::AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer )
{
- mImpl->propertyBufferContainer.PushBack( propertyBuffer );
+ mImpl->propertyBufferContainer.PushBack( propertyBuffer.Release() );
}
void RenderManager::RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer )
{
- DALI_ASSERT_DEBUG( NULL != propertyBuffer );
-
- PropertyBufferOwnerContainer& propertyBuffers = mImpl->propertyBufferContainer;
-
- // Find the sampler
- for ( PropertyBufferOwnerIter iter = propertyBuffers.Begin(); iter != propertyBuffers.End(); ++iter )
- {
- if ( *iter == propertyBuffer )
- {
- propertyBuffers.Erase( iter ); // Property buffer found; now destroy it
- break;
- }
- }
+ mImpl->propertyBufferContainer.EraseObject( propertyBuffer );
}
-void RenderManager::SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format )
+void RenderManager::SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format )
{
- propertyBuffer->SetFormat( format );
+ propertyBuffer->SetFormat( format.Release() );
}
-void RenderManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, Dali::Vector<char>* data, size_t size )
+void RenderManager::SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<char> >& data, size_t size )
{
- propertyBuffer->SetData( data, size );
+ propertyBuffer->SetData( data.Release(), size );
}
void RenderManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<unsigned short>& indices )
geometry->SetIndexBuffer( indices );
}
-void RenderManager::AddGeometry( Render::Geometry* geometry )
+void RenderManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry )
{
- mImpl->geometryContainer.PushBack( geometry );
+ mImpl->geometryContainer.PushBack( geometry.Release() );
}
void RenderManager::RemoveGeometry( Render::Geometry* geometry )
{
- DALI_ASSERT_DEBUG( NULL != geometry );
-
- GeometryOwnerContainer& geometries = mImpl->geometryContainer;
-
- // Find the geometry
- for ( GeometryOwnerIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
- {
- if ( *iter == geometry )
- {
- geometries.Erase( iter ); // Geometry found; now destroy it
- break;
- }
- }
+ mImpl->geometryContainer.EraseObject( geometry );
}
-void RenderManager::AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
+void RenderManager::AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer )
{
DALI_ASSERT_DEBUG( NULL != geometry );
- GeometryOwnerContainer& geometries = mImpl->geometryContainer;
-
- // Find the renderer
- for ( GeometryOwnerIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
+ // Find the geometry
+ for ( auto&& iter : mImpl->geometryContainer )
{
- if ( *iter == geometry )
+ if ( iter == geometry )
{
- (*iter)->AddPropertyBuffer( propertyBuffer );
+ iter->AddPropertyBuffer( propertyBuffer );
break;
}
}
{
DALI_ASSERT_DEBUG( NULL != geometry );
- GeometryOwnerContainer& geometries = mImpl->geometryContainer;
-
- // Find the renderer
- for ( GeometryOwnerIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
+ // Find the geometry
+ for ( auto&& iter : mImpl->geometryContainer )
{
- if ( *iter == geometry )
+ if ( iter == geometry )
{
- (*iter)->RemovePropertyBuffer( propertyBuffer );
+ iter->RemovePropertyBuffer( propertyBuffer );
break;
}
}
void RenderManager::SetGeometryType( Render::Geometry* geometry, unsigned int geometryType )
{
- geometry->SetGeometryType( Render::Geometry::GeometryType(geometryType) );
+ geometry->SetType( Render::Geometry::Type(geometryType) );
}
void RenderManager::AddRenderTracker( Render::RenderTracker* renderTracker )
mImpl->RemoveRenderTracker(renderTracker);
}
-void RenderManager::SetDefaultShader( Shader* shader )
-{
- mImpl->defaultShader = shader;
-}
-
ProgramCache* RenderManager::GetProgramCache()
{
return &(mImpl->programController);
}
-bool RenderManager::Render( Integration::RenderStatus& status )
+void RenderManager::Render( Integration::RenderStatus& status, bool forceClear )
{
DALI_PRINT_RENDER_START( mImpl->renderBufferIndex );
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 );
- // No need to make any gl calls if we've done 1st glClear & don't have any renderers to render during startup.
- if( !mImpl->firstRenderCompleted || mImpl->renderersAdded )
+ const size_t count = mImpl->instructions.Count( mImpl->renderBufferIndex );
+ 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 || 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,
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
mImpl->programController.ResetProgramMatrices();
- // if we don't have default shader, no point doing the render calls
- if( mImpl->defaultShader )
+ for( size_t i = 0; i < count; ++i )
{
- size_t count = mImpl->instructions.Count( mImpl->renderBufferIndex );
- for ( size_t i = 0; i < count; ++i )
- {
- RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i );
+ RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i );
- DoRender( instruction, *mImpl->defaultShader );
- }
- GLenum attachments[] = { GL_DEPTH, GL_STENCIL };
- mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+ DoRender( instruction );
+ }
- mImpl->UpdateTrackers();
+ GLenum attachments[] = { GL_DEPTH, GL_STENCIL };
+ mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
- mImpl->firstRenderCompleted = true;
+ //Notify RenderGeometries that rendering has finished
+ for ( auto&& iter : mImpl->geometryContainer )
+ {
+ iter->OnRenderFinished();
}
}
- //Notify RenderGeometries that rendering has finished
- for ( GeometryOwnerIter iter = mImpl->geometryContainer.Begin(); iter != mImpl->geometryContainer.End(); ++iter )
- {
- (*iter)->OnRenderFinished();
- }
+ 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;
/**
* The rendering has finished; swap to the next buffer.
mImpl->renderBufferIndex = (0 != mImpl->renderBufferIndex) ? 0 : 1;
DALI_PRINT_RENDER_END();
-
- // check if anything has been posted to the update thread, if IsEmpty then no update required.
- return !mImpl->textureUploadedQueue.IsEmpty();
}
-void RenderManager::DoRender( RenderInstruction& instruction, Shader& defaultShader )
+void RenderManager::DoRender( RenderInstruction& instruction )
{
Rect<int> viewportRect;
Vector4 clearColor;
clearColor = Dali::RenderTask::DEFAULT_CLEAR_COLOR;
}
- FrameBufferTexture* offscreen = NULL;
-
- if ( instruction.mOffscreenTextureId != 0 )
- {
- offscreen = mImpl->textureCache.GetFramebuffer( instruction.mOffscreenTextureId );
- DALI_ASSERT_DEBUG( NULL != offscreen );
-
- if( NULL != offscreen &&
- offscreen->Prepare() )
- {
- // 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)
- const int y = ( offscreen->GetHeight() - instruction.mViewport.height ) - instruction.mViewport.y;
- viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height );
- }
- else
- {
- viewportRect.Set( 0, 0, offscreen->GetWidth(), offscreen->GetHeight() );
- }
- }
- else
- {
- // Offscreen is NULL or could not be prepared.
- return;
- }
- }
- else if( instruction.mFrameBuffer != 0 )
+ if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) )
{
instruction.mFrameBuffer->Bind( mImpl->context );
if ( instruction.mIsViewportSet )
mImpl->context.SetScissorTest( false );
}
- Render::ProcessRenderInstruction( instruction,
- mImpl->context,
- mImpl->textureCache,
- defaultShader,
- mImpl->renderBufferIndex );
-
- if(instruction.mOffscreenTextureId != 0)
- {
- GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
- mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
- }
+ mImpl->renderAlgorithms.ProcessRenderInstruction(
+ instruction,
+ mImpl->context,
+ mImpl->renderBufferIndex,
+ mImpl->depthBufferAvailable,
+ mImpl->stencilBufferAvailable );
- if( instruction.mRenderTracker && offscreen != NULL )
+ if( instruction.mRenderTracker && ( instruction.mFrameBuffer != NULL ) )
{
// This will create a sync object every frame this render tracker
// is alive (though it should be now be created only for