[4.0] Depth & Stencil buffers now disabled by default, can be enabled using env var 27/160727/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 9 Nov 2017 15:04:26 +0000 (15:04 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 17 Nov 2017 18:08:28 +0000 (18:08 +0000)
Change-Id: I8ebfdb92be54b4705768a4a97dc89e42c5aff59a
(cherry picked from commit e4e5b7e737577d552f6d1e92bbe2882312758a10)

adaptors/base/environment-options.cpp
adaptors/base/environment-options.h
adaptors/base/environment-variables.h
adaptors/common/adaptor-impl.cpp
adaptors/common/gl/egl-factory.cpp
adaptors/common/gl/egl-factory.h
adaptors/common/gl/egl-implementation.cpp
adaptors/common/gl/egl-implementation.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp

index 7d2d354..792b2ab 100644 (file)
@@ -39,6 +39,8 @@ namespace
 {
 const unsigned int DEFAULT_STATISTICS_LOG_FREQUENCY = 2;
 const int DEFAULT_MULTI_SAMPLING_LEVEL = -1;
+const bool DEFAULT_DEPTH_BUFFER_REQUIRED_SETTING = true;
+const bool DEFAULT_STENCIL_BUFFER_REQUIRED_SETTING = true;
 
 unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
 {
@@ -83,36 +85,38 @@ const char * GetCharEnvironmentVariable( const char * variable )
 } // unnamed namespace
 
 EnvironmentOptions::EnvironmentOptions()
-: mWindowName(),
+: mLogFunction( NULL ),
+  mWindowName(),
   mWindowClassName(),
-  mNetworkControl(0),
-  mFpsFrequency(0),
-  mUpdateStatusFrequency(0),
+  mPanGestureSmoothingAmount( -1.0f ),
+  mNetworkControl( 0 ),
+  mFpsFrequency( 0 ),
+  mUpdateStatusFrequency( 0 ),
   mObjectProfilerInterval( 0 ),
-  mPerformanceStatsLevel(0),
+  mPerformanceStatsLevel( 0 ),
   mPerformanceStatsFrequency( DEFAULT_STATISTICS_LOG_FREQUENCY ),
-  mPerformanceTimeStampOutput(0),
-  mPanGestureLoggingLevel(0),
-  mPanGesturePredictionMode(-1),
-  mPanGesturePredictionAmount(-1), ///< only sets value in pan gesture if greater than 0
-  mPanGestureMaxPredictionAmount(-1),
-  mPanGestureMinPredictionAmount(-1),
-  mPanGesturePredictionAmountAdjustment(-1),
-  mPanGestureSmoothingMode(-1),
-  mPanGestureSmoothingAmount(-1.0f),
-  mPanMinimumDistance(-1),
-  mPanMinimumEvents(-1),
-  mGlesCallTime( 0 ),
+  mPerformanceTimeStampOutput( 0 ),
+  mPanGestureLoggingLevel( 0 ),
   mWindowWidth( 0u ),
   mWindowHeight( 0u ),
-  mThreadingMode( ThreadingMode::COMBINED_UPDATE_RENDER ),
   mRenderRefreshRate( 1u ),
-  mGlesCallAccumulate( false ),
-  mMultiSamplingLevel( DEFAULT_MULTI_SAMPLING_LEVEL ),
   mMaxTextureSize( 0 ),
-  mIndicatorVisibleMode( -1 ),
   mRenderToFboInterval( 0u ),
-  mLogFunction( NULL )
+  mPanGesturePredictionMode( -1 ),
+  mPanGesturePredictionAmount( -1 ), ///< only sets value in pan gesture if greater than 0
+  mPanGestureMaxPredictionAmount( -1 ),
+  mPanGestureMinPredictionAmount( -1 ),
+  mPanGesturePredictionAmountAdjustment( -1 ),
+  mPanGestureSmoothingMode( -1 ),
+  mPanMinimumDistance( -1 ),
+  mPanMinimumEvents( -1 ),
+  mGlesCallTime( 0 ),
+  mMultiSamplingLevel( DEFAULT_MULTI_SAMPLING_LEVEL ),
+  mIndicatorVisibleMode( -1 ),
+  mThreadingMode( ThreadingMode::COMBINED_UPDATE_RENDER ),
+  mGlesCallAccumulate( false ),
+  mDepthBufferRequired( DEFAULT_DEPTH_BUFFER_REQUIRED_SETTING ),
+  mStencilBufferRequired( DEFAULT_STENCIL_BUFFER_REQUIRED_SETTING )
 {
   ParseEnvironmentOptions();
 }
@@ -285,6 +289,16 @@ bool EnvironmentOptions::PerformanceServerRequired() const
            ( GetNetworkControlMode() > 0) );
 }
 
