Adding vulkan surface to android build 13/324713/3 devel/master
authorDavid Steele <david.steele@samsung.com>
Fri, 13 Jun 2025 17:28:50 +0000 (18:28 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 13 Jun 2025 17:48:28 +0000 (18:48 +0100)
Change-Id: Ie1237b5a8e39e06183f5ab58879b545bfa99ae76

build/tizen/CMakeLists.txt
build/tizen/profiles/android-profile.cmake
dali/internal/graphics/file.list
dali/internal/graphics/vulkan-impl/vulkan-types.h
dali/internal/graphics/vulkan/android/vk-surface-android.cpp [new file with mode: 0644]
dali/internal/graphics/vulkan/android/vk-surface-android.h [new file with mode: 0644]
dali/internal/graphics/vulkan/vulkan-device.cpp
dali/internal/imaging/android/native-image-source-factory-android-vulkan.cpp [new file with mode: 0644]
dali/internal/imaging/file.list
dali/internal/window-system/android/window-base-android.cpp

index 9ebd31b71ebc0f7b54f024b2c203d3255ce97285..cac6eec927a8d75b5ce7fb993373acfd56020b80 100644 (file)
@@ -211,6 +211,8 @@ ENDIF()
 IF(DEFINED ADAPTOR_GRAPHICS_GLES_SOURCES AND DEFINED ADAPTOR_GRAPHICS_VULKAN_SOURCES)
   IF(enable_graphics_backend MATCHES DYNAMIC)
     # Separate GLES Graphics Library
+    MESSAGE(STATUS "Separating GLES and Vulkan graphics into their own libraries")
+
     SET(ADAPTOR_GRAPHICS_GLES_NAME "${name}-gles")
     ADD_LIBRARY(${ADAPTOR_GRAPHICS_GLES_NAME} ${LIBTYPE} ${ADAPTOR_GRAPHICS_GLES_SOURCES})
     TARGET_COMPILE_OPTIONS(${ADAPTOR_GRAPHICS_GLES_NAME} PRIVATE ${DALI_CFLAGS} ${COVERAGE})
@@ -254,6 +256,7 @@ IF(DEFINED ADAPTOR_GRAPHICS_GLES_SOURCES AND DEFINED ADAPTOR_GRAPHICS_VULKAN_SOU
     SET(GRAPHICS_BACKEND_TYPE "Dynamic (GLES/VULKAN)")
   ELSEIF(enable_graphics_backend MATCHES GLES)
     # Add GLES sources to main adaptor library
+    MESSAGE(STATUS "Integrating GLES graphics into main lib")
     SET(GRAPHICS_BACKEND_TYPE "GLES")
     SET(SOURCES ${SOURCES} ${ADAPTOR_GRAPHICS_GLES_SOURCES})
     SET(OPTIONAL_LIBS ${OPTIONAL_LIBS}
@@ -264,6 +267,10 @@ IF(DEFINED ADAPTOR_GRAPHICS_GLES_SOURCES AND DEFINED ADAPTOR_GRAPHICS_VULKAN_SOU
     # Add VULKAN sources to main adaptor library
     SET(GRAPHICS_BACKEND_TYPE "VULKAN")
     SET(SOURCES ${SOURCES} ${ADAPTOR_GRAPHICS_VULKAN_SOURCES})
+    MESSAGE(STATUS "Integrating Vulkan graphics into main lib")
+    IF(ANDROID_PROFILE)
+      ADD_DEFINITIONS(-DVK_USE_PLATFORM_ANDROID_KHR=1)
+    ENDIF()
     SET(OPTIONAL_LIBS ${OPTIONAL_LIBS}
             ${VULKAN_LDFLAGS}
             ${GLSLANG_LDFLAGS}
index 88c3888d0e9115c1f210138efb5aa93250a922ab..584de55b7d39c54aae9f6b1fdd57898f7946356c 100644 (file)
@@ -14,8 +14,6 @@ SET( SOURCES
         ${devel_api_src_files}
         ${adaptor_devel_api_text_abstraction_src_files}
         ${adaptor_graphics_common_src_files}
-        ${adaptor_graphics_gles_src_files}
-        ${adaptor_graphics_android_src_files}
         ${adaptor_haptics_common_src_files}
         ${adaptor_imaging_common_src_files}
         ${adaptor_imaging_android_src_files}
@@ -49,8 +47,24 @@ SET( SOURCES
         ${static_libraries_libunibreak_src_files}
         ${adaptor_addons_common_src_files}
         ${adaptor_addons_android_src_files}
+        ${adaptor_graphics_gles_src_files}
+        ${adaptor_graphics_egl_android_src_files}
+        ${adaptor_imaging_egl_android_src_files}
 )
 
+#SET(ADAPTOR_GRAPHICS_GLES_SOURCES
+#        ${adaptor_graphics_gles_src_files}
+#        ${adaptor_graphics_egl_android_src_files}
+#        ${adaptor_imaging_egl_android_src_files}
+#)
+
+#SET(ADAPTOR_GRAPHICS_VULKAN_SOURCES
+#        ${adaptor_graphics_vulkan_src_files}
+#        ${adaptor_graphics_vulkan_android_src_files}
+#        ${adaptor_imaging_vulkan_android_src_files}
+#        ${adaptor_libraries_spirv_reflect_src_files}
+#)
+
 IF( ENABLE_VECTOR_BASED_TEXT_RENDERING )
     SET( SOURCES ${SOURCES}
          ${static_libraries_glyphy_src_files}
index ff853465228d40fc2b5e9889313cbf4e8218a1b2..a60d621d472fc41d61fd434e07900e7177e43f72 100644 (file)
@@ -78,11 +78,6 @@ SET( adaptor_graphics_vulkan_wayland_src_files
     ${adaptor_graphics_dir}/vulkan/wayland/vk-surface-wayland.cpp
 )
 
-# module: graphics, backend: vulkan/tizen
-SET( adaptor_graphics_vulkan_tizen_src_files
-    ${adaptor_graphics_dir}/vulkan/api/vulkan-api-native-texture.cpp
-)
-
 # module: graphics, backend: tizen
 SET( adaptor_graphics_tizen_src_files
     ${adaptor_graphics_dir}/tizen/egl-image-extensions-tizen.cpp
@@ -101,12 +96,17 @@ SET( adaptor_graphics_x11_src_files
     ${adaptor_graphics_dir}/generic/egl-sync-implementation.cpp
 )
 
-# module: graphics, backend: android
-SET( adaptor_graphics_android_src_files
+# module: graphics, backend: android, egl
+SET( adaptor_graphics_egl_android_src_files
     ${adaptor_graphics_dir}/android/egl-image-extensions-android.cpp
     ${adaptor_graphics_dir}/android/egl-sync-implementation-android.cpp
 )
 
+# module: graphics, backend: android, vulkan
+SET( adaptor_graphics_vulkan_android_src_files
+    ${adaptor_graphics_dir}/vulkan/android/vk-surface-android.cpp
+)
+
 # module: graphics, backend: windows
 SET( adaptor_graphics_windows_src_files
     ${adaptor_graphics_dir}/windows-gl/egl-image-extensions.cpp
index 291d01f8221cd33d951ab920648da872ce8b7a81..50aff187043c8dced1929636fb8155741f854e56 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_VULKAN_TYPES
 
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -128,6 +128,7 @@ enum class Platform
   XLIB,
   XCB,
   WAYLAND,
+  PLATFORM_ANDROID,
 };
 
 struct FormatInfo
diff --git a/dali/internal/graphics/vulkan/android/vk-surface-android.cpp b/dali/internal/graphics/vulkan/android/vk-surface-android.cpp
new file mode 100644 (file)
index 0000000..0697bfc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2025 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/android/vk-surface-android.h>
+#include <dali/internal/graphics/vulkan/vulkan-hpp-wrapper.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+VkSurfaceAndroid::VkSurfaceAndroid(NativeWindowInterface& nativeWindow)
+: SurfaceFactory()
+{
+  mWindow = static_cast<ANativeWindow*>(AnyCast<void*>(nativeWindow.GetNativeWindow()));
+}
+
+VkSurfaceAndroid::VkSurfaceAndroid(ANativeWindow* window)
+: SurfaceFactory()
+{
+  mWindow = window;
+}
+
+vk::SurfaceKHR VkSurfaceAndroid::Create(
+  vk::Instance                   instance,
+  const vk::AllocationCallbacks* allocCallbacks) const
+{
+  vk::AndroidSurfaceCreateInfoKHR info;
+  info.window = mWindow;
+
+  auto retval = instance.createAndroidSurfaceKHR(info, allocCallbacks).value;
+
+  return retval;
+}
+
+} // namespace Vulkan
+
+std::unique_ptr<SurfaceFactory> SurfaceFactory::New(NativeWindowInterface& nativeWindow)
+{
+  auto surfaceFactory = std::unique_ptr<Graphics::Vulkan::VkSurfaceAndroid>(new Graphics::Vulkan::VkSurfaceAndroid(nativeWindow));
+  return surfaceFactory;
+}
+
+} // namespace Graphics
+} // namespace Dali
diff --git a/dali/internal/graphics/vulkan/android/vk-surface-android.h b/dali/internal/graphics/vulkan/android/vk-surface-android.h
new file mode 100644 (file)
index 0000000..fe59d7b
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef DALI_GRAPHICS_VULKAN_SURFACE_ANDROID_H
+#define DALI_GRAPHICS_VULKAN_SURFACE_ANDROID_H
+
+/*
+ * Copyright (c) 2025 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/vulkan/vulkan-surface-factory.h>
+
+// EXTERNAL INCLUDES
+#include <android_native_app_glue.h>
+#include <vulkan/vulkan.hpp>
+
+namespace Dali
+{
+class RenderSurface;
+
+namespace Graphics
+{
+namespace Vulkan
+{
+class VkSurfaceAndroid final : public SurfaceFactory
+{
+public:
+  VkSurfaceAndroid(NativeWindowInterface& renderSurface);
+  VkSurfaceAndroid(ANativeWindow* window);
+
+  virtual vk::SurfaceKHR Create(
+    vk::Instance                   instance,
+    const vk::AllocationCallbacks* allocCallbacks) const override;
+
+private:
+  ANativeWindow* mWindow;
+};
+
+} // Namespace Vulkan
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif // DALI_GRAPHICS_VULKAN_SURFACE_ANDROID_H
index d4a91fd6e106598dcbf1499e60fe19174a6f280e..a35d7a4845f250e22e49e43ac6e179e78b32f61c 100644 (file)
 #define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
 #endif
 
+#ifndef VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
+#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
+#endif
+
 #include <iostream>
 #include <utility>
 
@@ -873,6 +877,7 @@ std::vector<const char*> Device::PrepareDefaultInstanceExtensions()
   bool xlibAvailable{false};
   bool xcbAvailable{false};
   bool waylandAvailable{false};
+  bool androidAvailable{false};
   bool debugReportExtensionAvailable{false};
 
   for(auto&& ext : availableExtensions.value)
@@ -890,6 +895,10 @@ std::vector<const char*> Device::PrepareDefaultInstanceExtensions()
     {
       waylandAvailable = true;
     }
+    else if(extensionName == VK_KHR_ANDROID_SURFACE_EXTENSION_NAME)
+    {
+      androidAvailable = true;
+    }
     else if(extensionName == VK_EXT_DEBUG_REPORT_EXTENSION_NAME)
     {
       debugReportExtensionAvailable = true;
@@ -919,6 +928,10 @@ std::vector<const char*> Device::PrepareDefaultInstanceExtensions()
        *  VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME
        */
     }
+    else if(platform == Platform::PLATFORM_ANDROID && androidAvailable)
+    {
+      extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
+    }
   }
   else // try to determine the platform based on available extensions
   {
@@ -941,6 +954,11 @@ std::vector<const char*> Device::PrepareDefaultInstanceExtensions()
        *  VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME
        */
     }
+    else if(androidAvailable)
+    {
+      mPlatform = Platform::PLATFORM_ANDROID;
+      extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
+    }
     else
     {
       // can't determine the platform!
diff --git a/dali/internal/imaging/android/native-image-source-factory-android-vulkan.cpp b/dali/internal/imaging/android/native-image-source-factory-android-vulkan.cpp
new file mode 100644 (file)
index 0000000..7a4431e
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/imaging/android/native-image-source-factory-android.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/imaging/android/native-image-source-impl-android.h>
+#include <dali/internal/imaging/android/native-image-source-queue-impl-android.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<NativeImageSource> NativeImageSourceFactoryAndroid::CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+{
+  return nullptr;
+}
+
+std::unique_ptr<NativeImageSourceQueue> NativeImageSourceFactoryAndroid::CreateNativeImageSourceQueue(uint32_t queueCount, uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorFormat colorFormat, Any nativeImageSourceQueue)
+{
+  return nullptr;
+}
+
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
+{
+  return nullptr;
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
index 170a5ce72df3a45d05ce3ce20d5fa0589170c245..820876411c6495947cdc422c382c192f9816fb31 100644 (file)
@@ -87,11 +87,20 @@ SET( adaptor_imaging_x11_vulkan_src_files
 # module: imaging, backend: android
 SET( adaptor_imaging_android_src_files
     ${adaptor_imaging_dir}/common/file-download.cpp
+)
+
+# module: imaging, backend: android, egl
+SET( adaptor_imaging_egl_android_src_files
     ${adaptor_imaging_dir}/android/native-image-source-factory-android.cpp
     ${adaptor_imaging_dir}/android/native-image-source-impl-android.cpp
     ${adaptor_imaging_dir}/android/native-image-source-queue-impl-android.cpp
 )
 
+# module: imaging, backend: android, vulkan
+SET( adaptor_imaging_vulkan_android_src_files
+    ${adaptor_imaging_dir}/android/native-image-source-factory-android-vulkan.cpp
+)
+
 # module: imaging, backend: windows
 SET( adaptor_imaging_windows_src_files
     ${adaptor_imaging_dir}/windows/curl-environment-win.cpp
index cb9aea66de4ac545a3ad3245995ae8fd0ee7522c..d24dc5b77bce3b6658f5ea0391f028e4e8556386 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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,7 +19,6 @@
 #include <dali/internal/window-system/android/window-base-android.h>
 
 // INTERNAL HEADERS
-#include <dali/internal/graphics/common/egl-include.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
 
@@ -136,8 +135,6 @@ std::string WindowBaseAndroid::GetNativeWindowResourceId()
 
 Dali::Any WindowBaseAndroid::CreateWindow(int width, int height)
 {
-  // from eglplatform.h header
-  // typedef struct ANativeWindow* EGLNativeWindowType;
   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n");
 
   auto window = static_cast<void*>(mWindow);