mGlSyncAbstraction,
mGestureManager,
mDataRetentionPolicy,
- false );
+ Integration::RenderToFrameBuffer::FALSE,
+ Integration::DepthBufferAvailable::TRUE,
+ Integration::StencilBufferAvailable::TRUE );
mCore->ContextCreated();
mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
SET(INTEGRATION_API_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/core.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/core-enumerations.h
${CMAKE_CURRENT_SOURCE_DIR}/context-notifier.h
${CMAKE_CURRENT_SOURCE_DIR}/debug.h
${CMAKE_CURRENT_SOURCE_DIR}/profiling.h
--- /dev/null
+#ifndef DALI_INTEGRATION_CORE_ENUMERATIONS_H
+#define DALI_INTEGRATION_CORE_ENUMERATIONS_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/view-mode.h>
+#include <dali/integration-api/context-notifier.h>
+#include <dali/integration-api/resource-policies.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+
+/**
+ * @brief Enumerations to specify whether we should render to the frame-buffer.
+ */
+enum class RenderToFrameBuffer
+{
+ FALSE = 0,
+ TRUE
+};
+
+/**
+ * @brief Enumerations to specify whether the depth buffer is available.
+ */
+enum class DepthBufferAvailable
+{
+ FALSE = 0,
+ TRUE
+};
+
+/**
+ * @brief Enumerations to specify whether the stencil buffer is available.
+ */
+enum class StencilBufferAvailable
+{
+ FALSE = 0,
+ TRUE
+};
+
+} // namespace Integration
+
+} // namespace Dali
+
+#endif // DALI_INTEGRATION_CORE_ENUMERATIONS_H
GlSyncAbstraction& glSyncAbstraction,
GestureManager& gestureManager,
ResourcePolicy::DataRetention policy,
- bool renderToFboEnabled )
+ RenderToFrameBuffer renderToFboEnabled,
+ DepthBufferAvailable depthBufferAvailable,
+ StencilBufferAvailable stencilBufferAvailable )
{
Core* instance = new Core;
instance->mImpl = new Internal::Core( renderController,
glSyncAbstraction,
gestureManager,
policy,
- renderToFboEnabled );
+ renderToFboEnabled,
+ depthBufferAvailable,
+ stencilBufferAvailable );
return instance;
}
*
*/
-// EXTERNAL INCLUDES
+// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/view-mode.h>
#include <dali/integration-api/context-notifier.h>
+#include <dali/integration-api/core-enumerations.h>
#include <dali/integration-api/resource-policies.h>
namespace Dali
* and platform support. Dali should honour this policy when deciding to discard
* intermediate resource data.
* @param[in] renderToFboEnabled Whether rendering into the Frame Buffer Object is enabled.
+ * @param[in] depthBufferAvailable Whether the depth buffer is available
+ * @param[in] stencilBufferAvailable Whether the stencil buffer is available
* @return A newly allocated Core.
*/
static Core* New( RenderController& renderController,
GlSyncAbstraction& glSyncAbstraction,
GestureManager& gestureManager,
ResourcePolicy::DataRetention policy,
- bool renderToFboEnabled );
+ RenderToFrameBuffer renderToFboEnabled,
+ DepthBufferAvailable depthBufferAvailable,
+ StencilBufferAvailable stencilBufferAvailable );
/**
* Non-virtual destructor. Core is not intended as a base class.
platform_abstraction_header_files = \
$(platform_abstraction_src_dir)/core.h \
+ $(platform_abstraction_src_dir)/core-enumerations.h \
$(platform_abstraction_src_dir)/context-notifier.h \
$(platform_abstraction_src_dir)/debug.h \
$(platform_abstraction_src_dir)/profiling.h \
GlSyncAbstraction& glSyncAbstraction,
GestureManager& gestureManager,
ResourcePolicy::DataRetention dataRetentionPolicy,
- bool renderToFboEnabled )
+ Integration::RenderToFrameBuffer renderToFboEnabled,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable )
: mRenderController( renderController ),
mPlatform(platform),
mProcessingEvent(false)
mRenderTaskProcessor = new SceneGraph::RenderTaskProcessor();
- mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction );
+ mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction, depthBufferAvailable, stencilBufferAvailable );
RenderQueue& renderQueue = mRenderManager->GetRenderQueue();
// This must be called after stage is created but before stage initialization
mRelayoutController = IntrusivePtr< RelayoutController >( new RelayoutController( mRenderController ) );
- mStage->Initialize( renderToFboEnabled );
+ mStage->Initialize( renderToFboEnabled == Integration::RenderToFrameBuffer::TRUE );
mGestureEventProcessor = new GestureEventProcessor( *mStage, *mUpdateManager, gestureManager, mRenderController );
mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor );
// INTERNAL INCLUDES
#include <dali/public-api/object/ref-object.h>
#include <dali/integration-api/context-notifier.h>
+#include <dali/integration-api/core-enumerations.h>
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/animation/animation-playlist-declarations.h>
#include <dali/internal/event/common/stage-def.h>
Integration::GlSyncAbstraction& glSyncAbstraction,
Integration::GestureManager& gestureManager,
ResourcePolicy::DataRetention dataRetentionPolicy,
- bool renderToFboEnabled );
+ Integration::RenderToFrameBuffer renderToFboEnabled,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable );
/**
* Destructor
}
}
-inline void RenderAlgorithms::SetupClipping( const RenderItem& item, Context& context, bool& usedStencilBuffer, uint32_t& lastClippingDepth, uint32_t& lastClippingId )
+inline void RenderAlgorithms::SetupClipping( const RenderItem& item,
+ Context& context,
+ bool& usedStencilBuffer,
+ uint32_t& lastClippingDepth,
+ uint32_t& lastClippingId,
+ Integration::StencilBufferAvailable stencilBufferAvailable )
{
RenderMode::Type renderMode = RenderMode::AUTO;
const Renderer *renderer = item.mRenderer;
// Turn the color buffer on as we always want to render this renderer, regardless of clipping hierarchy.
context.ColorMask( true );
- // The automatic clipping feature will manage the scissor and stencil functions.
+ // The automatic clipping feature will manage the scissor and stencil functions, only if stencil buffer is available for the latter.
// As both scissor and stencil clips can be nested, we may be simultaneously traversing up the scissor tree, requiring a scissor to be un-done. Whilst simultaneously adding a new stencil clip.
// We process both based on our current and old clipping depths for each mode.
// Both methods with return rapidly if there is nothing to be done for that type of clipping.
SetupScissorClipping( item, context );
- SetupStencilClipping( item, context, lastClippingDepth, lastClippingId );
+
+ if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
+ {
+ SetupStencilClipping( item, context, lastClippingDepth, lastClippingId );
+ }
break;
}
{
// No clipping is performed for these modes.
// Note: We do not turn off scissor clipping as it may be used for the whole layer.
- // The stencil buffer will not be used at all.
- context.EnableStencilBuffer( false );
+ // The stencil buffer will not be used at all, but we only need to disable it if it's available.
+ if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
+ {
+ context.EnableStencilBuffer( false );
+ }
// Setup the color buffer based on the RenderMode.
context.ColorMask( renderMode == RenderMode::COLOR );
case RenderMode::STENCIL:
case RenderMode::COLOR_STENCIL:
{
- // We are using the low-level Renderer Stencil API.
- // The stencil buffer must be enabled for every renderer with stencil mode on, as renderers in between can disable it.
- // Note: As the command state is cached, it is only sent when needed.
- context.EnableStencilBuffer( true );
-
- // Setup the color buffer based on the RenderMode.
- context.ColorMask( renderMode == RenderMode::COLOR_STENCIL );
-
- // If this is the first use of the stencil buffer within this RenderList, clear it (this avoids unnecessary clears).
- if( !usedStencilBuffer )
+ if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
{
- context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
- usedStencilBuffer = true;
+ // We are using the low-level Renderer Stencil API.
+ // The stencil buffer must be enabled for every renderer with stencil mode on, as renderers in between can disable it.
+ // Note: As the command state is cached, it is only sent when needed.
+ context.EnableStencilBuffer( true );
+
+ // Setup the color buffer based on the RenderMode.
+ context.ColorMask( renderMode == RenderMode::COLOR_STENCIL );
+
+ // If this is the first use of the stencil buffer within this RenderList, clear it (this avoids unnecessary clears).
+ if( !usedStencilBuffer )
+ {
+ context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
+ usedStencilBuffer = true;
+ }
+
+ // Setup the stencil buffer based on the renderers properties.
+ context.StencilFunc( DaliStencilFunctionToGL[ renderer->GetStencilFunction() ],
+ renderer->GetStencilFunctionReference(),
+ renderer->GetStencilFunctionMask() );
+ context.StencilOp( DaliStencilOperationToGL[ renderer->GetStencilOperationOnFail() ],
+ DaliStencilOperationToGL[ renderer->GetStencilOperationOnZFail() ],
+ DaliStencilOperationToGL[ renderer->GetStencilOperationOnZPass() ] );
+ context.StencilMask( renderer->GetStencilMask() );
}
-
- // Setup the stencil buffer based on the renderers properties.
- context.StencilFunc( DaliStencilFunctionToGL[ renderer->GetStencilFunction() ],
- renderer->GetStencilFunctionReference(),
- renderer->GetStencilFunctionMask() );
- context.StencilOp( DaliStencilOperationToGL[ renderer->GetStencilOperationOnFail() ],
- DaliStencilOperationToGL[ renderer->GetStencilOperationOnZFail() ],
- DaliStencilOperationToGL[ renderer->GetStencilOperationOnZPass() ] );
- context.StencilMask( renderer->GetStencilMask() );
break;
}
}
Context& context,
BufferIndex bufferIndex,
const Matrix& viewMatrix,
- const Matrix& projectionMatrix )
+ const Matrix& projectionMatrix,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable )
{
DALI_PRINT_RENDER_LIST( renderList );
// Note: The depth buffer is enabled or disabled on a per-renderer basis.
// Here we pre-calculate the value to use if these modes are set to AUTO.
- const bool autoDepthTestMode( !( renderList.GetSourceLayer()->IsDepthTestDisabled() ) && renderList.HasColorRenderItems() );
+ const bool autoDepthTestMode( ( depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ) &&
+ !( renderList.GetSourceLayer()->IsDepthTestDisabled() ) &&
+ renderList.HasColorRenderItems() );
const std::size_t count = renderList.Count();
uint32_t lastClippingDepth( 0u );
uint32_t lastClippingId( 0u );
// Set up clipping based on both the Renderer and Actor APIs.
// The Renderer API will be used if specified. If AUTO, the Actors automatic clipping feature will be used.
- SetupClipping( item, context, usedStencilBuffer, lastClippingDepth, lastClippingId );
+ SetupClipping( item, context, usedStencilBuffer, lastClippingDepth, lastClippingId, stencilBufferAvailable );
if( DALI_LIKELY( item.mRenderer ) )
{
- // Set up the depth buffer based on per-renderer flags.
+ // Set up the depth buffer based on per-renderer flags if depth buffer is available
// If the per renderer flags are set to "ON" or "OFF", they will always override any Layer depth mode or
// draw-mode state, such as Overlays.
// If the flags are set to "AUTO", the behavior then depends on the type of renderer. Overlay Renderers will always
// disable depth testing and writing. Color Renderers will enable them if the Layer does.
- SetupDepthBuffer( item, context, autoDepthTestMode, firstDepthBufferUse );
+ if( depthBufferAvailable == Integration::DepthBufferAvailable::TRUE )
+ {
+ SetupDepthBuffer( item, context, autoDepthTestMode, firstDepthBufferUse );
+ }
// Render the item.
item.mRenderer->Render( context, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix,
{
}
-void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instruction, Context& context, BufferIndex bufferIndex )
+void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instruction,
+ Context& context,
+ BufferIndex bufferIndex,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable )
{
DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex );
if( renderList && !renderList->IsEmpty() )
{
- ProcessRenderList( *renderList, context, bufferIndex, *viewMatrix, *projectionMatrix );
+ ProcessRenderList( *renderList,
+ context,
+ bufferIndex,
+ *viewMatrix,
+ *projectionMatrix,
+ depthBufferAvailable,
+ stencilBufferAvailable );
}
}
}
*/
// INTERNAL INCLUDES
+#include <dali/integration-api/core-enumerations.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/render/common/render-list.h>
/**
* Process a render-instruction.
- * @param[in] instruction The render-instruction to process.
- * @param[in] context The GL context.
- * @param[in] bufferIndex The current render buffer index (previous update buffer)
+ * @param[in] instruction The render-instruction to process.
+ * @param[in] context The GL context.
+ * @param[in] bufferIndex The current render buffer index (previous update buffer)
+ * @param[in] depthBufferAvailable Whether the depth buffer is available
+ * @param[in] stencilBufferAvailable Whether the stencil buffer is available
*/
- void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction, Context& context, BufferIndex bufferIndex );
+ void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction,
+ Context& context,
+ BufferIndex bufferIndex,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable );
private:
* @param[in/out] usedStencilBuffer True if the stencil buffer has been used so far within this RenderList. Used by StencilMode::ON.
* @param[in/out] lastClippingDepth The stencil depth of the last renderer drawn. Used by the clipping feature.
* @param[in/out] lastClippingId The clipping ID of the last renderer drawn. Used by the clipping feature.
+ * @param[in] stencilBufferAvailable Whether the stencil buffer is available
*/
- inline void SetupClipping( const Dali::Internal::SceneGraph::RenderItem& item, Context& context, bool& usedStencilBuffer, uint32_t& lastClippingDepth, uint32_t& lastClippingId );
+ inline void SetupClipping( const Dali::Internal::SceneGraph::RenderItem& item,
+ Context& context,
+ bool& usedStencilBuffer,
+ uint32_t& lastClippingDepth,
+ uint32_t& lastClippingId,
+ Integration::StencilBufferAvailable stencilBufferAvailable );
/**
* @brief Process a render-list.
- * @param[in] renderList The render-list to process.
- * @param[in] context The GL context.
- * @param[in] buffer The current render buffer index (previous update buffer)
- * @param[in] viewMatrix The view matrix from the appropriate camera.
- * @param[in] projectionMatrix The projection matrix from the appropriate camera.
+ * @param[in] renderList The render-list to process.
+ * @param[in] context The GL context.
+ * @param[in] buffer The current render buffer index (previous update buffer)
+ * @param[in] viewMatrix The view matrix from the appropriate camera.
+ * @param[in] projectionMatrix The projection matrix from the appropriate camera.
+ * @param[in] depthBufferAvailable Whether the depth buffer is available
+ * @param[in] stencilBufferAvailable Whether the stencil buffer is available
*/
- inline void ProcessRenderList( const Dali::Internal::SceneGraph::RenderList& renderList, Context& context, BufferIndex bufferIndex, const Matrix& viewMatrix, const Matrix& projectionMatrix );
+ inline void ProcessRenderList( const Dali::Internal::SceneGraph::RenderList& renderList,
+ Context& context,
+ BufferIndex bufferIndex,
+ const Matrix& viewMatrix,
+ const Matrix& projectionMatrix,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable );
// Prevent copying:
RenderAlgorithms( RenderAlgorithms& rhs );
struct RenderManager::Impl
{
Impl( Integration::GlAbstraction& glAbstraction,
- Integration::GlSyncAbstraction& glSyncAbstraction )
+ Integration::GlSyncAbstraction& glSyncAbstraction,
+ Integration::DepthBufferAvailable depthBufferAvailableParam,
+ Integration::StencilBufferAvailable stencilBufferAvailableParam )
: context( glAbstraction ),
glSyncAbstraction( glSyncAbstraction ),
renderQueue(),
textureContainer(),
frameBufferContainer(),
lastFrameWasRendered( false ),
- programController( glAbstraction )
+ programController( glAbstraction ),
+ depthBufferAvailable( depthBufferAvailableParam ),
+ stencilBufferAvailable( stencilBufferAvailableParam )
{
}
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;
}
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->context.SetScissorTest( false );
}
- mImpl->renderAlgorithms.ProcessRenderInstruction( instruction, mImpl->context, mImpl->renderBufferIndex );
+ mImpl->renderAlgorithms.ProcessRenderInstruction(
+ instruction,
+ mImpl->context,
+ mImpl->renderBufferIndex,
+ mImpl->depthBufferAvailable,
+ mImpl->stencilBufferAvailable );
if( instruction.mRenderTracker && ( instruction.mFrameBuffer != NULL ) )
{
#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H__
/*
- * 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.
// INTERNAL INCLUDES
#include <dali/public-api/math/rect.h>
+#include <dali/integration-api/core-enumerations.h>
#include <dali/internal/common/shader-saver.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
#include <dali/internal/render/renderers/render-property-buffer.h>
/**
* Construct a new RenderManager.
- * @param[in] glAbstraction The GL abstraction used for rendering.
- * @param[in] glSyncAbstraction The GL sync abstraction used fence sync creation/deletion.
- * @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.*
+ * @param[in] glAbstraction The GL abstraction used for rendering.
+ * @param[in] glSyncAbstraction The GL sync abstraction used fence sync creation/deletion.
+ * @param[in] depthBufferAvailable Whether the depth buffer is available
+ * @param[in] stencilBufferAvailable Whether the stencil buffer is available
*/
static RenderManager* New( Integration::GlAbstraction& glAbstraction,
- Integration::GlSyncAbstraction& glSyncAbstraction );
+ Integration::GlSyncAbstraction& glSyncAbstraction,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable );
/**
* Non-virtual destructor; not intended as a base class