+bool EnvironmentOptions::DepthBufferRequired() const
+{
+  return mDepthBufferRequired;
+}
+
+bool EnvironmentOptions::StencilBufferRequired() const
+{
+  return mStencilBufferRequired;
+}
+
 void EnvironmentOptions::ParseEnvironmentOptions()
 {
   // get logging options
@@ -445,6 +459,26 @@ void EnvironmentOptions::ParseEnvironmentOptions()
   }
 
   mRenderToFboInterval = GetIntegerEnvironmentVariable( DALI_RENDER_TO_FBO, 0u );
+
+
+  int depthBufferRequired( -1 );
+  if( GetIntegerEnvironmentVariable( DALI_ENV_DISABLE_DEPTH_BUFFER, depthBufferRequired ) )
+  {
+    if( depthBufferRequired > 0 )
+    {
+      mDepthBufferRequired = false;
+      mStencilBufferRequired = false; // Disable stencil buffer as well
+    }
+  }
+
+  int stencilBufferRequired( -1 );
+  if( GetIntegerEnvironmentVariable( DALI_ENV_DISABLE_STENCIL_BUFFER, stencilBufferRequired ) )
+  {
+    if( stencilBufferRequired > 0 )
+    {
+      mStencilBufferRequired = false;
+    }
+  }
 }
 
 } // Adaptor
index 080850e..987006d 100644 (file)
@@ -224,6 +224,28 @@ public:
    */
   unsigned int GetRenderToFboInterval() const;
 
