From: David Steele Date: Fri, 13 Jun 2025 17:28:50 +0000 (+0100) Subject: Adding vulkan surface to android build X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fdevel%2Fmaster;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Adding vulkan surface to android build Change-Id: Ie1237b5a8e39e06183f5ab58879b545bfa99ae76 --- diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 9ebd31b71..cac6eec92 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -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} diff --git a/build/tizen/profiles/android-profile.cmake b/build/tizen/profiles/android-profile.cmake index 88c3888d0..584de55b7 100644 --- a/build/tizen/profiles/android-profile.cmake +++ b/build/tizen/profiles/android-profile.cmake @@ -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} diff --git a/dali/internal/graphics/file.list b/dali/internal/graphics/file.list index ff8534652..a60d621d4 100644 --- a/dali/internal/graphics/file.list +++ b/dali/internal/graphics/file.list @@ -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 diff --git a/dali/internal/graphics/vulkan-impl/vulkan-types.h b/dali/internal/graphics/vulkan-impl/vulkan-types.h index 291d01f82..50aff1870 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-types.h +++ b/dali/internal/graphics/vulkan-impl/vulkan-types.h @@ -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 index 000000000..0697bfc28 --- /dev/null +++ b/dali/internal/graphics/vulkan/android/vk-surface-android.cpp @@ -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 +#include +#include + +namespace Dali +{ +namespace Graphics +{ +namespace Vulkan +{ +VkSurfaceAndroid::VkSurfaceAndroid(NativeWindowInterface& nativeWindow) +: SurfaceFactory() +{ + mWindow = static_cast(AnyCast(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::New(NativeWindowInterface& nativeWindow) +{ + auto surfaceFactory = std::unique_ptr(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 index 000000000..fe59d7b5c --- /dev/null +++ b/dali/internal/graphics/vulkan/android/vk-surface-android.h @@ -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 + +// EXTERNAL INCLUDES +#include +#include + +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 diff --git a/dali/internal/graphics/vulkan/vulkan-device.cpp b/dali/internal/graphics/vulkan/vulkan-device.cpp index d4a91fd6e..a35d7a484 100644 --- a/dali/internal/graphics/vulkan/vulkan-device.cpp +++ b/dali/internal/graphics/vulkan/vulkan-device.cpp @@ -45,6 +45,10 @@ #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 #include @@ -873,6 +877,7 @@ std::vector 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 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 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 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 index 000000000..7a4431e3e --- /dev/null +++ b/dali/internal/imaging/android/native-image-source-factory-android-vulkan.cpp @@ -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 + +// INTERNAL HEADERS +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +std::unique_ptr NativeImageSourceFactoryAndroid::CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) +{ + return nullptr; +} + +std::unique_ptr NativeImageSourceFactoryAndroid::CreateNativeImageSourceQueue(uint32_t queueCount, uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorFormat colorFormat, Any nativeImageSourceQueue) +{ + return nullptr; +} + +std::unique_ptr GetNativeImageSourceFactory() +{ + return nullptr; +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/imaging/file.list b/dali/internal/imaging/file.list index 170a5ce72..820876411 100644 --- a/dali/internal/imaging/file.list +++ b/dali/internal/imaging/file.list @@ -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 diff --git a/dali/internal/window-system/android/window-base-android.cpp b/dali/internal/window-system/android/window-base-android.cpp index cb9aea66d..d24dc5b77 100644 --- a/dali/internal/window-system/android/window-base-android.cpp +++ b/dali/internal/window-system/android/window-base-android.cpp @@ -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 // INTERNAL HEADERS -#include #include #include @@ -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(mWindow);