Graphics and Vulkan integration within Adaptor
authorjsr184 <jsr184@gmail.com>
Fri, 17 Nov 2017 16:49:12 +0000 (16:49 +0000)
committerDavid Steele <david.steele@samsung.com>
Thu, 31 May 2018 17:10:43 +0000 (18:10 +0100)
Change-Id: I4a24f5a03e06ec79399746b6b99dc5cabcdf7dc7

16 files changed:
build/tizen/adaptor/Makefile.am
build/tizen/adaptor/configure.ac
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/adaptor-internal-services.h
dali/internal/graphics/common/render-helper.cpp
dali/internal/graphics/common/render-helper.h
dali/internal/graphics/file.list
dali/internal/graphics/vulkan/x11/.clang-format [new file with mode: 0644]
dali/internal/graphics/vulkan/x11/vk-surface-xcb.cpp [new file with mode: 0644]
dali/internal/graphics/vulkan/x11/vk-surface-xcb.h [new file with mode: 0644]
dali/internal/graphics/vulkan/x11/vk-surface-xlib.cpp [new file with mode: 0644]
dali/internal/graphics/vulkan/x11/vk-surface-xlib.h [new file with mode: 0644]
dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.cpp [new file with mode: 0644]
dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.h [new file with mode: 0644]
dali/internal/window-system/ubuntu-x11/window-render-surface-ecore-x.cpp

index dd26888..a8e1b08 100644 (file)
@@ -81,6 +81,11 @@ LIBDALI_ADAPTOR_LA_SOURCES += \
                   $(adaptor_trace_ubuntu_src_files)
 endif
 
+if VULKAN_ENABLED
+LIBDALI_ADAPTOR_LA_SOURCES += \
+                  $(adaptor_graphics_vulkan_x11_src_files)
+endif
+
 endif
 
 
@@ -422,6 +427,7 @@ LIBDALI_ADAPTOR_LA_LIBADD = \
                       $(HARFBUZZ_LIBS) \
                       $(TPKP_CURL_LIBS) \
                       $(UTILX_LIBS) \
+                      $(VULKAN_LIBS) \
                       -lgif \
                       -lpthread \
                       -lturbojpeg \
index 12ee52a..3c631a2 100644 (file)
@@ -308,12 +308,15 @@ PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.
                   [DALI_USE_ECORE_WAYLAND=0])
 
 else
-PKG_CHECK_MODULES(ECORE_X, [ecore-x],
+PKG_CHECK_MODULES(ECORE_X, [ecore-x x11-xcb],
                   [DALI_USE_ECORE_X11=1],
                   [DALI_USE_ECORE_X11=0])
-PKG_CHECK_MODULES(X11, [x11],
+PKG_CHECK_MODULES(X11, [x11 x11-xcb],
                   [DALI_USE_X11=1],
                   [DALI_USE_X11=0])
+#PKG_CHECK_MODULES(X11_XCB, [x11-xcb],
+#                  [DALI_HAS_X11_XCB=1],
+#                  [DALI_HAS_X11_XCB=0])
 fi
 
 # remove this when we update common repos
@@ -353,11 +356,18 @@ if test "x$enable_vulkan" != "xno"; then
                   [ AC_MSG_ERROR([Vulkan not available as a package]) ]
                   )
 
-    DALI_ADAPTOR_CFLAGS+=" ${VULKAN_CFLAGS} -DVK_USE_PLATFORM_XLIB_KHR -DVULKAN_HPP_NO_EXCEPTIONS"
-    DALI_ADAPTOR_LDFLAGS+=" ${VULKAN_LIBS}"
+    DALI_ADAPTOR_CFLAGS+=" ${VULKAN_CFLAGS} -DVULKAN_HPP_NO_EXCEPTIONS"
+
+    # due to a bug in nvidia driver x11-xcb library is required
+    DALI_ADAPTOR_LDFLAGS+=${VULKAN_LIBS}
+
+    if test "x$DALI_HAS_X11_XCB" == "x1"; then
+        echo "X11 libs: ${X11_XCB_LIBS}"
+        DALI_ADAPTOR_LDFLAGS+=${X11_XCB_LIBS}
+    fi
 fi
 
-AM_CONDITIONAL([VULKAN_ENABLED], [test x$enable_vulkan = xyes])
+AM_CONDITIONAL([VULKAN_ENABLED], [test x$enable_vulkan != xno])
 
 AC_SUBST(dataReadWriteDir)
 AC_SUBST(dataReadOnlyDir)
index af8a13e..131a611 100755 (executable)
@@ -28,6 +28,7 @@
 #include <dali/integration-api/profiling.h>
 #include <dali/integration-api/input-options.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/graphics/graphics.h>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/dali-adaptor-common.h>
@@ -53,6 +54,7 @@
 #include <dali/internal/window-system/common/display-connection.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.h>
 
 #include <dali/internal/system/common/logging.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
@@ -147,12 +149,19 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
 
   EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
 
-  mCore = Integration::Core::New( *this,
-                                  *mPlatformAbstraction,
-                                  *mGLES,
-                                  *eglSyncImpl,
-                                  *mGestureManager,
-                                  dataRetentionPolicy ,
+  // todo: add somewhere MakeUnique to make it cleaner
+  mGraphics = std::unique_ptr<Dali::Integration::Graphics::Graphics>(
+    new Dali::Integration::Graphics::Graphics()
+  );
+
+  // todo: surface shouldn't really be create here :((((
+  auto xlibSurface = std::unique_ptr<Dali::Graphics::Vulkan::VkSurfaceXlib2Xcb>(
+    new Dali::Graphics::Vulkan::VkSurfaceXlib2Xcb( *mSurface )
+  );
+
+  mGraphics->Create( std::move(xlibSurface) );
+
+  mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGraphics, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy,
                                   ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
                                   depthBufferAvailable,
                                   stencilBufferAvailable );
@@ -550,6 +559,11 @@ Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
   return *mGLES;
 }
 
+Dali::Integration::Graphics::Graphics& Adaptor::GetGraphics() const
+{
+  return *mGraphics;
+}
+
 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
 {
   return *mPlatformAbstraction;
index 5588cd8..a8f69ba 100755 (executable)
@@ -43,6 +43,8 @@
 #include <dali/integration-api/trigger-event-factory.h>
 #include <dali/internal/network/common/socket-factory.h>
 
+#include <memory>
+
 namespace Dali
 {
 
@@ -53,6 +55,10 @@ namespace Integration
 {
 class Core;
 class GlAbstraction;
+namespace Graphics
+{
+class Graphics;
+}
 }
 
 namespace Internal
@@ -245,6 +251,12 @@ public:
   Integration::GlAbstraction& GetGlAbstraction() const;
 
   /**
+   *
+   * @return the Graphics
+   */
+  Dali::Integration::Graphics::Graphics& GetGraphics() const;
+
+  /**
    * Return the PlatformAbstraction.
    * @return The PlatformAbstraction.
    */
@@ -601,6 +613,9 @@ private: // Data
   SocketFactory                         mSocketFactory;               ///< Socket factory
   const bool                            mEnvironmentOptionsOwned:1;   ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
   bool                                  mUseRemoteSurface;            ///< whether the remoteSurface is used or not
+
+  std::unique_ptr<Dali::Integration::Graphics::Graphics> mGraphics;
+
 public:
   inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;}
 };
index 5d52f9a..c429557 100644 (file)
 namespace Dali
 {
 
+namespace Integration
+{
+namespace Graphics
+{
+class Graphics;
+} // graphics
+} // integration
+
 namespace Internal
 {
 
@@ -74,6 +82,11 @@ public:
   virtual EglFactoryInterface& GetEGLFactoryInterface() const  = 0;
 
   /**
+   * @return Graphics
+   */
+  virtual Dali::Integration::Graphics::Graphics& GetGraphics() const = 0;
+
+  /**
    * Used by update-thread to notify core (main-thread) it has messages to process
    * @return trigger event ProcessCoreEvents
    */
index 87cdb3b..8abff8d 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/graphics/graphics.h>
 
 // INTERNAL INCLUDES
 #include <dali/internal/adaptor/common/adaptor-internal-services.h>
@@ -38,6 +39,7 @@ RenderHelper::RenderHelper( AdaptorInternalServices& adaptorInterfaces )
 : mGLES( adaptorInterfaces.GetGlesInterface() ),
   mEglFactory( &adaptorInterfaces.GetEGLFactoryInterface()),
   mEGL( NULL ),
+  mGraphics( adaptorInterfaces.GetGraphics() ),
   mSurfaceReplaced( false ),
   mSurfaceResized( false )
 {
@@ -61,25 +63,30 @@ RenderHelper::~RenderHelper()
     delete mDisplayConnection;
     mDisplayConnection = NULL;
   }
-
+#if 0
   mEglFactory->Destroy();
+#endif
 }
 
 void RenderHelper::Start()
 {
+#if 0
   if( mSurface )
   {
     mSurface->StartRender();
   }
+#endif
 }
 
 void RenderHelper::Stop()
 {
+#if 0
   if( mSurface )
   {
     // Tell surface we have stopped rendering
     mSurface->StopRender();
   }
+#endif
 }
 
 void RenderHelper::ConsumeEvents()
@@ -89,6 +96,7 @@ void RenderHelper::ConsumeEvents()
 
 void RenderHelper::InitializeEgl()
 {
+#if 0
   mEGL = mEglFactory->Create();
 
   DALI_ASSERT_ALWAYS( mSurface && "NULL surface" );
@@ -105,10 +113,12 @@ void RenderHelper::InitializeEgl()
 
   // Make it current
   mEGL->MakeContextCurrent();
+#endif
 }
 
 void RenderHelper::ReplaceSurface( RenderSurface* newSurface )
 {
+#if 0
   mSurface->DestroyEglSurface(*mEGL);
 
   // This is designed for replacing pixmap surfaces, but should work for window as well
@@ -124,6 +134,7 @@ void RenderHelper::ReplaceSurface( RenderSurface* newSurface )
   // use the new surface from now on
   mSurface = newSurface;
   mSurfaceReplaced = true;
+#endif
 }
 
 void RenderHelper::ResizeSurface()
@@ -133,6 +144,7 @@ void RenderHelper::ResizeSurface()
 
 void RenderHelper::ShutdownEgl()
 {
+#if 0
   if( mSurface )
   {
     // give a chance to destroy the OpenGL surface that created externally
@@ -143,20 +155,26 @@ void RenderHelper::ShutdownEgl()
 
   // delete the GL context / egl surface
   mEGL->TerminateGles();
+#endif
 }
 
 bool RenderHelper::PreRender()
 {
+  mGraphics.PreRender( 1 );
+#if 0
   if( mSurface )
   {
     mSurface->PreRender( *mEGL, mGLES, mSurfaceResized );
   }
   mGLES.PreRender();
+#endif
   return true;
 }
 
 void RenderHelper::PostRender( bool renderToFbo )
 {
+  mGraphics.PostRender( 1 );
+#if 0
   // Inform the gl implementation that rendering has finished before informing the surface
   mGLES.PostRender();
 
@@ -175,6 +193,7 @@ void RenderHelper::PostRender( bool renderToFbo )
   }
   mSurfaceReplaced = false;
   mSurfaceResized = false;
+#endif
 }
 
 } // namespace Adaptor
index 641a0cb..c2d6f25 100644 (file)
@@ -31,6 +31,10 @@ class DisplayConnection;
 namespace Integration
 {
 class GlAbstraction;
+namespace Graphics
+{
+class Graphics;
+}
 }
 
 namespace Internal
@@ -143,13 +147,14 @@ private:
 
 private: // Data
 
-  Integration::GlAbstraction&   mGLES;                   ///< GL abstraction reference
-  EglFactoryInterface*          mEglFactory;             ///< Factory class to create EGL implementation
-  EglInterface*                 mEGL;                    ///< Interface to EGL implementation
-  RenderSurface*                mSurface;                ///< Current surface
-  Dali::DisplayConnection*      mDisplayConnection;      ///< Display connection
-  bool                          mSurfaceReplaced;        ///< True when new surface has been initialized.
-  bool                          mSurfaceResized;         ///< True when the surface is resized.
+  Integration::GlAbstraction&       mGLES;                   ///< GL abstraction reference
+  EglFactoryInterface*              mEglFactory;             ///< Factory class to create EGL implementation
+  EglInterface*                     mEGL;                    ///< Interface to EGL implementation
+  RenderSurface*                    mSurface;                ///< Current surface
+  Dali::DisplayConnection*          mDisplayConnection;      ///< Display connection
+  Integration::Graphics::Graphics&  mGraphics;
+  bool                              mSurfaceReplaced;        ///< True when new surface has been initialized.
+  bool                              mSurfaceResized;         ///< True when the surface is resized.
 };
 
 } // namespace Adaptor
index 31217fb..5ee7530 100644 (file)
@@ -24,4 +24,9 @@ adaptor_graphics_ubuntu_gl_src_files=\
 
 # module: graphics, backend: ubuntu
 adaptor_graphics_ubuntu_src_files=\
-    ${adaptor_graphics_dir}/ubuntu/vsync-monitor-ubuntu.cpp
\ No newline at end of file
+    ${adaptor_graphics_dir}/ubuntu/vsync-monitor-ubuntu.cpp
+
+adaptor_vulkan_ubuntu_src_files = \
+    $(adaptor_graphics_dir)/vulkan/x11/vk-surface-xcb.cpp \
+    $(adaptor_graphics_dir)/vulkan/x11/vk-surface-xlib.cpp \
+    $(adaptor_graphics_dir)/vulkan/x11/vk-surface-xlib2xcb.cpp
diff --git a/dali/internal/graphics/vulkan/x11/.clang-format b/dali/internal/graphics/vulkan/x11/.clang-format
new file mode 100644 (file)
index 0000000..6ef73d4
--- /dev/null
@@ -0,0 +1,103 @@
+---
+Language:        Cpp
+BasedOnStyle:  Google
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: true
+AlignConsecutiveDeclarations: true
+
+AlignEscapedNewlinesLeft: true
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: true
+
+BinPackArguments: true
+BinPackParameters: true
+
+BraceWrapping:
+  AfterClass:      false
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   false
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  BeforeCatch:     false
+  BeforeElse:      false
+  IndentBraces:    false
+
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Allman
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: false
+ColumnLimit:     100
+CommentPragmas:  '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 0
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: true
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: true
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeCategories:
+  - Regex:           '^<.*\.h>'
+    Priority:        1
+  - Regex:           '^<.*'
+    Priority:        2
+  - Regex:           '.*'
+    Priority:        3
+IncludeIsMainRegex: '([-_](test|unittest))?$'
+IndentCaseLabels: false
+IndentWidth:     2
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: false
+PenaltyBreakBeforeFirstCallParameter: 50
+PenaltyBreakComment: 300000000
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1
+PenaltyReturnTypeOnItsOwnLine: 200
+PointerAlignment: Left
+ReflowComments:  false
+SortIncludes:    true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: Never
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  true
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: true
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Auto
+TabWidth:        2
+UseTab:          Never
+...
+
+
diff --git a/dali/internal/graphics/vulkan/x11/vk-surface-xcb.cpp b/dali/internal/graphics/vulkan/x11/vk-surface-xcb.cpp
new file mode 100644 (file)
index 0000000..f5cb9ef
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ */
+
+#include <dali/internal/graphics/vulkan/x11/vk-surface-xcb.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+
+VkSurfaceXcb::VkSurfaceXcb(xcb_connection_t* connection, xcb_window_t window)
+: VkSurfaceFactory{}, mConnection(connection), mWindow(window)
+{
+}
+
+vk::SurfaceKHR VkSurfaceXcb::Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
+                                    vk::PhysicalDevice physicalDevice) const
+{
+  vk::XcbSurfaceCreateInfoKHR info;
+  info.setConnection(mConnection).setWindow(mWindow);
+  auto retval = instance.createXcbSurfaceKHR(info, allocCallbacks).value;
+  return retval;
+}
+}
+}
+}
diff --git a/dali/internal/graphics/vulkan/x11/vk-surface-xcb.h b/dali/internal/graphics/vulkan/x11/vk-surface-xcb.h
new file mode 100644 (file)
index 0000000..1c71bc8
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef DALI_GRAPHICS_VULKAN_VKSURFACEXCB_H
+#define DALI_GRAPHICS_VULKAN_VKSURFACEXCB_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.
+ *
+ */
+#ifndef VK_USE_PLATFORM_XCB_KHR
+#define VK_USE_PLATFORM_XCB_KHR
+#endif
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
+
+// EXTERNAL INCLUDES
+#include <vulkan/vulkan.hpp>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+
+class VkSurfaceXcb final : public Dali::Integration::Graphics::Vulkan::VkSurfaceFactory
+{
+public:
+  /**
+   * Instantiates surface factory ( should
+   * @param display
+   * @param window
+   */
+  VkSurfaceXcb(xcb_connection_t* connection, xcb_window_t window);
+
+  virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
+                                vk::PhysicalDevice physicalDevice) const override;
+
+private:
+  xcb_connection_t* mConnection;
+  xcb_window_t      mWindow;
+  vk::SurfaceKHR    mSurface;
+};
+
+} // Namespace Vulkan
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif // DALI_GRAPHICS_VULKAN_VKSURFACEXCB_H
diff --git a/dali/internal/graphics/vulkan/x11/vk-surface-xlib.cpp b/dali/internal/graphics/vulkan/x11/vk-surface-xlib.cpp
new file mode 100644 (file)
index 0000000..791c19d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ *
+ */
+
+#include <adaptors/devel-api/adaptor-framework/render-surface.h>
+#include <dali/internal/graphics/vulkan/x11/vk-surface-xlib.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+
+VkSurfaceXlib::VkSurfaceXlib(Dali::RenderSurface& renderSurface)
+: VkSurfaceFactory()
+{
+  auto ecoreSurface = dynamic_cast<Dali::ECore::WindowRenderSurface*>(&renderSurface);
+  assert( ecoreSurface != nullptr && "This is not ecore surface!");
+  mWindow = ecoreSurface->GetXWindow();
+  mDisplay = XOpenDisplay(nullptr);
+}
+
+VkSurfaceXlib::VkSurfaceXlib(Display* display, Window window)
+: VkSurfaceFactory(), mDisplay(display), mWindow(window)
+{
+}
+
+vk::SurfaceKHR VkSurfaceXlib::Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
+                                     vk::PhysicalDevice physicalDevice) const
+{
+  vk::XlibSurfaceCreateInfoKHR info;
+  info.setDpy(mDisplay).setWindow(mWindow);
+  auto retval = instance.createXlibSurfaceKHR(info, allocCallbacks).value;
+  return retval;
+}
+}
+}
+}
diff --git a/dali/internal/graphics/vulkan/x11/vk-surface-xlib.h b/dali/internal/graphics/vulkan/x11/vk-surface-xlib.h
new file mode 100644 (file)
index 0000000..492f986
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef DALI_GRAPHICS_VULKAN_VKSURFACEXLIB_H
+#define DALI_GRAPHICS_VULKAN_VKSURFACEXLIB_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.
+ *
+ */
+
+#ifndef VK_USE_PLATFORM_XLIB_KHR
+#define VK_USE_PLATFORM_XLIB_KHR
+#endif
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
+
+// EXTERNAL INCLUDES
+#include <vulkan/vulkan.hpp>
+
+namespace Dali
+{
+class RenderSurface;
+
+namespace Graphics
+{
+namespace Vulkan
+{
+
+class VkSurfaceXlib final : public Dali::Integration::Graphics::Vulkan::VkSurfaceFactory
+{
+public:
+  VkSurfaceXlib(Dali::RenderSurface& renderSurface);
+
+  VkSurfaceXlib(Display* display, Window window);
+
+  virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
+                                vk::PhysicalDevice physicalDevice) const override;
+
+private:
+  Display*       mDisplay;
+  ::Window       mWindow;
+  vk::SurfaceKHR mSurface;
+};
+
+} // Namespace Vulkan
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif // DALI_GRAPHICS_VULKAN_VKSURFACEXLIB_H
diff --git a/dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.cpp b/dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.cpp
new file mode 100644 (file)
index 0000000..cfc301e
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ *
+ */
+
+#include <adaptors/devel-api/adaptor-framework/render-surface.h>
+#include <dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
+
+#include <X11/Xlib-xcb.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+
+VkSurfaceXlib2Xcb::VkSurfaceXlib2Xcb(Dali::RenderSurface& renderSurface)
+: VkSurfaceFactory()
+{
+  auto ecoreSurface = dynamic_cast<Dali::ECore::WindowRenderSurface*>(&renderSurface);
+  assert( ecoreSurface != nullptr && "This is not ecore surface!");
+  mConnection = XGetXCBConnection(XOpenDisplay(nullptr));
+  mWindow = static_cast<decltype(mWindow)>(ecoreSurface->GetXWindow());
+}
+
+VkSurfaceXlib2Xcb::VkSurfaceXlib2Xcb(Display* display, Window window)
+: VkSurfaceFactory()
+{
+  mConnection = XGetXCBConnection(display);
+  mWindow = static_cast<decltype(mWindow)>(window);
+}
+
+vk::SurfaceKHR VkSurfaceXlib2Xcb::Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
+                                     vk::PhysicalDevice physicalDevice) const
+{
+  vk::XcbSurfaceCreateInfoKHR info;
+  info.setConnection(mConnection).setWindow(mWindow);
+  auto retval = instance.createXcbSurfaceKHR(info, allocCallbacks).value;
+  return retval;
+}
+}
+}
+}
diff --git a/dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.h b/dali/internal/graphics/vulkan/x11/vk-surface-xlib2xcb.h
new file mode 100644 (file)
index 0000000..3ae16c1
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef DALI_GRAPHICS_VULKAN_VKSURFACEXLIB2XCB_H
+#define DALI_GRAPHICS_VULKAN_VKSURFACEXLIB2XCB_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.
+ *
+ */
+
+#ifndef VK_USE_PLATFORM_XLIB_KHR
+#define VK_USE_PLATFORM_XLIB_KHR
+#endif
+#ifndef VK_USE_PLATFORM_XCB_KHR
+#define VK_USE_PLATFORM_XCB_KHR
+#endif
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
+
+// EXTERNAL INCLUDES
+#include <vulkan/vulkan.hpp>
+
+namespace Dali
+{
+class RenderSurface;
+
+namespace Graphics
+{
+namespace Vulkan
+{
+/**
+ * This surface exists only because of ( probably ) Nvidia driver bug.
+ * Presenting swapchain that uses Xlib surface crashes. Class VkSurfaceXlib2Xcb
+ * takes Xlib window arguments but creates Xcb surface. It's a workaround.
+ */
+class VkSurfaceXlib2Xcb final : public Dali::Integration::Graphics::Vulkan::VkSurfaceFactory
+{
+public:
+  VkSurfaceXlib2Xcb(Dali::RenderSurface& renderSurface);
+
+  VkSurfaceXlib2Xcb(Display* display, Window window);
+
+  virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
+                                vk::PhysicalDevice physicalDevice) const override;
+
+private:
+  xcb_connection_t* mConnection;
+  xcb_window_t      mWindow;
+  vk::SurfaceKHR    mSurface;
+};
+
+} // Namespace Vulkan
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif // DALI_GRAPHICS_VULKAN_VKSURFACEXLIB2XCB_H
index f050c2b..d4e0ae2 100644 (file)
@@ -253,7 +253,7 @@ void WindowRenderSurfaceEcoreX::PostRender( EglInterface& egl, Integration::GlAb
   if(mNeedToApproveDeiconify)
   {
     // SwapBuffer is desychronized. So make sure to sychronize when window is deiconified.
-    glAbstraction.Finish();
+    //glAbstraction.Finish();
 
     XDisplay* display = AnyCast<XDisplay *>(displayConnection->GetDisplay());