+  /**
+   * @return Whether the depth buffer is required.
+   */
+  bool DepthBufferRequired() const;
+
+  /**
+   * @return Whether the stencil buffer is required.
+   */
+  bool StencilBufferRequired() const;
+
+  /// Deleted copy constructor.
+  EnvironmentOptions( const EnvironmentOptions& ) = delete;
+
+  /// Deleted move constructor.
+  EnvironmentOptions( const EnvironmentOptions&& ) = delete;
+
+  /// Deleted assignment operator.
+  EnvironmentOptions& operator=( const EnvironmentOptions& ) = delete;
+
+  /// Deleted move assignment operator.
+  EnvironmentOptions& operator=( const EnvironmentOptions&& ) = delete;
+
 private: // Internal
 
   /**
@@ -234,8 +256,11 @@ private: // Internal
 
 private: // Data
 
+  Dali::Integration::Log::LogFunction mLogFunction;
+
   std::string mWindowName;                        ///< name of the window
   std::string mWindowClassName;                   ///< name of the class the window belongs to
+  float mPanGestureSmoothingAmount;               ///< prediction amount for pan gestures
   unsigned int mNetworkControl;                   ///< whether network control is enabled
   unsigned int mFpsFrequency;                     ///< how often fps is logged out in seconds
   unsigned int mUpdateStatusFrequency;            ///< how often update status is logged out in frames
@@ -244,34 +269,26 @@ private: // Data
   unsigned int mPerformanceStatsFrequency;        ///< performance statistics logging frequency (seconds)
   unsigned int mPerformanceTimeStampOutput;       ///< performance time stamp output ( bitmask)
   unsigned int mPanGestureLoggingLevel;           ///< pan-gesture log level
+  unsigned int mWindowWidth;                      ///< width of the window
+  unsigned int mWindowHeight;                     ///< height of the window
+  unsigned int mRenderRefreshRate;                ///< render refresh rate
+  unsigned int mMaxTextureSize;                   ///< The maximum texture size that GL can handle
+  unsigned int mRenderToFboInterval;              ///< The number of frames that are going to be rendered into the Frame Buffer Object but the last one which is going to be rendered into the Frame Buffer.
   int mPanGesturePredictionMode;                  ///< prediction mode for pan gestures
   int mPanGesturePredictionAmount;                ///< prediction amount for pan gestures
   int mPanGestureMaxPredictionAmount;             ///< maximum prediction amount for pan gestures
   int mPanGestureMinPredictionAmount;             ///< minimum prediction amount for pan gestures
   int mPanGesturePredictionAmountAdjustment;      ///< adjustment of prediction amount for pan gestures
   int mPanGestureSmoothingMode;                   ///< prediction mode for pan gestures
-  float mPanGestureSmoothingAmount;               ///< prediction amount for pan gestures
   int mPanMinimumDistance;                        ///< minimum distance required before pan starts
   int mPanMinimumEvents;                          ///< minimum events required before pan starts
   int mGlesCallTime;                              ///< time in seconds between status updates
-  unsigned int mWindowWidth;                      ///< width of the window
-  unsigned int mWindowHeight;                     ///< height of the window
-  ThreadingMode::Type mThreadingMode;             ///< threading mode
-  unsigned int mRenderRefreshRate;                ///< render refresh rate
-  bool mGlesCallAccumulate;                       ///< Whether or not to accumulate gles call statistics
   int mMultiSamplingLevel;                        ///< The number of samples required in multisample buffers
-  unsigned int mMaxTextureSize;                   ///< The maximum texture size that GL can handle
   int mIndicatorVisibleMode;                      ///< Indicator visible mode
-  unsigned int mRenderToFboInterval;              ///< The number of frames that are going to be rendered into the Frame Buffer Object but the last one which is going to be rendered into the Frame Buffer.
-
-  Dali::Integration::Log::LogFunction mLogFunction;
-
-  // Undefined copy constructor.
-  EnvironmentOptions( const EnvironmentOptions& );
-
-  // Undefined assignment operator.
-  EnvironmentOptions& operator=( const EnvironmentOptions& );
-
+  ThreadingMode::Type mThreadingMode;             ///< threading mode
+  bool mGlesCallAccumulate;                       ///< Whether or not to accumulate gles call statistics
+  bool mDepthBufferRequired;                      ///< Whether the depth buffer is required
+  bool mStencilBufferRequired;                    ///< Whether the stencil buffer is required
 };
 
 } // Adaptor
index 234ce3c..5d02f79 100644 (file)
@@ -101,6 +101,10 @@ namespace Adaptor
 
 #define DALI_RENDER_TO_FBO "DALI_RENDER_TO_FBO"
 
+#define DALI_ENV_DISABLE_DEPTH_BUFFER "DALI_DISABLE_DEPTH_BUFFER"
+
+#define DALI_ENV_DISABLE_STENCIL_BUFFER "DALI_DISABLE_STENCIL_BUFFER"
+
 } // namespace Adaptor
 
 } // namespace Internal
index 1a77222..0656c18 100644 (file)
@@ -140,7 +140,10 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
     mGLES = new GlImplementation();
   }
 
-  mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel() );
+  const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
+  const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
+
+  mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
 
   EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
 
@@ -150,7 +153,9 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
                                   *eglSyncImpl,
                                   *mGestureManager,
                                   dataRetentionPolicy ,
-                                  0u != mEnvironmentOptions->GetRenderToFboInterval() );
+                                  ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
+                                  depthBufferAvailable,
+                                  stencilBufferAvailable );
 
   const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
   if( 0u < timeInterval )
index b30621d..05fa711 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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.
@@ -30,11 +30,15 @@ namespace Internal
 namespace Adaptor
 {
 
-EglFactory::EglFactory( int multiSamplingLevel )
+EglFactory::EglFactory( int multiSamplingLevel,
+                        Integration::DepthBufferAvailable depthBufferRequired,
+                        Integration::StencilBufferAvailable stencilBufferRequired )
 : mEglImplementation(NULL),
   mEglImageExtensions(NULL),
   mEglSync(new EglSyncImplementation), // Created early, as needed by Core constructor
-  mMultiSamplingLevel( multiSamplingLevel )
+  mMultiSamplingLevel( multiSamplingLevel ),
+  mDepthBufferRequired( depthBufferRequired ),
+  mStencilBufferRequired( stencilBufferRequired )
 {
 }
 
@@ -49,7 +53,7 @@ EglFactory::~EglFactory()
 EglInterface* EglFactory::Create()
 {
   // Created by RenderThread (After Core construction)
-  mEglImplementation = new EglImplementation( mMultiSamplingLevel );
+  mEglImplementation = new EglImplementation( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired );
   mEglImageExtensions = new EglImageExtensions( mEglImplementation );
 
   mEglSync->Initialize(mEglImplementation); // The sync impl needs the EglDisplay
index 872f39f..a69336c 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
-#define __DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
+#ifndef DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H
+#define DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H
 
 /*
- * Copyright (c) 2014 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.
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/integration-api/core-enumerations.h>
 
 // INTERNAL INCLUDES
 #include <base/interfaces/egl-factory-interface.h>
@@ -36,10 +37,16 @@ class EglSyncImplementation;
 class EglFactory : public EglFactoryInterface
 {
 public:
+
   /**
    * Constructor
+   * @param[in] multiSamplingLevel The Multi-sampling level required
+   * @param[in] depthBufferRequired Whether the depth buffer is required
+   * @param[in] stencilBufferRequired Whether the stencil buffer is required
    */
-  EglFactory( int multiSamplingLevel );
+  EglFactory( int multiSamplingLevel,
+              Integration::DepthBufferAvailable depthBufferRequired,
+              Integration::StencilBufferAvailable stencilBufferRequired );
 
   /**
    * Destructor
@@ -85,10 +92,12 @@ private:
   EglSyncImplementation* mEglSync;
 
   int mMultiSamplingLevel;
+  Integration::DepthBufferAvailable mDepthBufferRequired;
+  Integration::StencilBufferAvailable mStencilBufferRequired;
 };
 
-}
-}
-}
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
 
-#endif //__DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
+#endif // DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H
index 7ca4366..c6b179d 100644 (file)
@@ -52,20 +52,25 @@ namespace Adaptor
   } \
 }
 
-EglImplementation::EglImplementation( int multiSamplingLevel )
-  : mEglNativeDisplay(0),
-    mEglNativeWindow(0),
-    mCurrentEglNativePixmap(0),
-    mEglDisplay(0),
-    mEglConfig(0),
-    mEglContext(0),
-    mCurrentEglSurface(0),
-    mGlesInitialized(false),
-    mIsOwnSurface(true),
-    mContextCurrent(false),
-    mIsWindow(true),
-    mColorDepth(COLOR_DEPTH_24),
-    mMultiSamplingLevel( multiSamplingLevel )
+EglImplementation::EglImplementation( int multiSamplingLevel,
+                                      Integration::DepthBufferAvailable depthBufferRequired,
+                                      Integration::StencilBufferAvailable stencilBufferRequired )
+: mContextAttribs(),
+  mEglNativeDisplay( 0 ),
+  mEglNativeWindow( 0 ),
+  mCurrentEglNativePixmap( 0 ),
+  mEglDisplay( 0 ),
+  mEglConfig( 0 ),
+  mEglContext( 0 ),
+  mCurrentEglSurface( 0 ),
+  mMultiSamplingLevel( multiSamplingLevel ),
+  mColorDepth( COLOR_DEPTH_24 ),
+  mGlesInitialized( false ),
+  mIsOwnSurface( true ),
+  mContextCurrent( false ),
+  mIsWindow( true ),
+  mDepthBufferRequired( depthBufferRequired == Integration::DepthBufferAvailable::TRUE ),
+  mStencilBufferRequired( stencilBufferRequired == Integration::StencilBufferAvailable::TRUE )
 {
 }
 
@@ -330,9 +335,10 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
 #endif // _ARCH_ARM_
 
   configAttribs.PushBack( EGL_DEPTH_SIZE );
-  configAttribs.PushBack( 24 );
+  configAttribs.PushBack( mDepthBufferRequired ? 24 : 0 );
   configAttribs.PushBack( EGL_STENCIL_SIZE );
-  configAttribs.PushBack( 8 );
+  configAttribs.PushBack( mStencilBufferRequired ? 8 : 0 );
+
 #ifndef DALI_PROFILE_UBUNTU
   if( mMultiSamplingLevel != EGL_DONT_CARE )
   {
index 4081ed3..10ffdc7 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
-#define __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
+#ifndef DALI_INTERNAL_EGL_IMPLEMENTATION_H
+#define DALI_INTERNAL_EGL_IMPLEMENTATION_H
 
 /*
  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
@@ -22,6 +22,7 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/integration-api/core-enumerations.h>
 
 // INTERNAL INCLUDES
 #include <adaptors/integration-api/egl-interface.h>
@@ -40,11 +41,16 @@ namespace Adaptor
 class EglImplementation : public EglInterface
 {
 public:
+
   /**
    * Constructor
-   * @param environmentOptions To check the envirionment options
+   * @param[in] multiSamplingLevel The Multi-sampling level required
+   * @param[in] depthBufferRequired Whether the depth buffer is required
+   * @param[in] stencilBufferRequired Whether the stencil buffer is required
    */
-  EglImplementation( int multiSamplingLevel );
+  EglImplementation( int multiSamplingLevel,
+                     Integration::DepthBufferAvailable depthBufferRequired,
+                     Integration::StencilBufferAvailable stencilBufferRequired );
 
   /**
    * Destructor
@@ -189,13 +195,16 @@ private:
   EGLContext           mEglContext;
   EGLSurface           mCurrentEglSurface;
 
+  int                  mMultiSamplingLevel;
+
+  ColorDepth           mColorDepth;
+
   bool                 mGlesInitialized;
   bool                 mIsOwnSurface;
   bool                 mContextCurrent;
   bool                 mIsWindow;
-  ColorDepth           mColorDepth;
-
-  int                  mMultiSamplingLevel;
+  bool                 mDepthBufferRequired;
+  bool                 mStencilBufferRequired;
 };
 
 } // namespace Adaptor
@@ -204,4 +213,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
+#endif // DALI_INTERNAL_EGL_IMPLEMENTATION_H
index 54a69bb..a247f7d 100644 (file)
@@ -68,7 +68,9 @@ void TestApplication::Initialize()
                                         mGlSyncAbstraction,
                                         mGestureManager,
                                         mDataRetentionPolicy,
-                                        false );
+                                        Integration::RenderToFrameBuffer::FALSE,
+                                        Integration::DepthBufferAvailable::TRUE,
+                                        Integration::StencilBufferAvailable::TRUE );
 
   mCore->ContextCreated();
   mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );