summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuelian Bai <xuelian.bai@samsung.com>2022-11-28 09:55:42 +0800
committerXuelian Bai <xuelian.bai@samsung.com>2023-10-19 10:04:35 +0800
commit7b9a41f64490c333fb15d640e1690cbb81cf760f (patch)
tree52ece087560fa719f26bd1a9131e09e6b2ccb087
parentf6c1b8e6c832283b59787b37d4e9bea08bda5740 (diff)
downloadvulkan-wsi-layer-7b9a41f64490c333fb15d640e1690cbb81cf760f.tar.gz
vulkan-wsi-layer-7b9a41f64490c333fb15d640e1690cbb81cf760f.tar.bz2
vulkan-wsi-layer-7b9a41f64490c333fb15d640e1690cbb81cf760f.zip
Update to latest upstream version
Change-Id: Idaa93081d2f067085145cec4902bac45121a3ba1 Signed-Off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--layer/surface_api.cpp47
-rw-r--r--layer/surface_api.hpp11
-rwxr-xr-xutil/helper.cpp275
-rwxr-xr-xutil/helper.hpp12
-rwxr-xr-xutil/log.cpp28
-rw-r--r--util/log.hpp40
-rw-r--r--wsi/external_memory.cpp4
-rw-r--r--wsi/surface_properties.cpp2
-rw-r--r--wsi/swapchain_base.cpp3
-rw-r--r--wsi/synchronization.cpp2
-rw-r--r--wsi/tizen/surface_properties.cpp6
-rw-r--r--wsi/tizen/swapchain.cpp165
-rw-r--r--wsi/tizen/swapchain.hpp26
-rw-r--r--wsi/wsi_factory.cpp6
15 files changed, 443 insertions, 185 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3fa8b2d..9dfece8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,6 +220,7 @@ add_library(${PROJECT_NAME} SHARED
util/extension_list.cpp
util/log.cpp
util/format_modifiers.cpp
+ util/helper.cpp
wsi/external_memory.cpp
wsi/surface_properties.cpp
wsi/swapchain_base.cpp
diff --git a/layer/surface_api.cpp b/layer/surface_api.cpp
index dcb8edc..3d679bd 100644
--- a/layer/surface_api.cpp
+++ b/layer/surface_api.cpp
@@ -171,53 +171,8 @@ wsi_layer_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
surface, util::allocator{ instance_data.get_allocator(), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT, pAllocator });
}
-VWL_VKAPI_CALL(VkResult)
-wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,
- const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
- VkSurfaceCapabilities2KHR *pSurfaceCapabilities) VWL_API_POST
-{
- auto &instance = layer::instance_private_data::get(physicalDevice);
- if (instance.should_layer_handle_surface(physicalDevice, pSurfaceInfo->surface))
- {
- wsi::surface_properties *props = wsi::get_surface_properties(instance, pSurfaceInfo->surface);
- assert(props != nullptr);
- const void *pNext = pSurfaceCapabilities->pNext;
- while (pNext) {
- VkSurfaceProtectedCapabilitiesKHR *pProctedCap =
- const_cast<VkSurfaceProtectedCapabilitiesKHR *>(reinterpret_cast<const VkSurfaceProtectedCapabilitiesKHR *>(pNext));
- if (pProctedCap->sType == VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR) {
- pProctedCap->supportsProtected = VK_FALSE;
- break;
- }
- pNext = pProctedCap->pNext;
- }
- return props->get_surface_capabilities(physicalDevice, pSurfaceInfo->surface, &pSurfaceCapabilities->surfaceCapabilities);
- }
- /* If the layer cannot handle this surface, then necessarily the surface must have been created by the ICDs (or a
- * layer below us.) So it is safe to assume that the ICDs (or layers below us) support VK_KHR_surface and therefore
- * it is safe to can call down. This holds for other entrypoints below.
- */
- return instance.disp.GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, pSurfaceInfo, pSurfaceCapabilities);
-}
-VWL_VKAPI_CALL(VkResult)
-wsi_layer_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
- const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
- uint32_t *pSurfaceFormatCount,
- VkSurfaceFormat2KHR *pSurfaceFormats) VWL_API_POST
-{
- auto &instance = layer::instance_private_data::get(physicalDevice);
- if (instance.should_layer_handle_surface(physicalDevice, pSurfaceInfo->surface))
- {
- wsi::surface_properties *props = wsi::get_surface_properties(instance, pSurfaceInfo->surface);
- assert(props != nullptr);
- return props->get_surface_formats_2(physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount, pSurfaceFormats);
- }
-
- return instance.disp.GetPhysicalDeviceSurfaceFormats2KHR(physicalDevice, pSurfaceInfo, pSurfaceFormatCount,
- pSurfaceFormats);
-}
VWL_VKAPI_CALL(VkResult)
wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice,
@@ -232,7 +187,7 @@ wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDe
assert(props != nullptr);
VkSurfaceCapabilitiesKHR surfaceCaps;
- res = props->get_surface_capabilities(physicalDevice, surface, &surfaceCaps);
+ res = props->get_surface_capabilities(physicalDevice, &surfaceCaps);
if (res != VK_SUCCESS)
return res;
diff --git a/layer/surface_api.hpp b/layer/surface_api.hpp
index 944bc2a..7d79152 100644
--- a/layer/surface_api.hpp
+++ b/layer/surface_api.hpp
@@ -87,17 +87,6 @@ wsi_layer_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
const VkAllocationCallbacks *pAllocator) VWL_API_POST;
VWL_VKAPI_CALL(VkResult)
-wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,
- const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
- VkSurfaceCapabilities2KHR *pSurfaceCapabilities) VWL_API_POST;
-
-VWL_VKAPI_CALL(VkResult)
-wsi_layer_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
- const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
- uint32_t *pSurfaceFormatCount,
- VkSurfaceFormat2KHR *pSurfaceFormats) VWL_API_POST;
-
-VWL_VKAPI_CALL(VkResult)
wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
VkSurfaceCapabilities2EXT* pSurfaceCapabilities) VWL_API_POST;
diff --git a/util/helper.cpp b/util/helper.cpp
new file mode 100755
index 0000000..a383b52
--- /dev/null
+++ b/util/helper.cpp
@@ -0,0 +1,275 @@
+
+
+#include "helper.hpp"
+
+namespace util
+{
+
+#define ENUM_TO_STR(r) \
+ case r: return #r
+
+const char *
+vk_result_string(VkResult code)
+{
+ switch (code) {
+ ENUM_TO_STR(VK_SUCCESS);
+ ENUM_TO_STR(VK_NOT_READY);
+ ENUM_TO_STR(VK_TIMEOUT);
+ ENUM_TO_STR(VK_EVENT_SET);
+ ENUM_TO_STR(VK_EVENT_RESET);
+ ENUM_TO_STR(VK_INCOMPLETE);
+ ENUM_TO_STR(VK_ERROR_OUT_OF_HOST_MEMORY);
+ ENUM_TO_STR(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+ ENUM_TO_STR(VK_ERROR_INITIALIZATION_FAILED);
+ ENUM_TO_STR(VK_ERROR_DEVICE_LOST);
+ ENUM_TO_STR(VK_ERROR_MEMORY_MAP_FAILED);
+ ENUM_TO_STR(VK_ERROR_LAYER_NOT_PRESENT);
+ ENUM_TO_STR(VK_ERROR_EXTENSION_NOT_PRESENT);
+ ENUM_TO_STR(VK_ERROR_FEATURE_NOT_PRESENT);
+ ENUM_TO_STR(VK_ERROR_INCOMPATIBLE_DRIVER);
+ ENUM_TO_STR(VK_ERROR_TOO_MANY_OBJECTS);
+ ENUM_TO_STR(VK_ERROR_FORMAT_NOT_SUPPORTED);
+ ENUM_TO_STR(VK_ERROR_SURFACE_LOST_KHR);
+ ENUM_TO_STR(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR);
+ ENUM_TO_STR(VK_SUBOPTIMAL_KHR);
+ ENUM_TO_STR(VK_ERROR_OUT_OF_DATE_KHR);
+ ENUM_TO_STR(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR);
+ ENUM_TO_STR(VK_ERROR_VALIDATION_FAILED_EXT);
+ ENUM_TO_STR(VK_ERROR_INVALID_SHADER_NV);
+ ENUM_TO_STR(VK_ERROR_INVALID_EXTERNAL_HANDLE);
+ ENUM_TO_STR(VK_ERROR_NOT_PERMITTED_EXT);
+ default: return "UNKNOWN RESULT";
+ }
+}
+
+const char *
+vk_format_string(VkFormat code)
+{
+ switch (code) {
+ ENUM_TO_STR(VK_FORMAT_UNDEFINED);
+ ENUM_TO_STR(VK_FORMAT_R4G4_UNORM_PACK8);
+ ENUM_TO_STR(VK_FORMAT_R4G4B4A4_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_B4G4R4A4_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_R5G6B5_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_B5G6R5_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_R5G5B5A1_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_B5G5R5A1_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_A1R5G5B5_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_R8_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R8_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R8_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R8_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R8_UINT);
+ ENUM_TO_STR(VK_FORMAT_R8_SINT);
+ ENUM_TO_STR(VK_FORMAT_R8_SRGB);
+ ENUM_TO_STR(VK_FORMAT_R8G8_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R8G8_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R8G8_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R8G8_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R8G8_UINT);
+ ENUM_TO_STR(VK_FORMAT_R8G8_SINT);
+ ENUM_TO_STR(VK_FORMAT_R8G8_SRGB);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_UINT);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_SINT);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8_SRGB);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_UNORM);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_SNORM);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_USCALED);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_UINT);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_SINT);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8_SRGB);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_UINT);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_SINT);
+ ENUM_TO_STR(VK_FORMAT_R8G8B8A8_SRGB);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_UNORM);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_SNORM);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_USCALED);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_UINT);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_SINT);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8A8_SRGB);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_UNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_SNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_USCALED_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_SSCALED_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_UINT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_SINT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A8B8G8R8_SRGB_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2R10G10B10_UNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2R10G10B10_SNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2R10G10B10_USCALED_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2R10G10B10_SSCALED_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2R10G10B10_UINT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2R10G10B10_SINT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2B10G10R10_UNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2B10G10R10_SNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2B10G10R10_USCALED_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2B10G10R10_SSCALED_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2B10G10R10_UINT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_A2B10G10R10_SINT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_R16_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R16_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R16_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R16_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R16_UINT);
+ ENUM_TO_STR(VK_FORMAT_R16_SINT);
+ ENUM_TO_STR(VK_FORMAT_R16_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R16G16_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R16G16_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R16G16_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R16G16_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R16G16_UINT);
+ ENUM_TO_STR(VK_FORMAT_R16G16_SINT);
+ ENUM_TO_STR(VK_FORMAT_R16G16_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_UINT);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_SINT);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_SNORM);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_USCALED);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_SSCALED);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_UINT);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_SINT);
+ ENUM_TO_STR(VK_FORMAT_R16G16B16A16_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R32_UINT);
+ ENUM_TO_STR(VK_FORMAT_R32_SINT);
+ ENUM_TO_STR(VK_FORMAT_R32_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R32G32_UINT);
+ ENUM_TO_STR(VK_FORMAT_R32G32_SINT);
+ ENUM_TO_STR(VK_FORMAT_R32G32_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R32G32B32_UINT);
+ ENUM_TO_STR(VK_FORMAT_R32G32B32_SINT);
+ ENUM_TO_STR(VK_FORMAT_R32G32B32_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R32G32B32A32_UINT);
+ ENUM_TO_STR(VK_FORMAT_R32G32B32A32_SINT);
+ ENUM_TO_STR(VK_FORMAT_R32G32B32A32_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R64_UINT);
+ ENUM_TO_STR(VK_FORMAT_R64_SINT);
+ ENUM_TO_STR(VK_FORMAT_R64_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R64G64_UINT);
+ ENUM_TO_STR(VK_FORMAT_R64G64_SINT);
+ ENUM_TO_STR(VK_FORMAT_R64G64_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R64G64B64_UINT);
+ ENUM_TO_STR(VK_FORMAT_R64G64B64_SINT);
+ ENUM_TO_STR(VK_FORMAT_R64G64B64_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_R64G64B64A64_UINT);
+ ENUM_TO_STR(VK_FORMAT_R64G64B64A64_SINT);
+ ENUM_TO_STR(VK_FORMAT_R64G64B64A64_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_B10G11R11_UFLOAT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32);
+ ENUM_TO_STR(VK_FORMAT_D16_UNORM);
+ ENUM_TO_STR(VK_FORMAT_X8_D24_UNORM_PACK32);
+ ENUM_TO_STR(VK_FORMAT_D32_SFLOAT);
+ ENUM_TO_STR(VK_FORMAT_S8_UINT);
+ ENUM_TO_STR(VK_FORMAT_D16_UNORM_S8_UINT);
+ ENUM_TO_STR(VK_FORMAT_D24_UNORM_S8_UINT);
+ ENUM_TO_STR(VK_FORMAT_D32_SFLOAT_S8_UINT);
+ ENUM_TO_STR(VK_FORMAT_BC1_RGB_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC1_RGB_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC1_RGBA_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC1_RGBA_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC2_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC2_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC3_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC3_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC4_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC4_SNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC5_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC5_SNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC6H_UFLOAT_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC6H_SFLOAT_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC7_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_BC7_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_EAC_R11_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_EAC_R11_SNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_EAC_R11G11_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_EAC_R11G11_SNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_4x4_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_4x4_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_5x4_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_5x4_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_5x5_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_5x5_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_6x5_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_6x5_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_6x6_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_6x6_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_8x5_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_8x5_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_8x6_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_8x6_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_8x8_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_8x8_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x5_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x5_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x6_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x6_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x8_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x8_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x10_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_10x10_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_12x10_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_12x10_SRGB_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_12x12_UNORM_BLOCK);
+ ENUM_TO_STR(VK_FORMAT_ASTC_12x12_SRGB_BLOCK);
+#ifdef VK_VERSION_1_1
+ ENUM_TO_STR(VK_FORMAT_G8B8G8R8_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_B8G8R8G8_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G8_B8R8_2PLANE_420_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G8_B8R8_2PLANE_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM);
+ ENUM_TO_STR(VK_FORMAT_R10X6_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_R10X6G10X6_UNORM_2PACK16);
+ ENUM_TO_STR(VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16);
+ ENUM_TO_STR(VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16);
+ ENUM_TO_STR(VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16);
+ ENUM_TO_STR(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_R12X4_UNORM_PACK16);
+ ENUM_TO_STR(VK_FORMAT_R12X4G12X4_UNORM_2PACK16);
+ ENUM_TO_STR(VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16);
+ ENUM_TO_STR(VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16);
+ ENUM_TO_STR(VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16);
+ ENUM_TO_STR(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16);
+ ENUM_TO_STR(VK_FORMAT_G16B16G16R16_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_B16G16R16G16_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G16_B16R16_2PLANE_420_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G16_B16R16_2PLANE_422_UNORM);
+ ENUM_TO_STR(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM);
+#endif // VK_VERSION_1_1
+ default: return "UNKNOWN FORMAT";
+ }
+}
+
+
+} /* namespace util */
diff --git a/util/helper.hpp b/util/helper.hpp
new file mode 100755
index 0000000..31431cb
--- /dev/null
+++ b/util/helper.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+
+#include <vulkan/vulkan.h>
+
+
+namespace util
+{
+ const char *vk_result_string(VkResult code);
+ const char *vk_format_string(VkFormat code);
+
+} /* namespace util */
diff --git a/util/log.cpp b/util/log.cpp
index eac9e35..889ca28 100755
--- a/util/log.cpp
+++ b/util/log.cpp
@@ -35,6 +35,32 @@ namespace util
#ifndef NDEBUG
+#if BUILD_WSI_TIZEN
+void wsi_log_message(int level, const char *file, int line, const char *format, ...)
+{
+ log_priority dlog_prio;
+ switch (level) {
+ case 1:
+ dlog_prio = DLOG_ERROR;
+ break;
+ case 2:
+ dlog_prio = DLOG_WARN;
+ break;
+ case 3:
+ dlog_prio = DLOG_INFO;
+ break;
+ default:
+ dlog_prio = DLOG_DEBUG;
+ break;
+ }
+
+ std::va_list args;
+ va_start(args, format);
+ __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, format, args);
+ va_end(args);
+}
+
+#else
/**
* @brief check if a log level is enabled, and print it
*/
@@ -90,7 +116,7 @@ void wsi_log_message(long level, const char *file, int line, const char *format,
std::putc('\n', stderr);
}
}
-
+#endif
#endif
} /* namespace util */
diff --git a/util/log.hpp b/util/log.hpp
index 13a2b03..3b6da72 100644
--- a/util/log.hpp
+++ b/util/log.hpp
@@ -34,9 +34,43 @@
namespace util
{
+#define WSI_DEFAULT_LOG_LEVEL 1
-#define WSI_LOG_ERROR(fmt, x...) LOGE(fmt, ##x)
-#define WSI_LOG_WARNING(fmt, x...) LOGW(fmt, ##x)
-#define WSI_LOG_INFO(fmt, x...) LOGI(fmt, ##x)
+/**
+ * @brief Log a message to a certain log level
+ *
+ * @details For the log level, we use a bigger integer to represent an increased
+ * level of verbosity. If this is not specified, the log level is default to 1.
+ * We use a "staircase" approach with respect to printing logs. We print all log
+ * messages equal or below the log level set, e.g. if VULKAN_WSI_DEBUG_LEVEL
+ * is set to 2, messages with log level 1 and 2 are printed. Please note that
+ * the newline character '\n' is automatically appended.
+ *
+ * @param[in] level The log level of this message, you can set an arbitary
+ * integer however please refer to the included macros for
+ * the sensible defaults.
+ * @param[in] file The source file name (``__FILE__``)
+ * @param[in] line The source file line number (``__LINE__``)
+ * @param[in] format A C-style formatting string.
+ */
+
+void wsi_log_message(int level, const char *file, int line, const char *format, ...)
+#ifdef __GNUC__
+ __attribute__((format(printf, 4, 5)))
+#endif
+ ;
+
+#ifdef NDEBUG
+static constexpr bool wsi_log_enable = false;
+#else
+static constexpr bool wsi_log_enable = true;
+#endif
+
+#define WSI_LOG(level, ...) \
+ do { if (::util::wsi_log_enable) ::util::wsi_log_message(level, __FILE__, __LINE__, __VA_ARGS__); } while (0)
+
+#define WSI_LOG_ERROR(...) WSI_LOG(1, __VA_ARGS__)
+#define WSI_LOG_WARNING(...) WSI_LOG(2, __VA_ARGS__)
+#define WSI_LOG_INFO(...) WSI_LOG(3, __VA_ARGS__)
} /* namespace util */
diff --git a/wsi/external_memory.cpp b/wsi/external_memory.cpp
index ad1a606..1fedfb8 100644
--- a/wsi/external_memory.cpp
+++ b/wsi/external_memory.cpp
@@ -54,7 +54,7 @@ external_memory::~external_memory()
else if (m_buffer_fds[plane] >= 0)
{
auto it = std::find(std::begin(m_buffer_fds), std::end(m_buffer_fds), m_buffer_fds[plane]);
- if (std::distance(std::begin(m_buffer_fds), it) == plane)
+ if (std::distance(std::begin(m_buffer_fds), it) == (int)plane)
{
close(m_buffer_fds[plane]);
}
@@ -123,7 +123,7 @@ VkResult external_memory::import_plane_memories()
for (uint32_t plane = 0; plane < get_num_planes(); plane++)
{
auto it = std::find(std::begin(m_buffer_fds), std::end(m_buffer_fds), m_buffer_fds[plane]);
- if (std::distance(std::begin(m_buffer_fds), it) == plane)
+ if (std::distance(std::begin(m_buffer_fds), it) == (int)plane)
{
TRY_LOG_CALL(import_plane_memory(plane));
}
diff --git a/wsi/surface_properties.cpp b/wsi/surface_properties.cpp
index 77cace5..20ea557 100644
--- a/wsi/surface_properties.cpp
+++ b/wsi/surface_properties.cpp
@@ -31,7 +31,7 @@ namespace wsi
VkResult surface_format_properties::check_device_support(VkPhysicalDevice phys_dev,
VkPhysicalDeviceImageFormatInfo2KHR image_format_info)
{
- VkImageFormatProperties2KHR image_format_props{ VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR, nullptr };
+ VkImageFormatProperties2KHR image_format_props{ VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR, nullptr, {} };
auto &instance_data = layer::instance_private_data::get(phys_dev);
diff --git a/wsi/swapchain_base.cpp b/wsi/swapchain_base.cpp
index c531bde..a6cff37 100644
--- a/wsi/swapchain_base.cpp
+++ b/wsi/swapchain_base.cpp
@@ -405,6 +405,7 @@ VkResult swapchain_base::acquire_next_image(uint64_t timeout, VkSemaphore semaph
image_status_lock.unlock();
+#if 0
/* Try to signal fences/semaphores with a sync FD for optimal performance. */
if (m_device_data.disp.ImportFenceFdKHR != nullptr && m_device_data.disp.ImportSemaphoreFdKHR != nullptr)
{
@@ -458,7 +459,7 @@ VkResult swapchain_base::acquire_next_image(uint64_t timeout, VkSemaphore semaph
}
}
}
-
+#endif
/* Fallback for when importing fence/semaphore sync FDs is unsupported by the ICD. */
VkResult retval = VK_SUCCESS;
if (VK_NULL_HANDLE != semaphore || VK_NULL_HANDLE != fence)
diff --git a/wsi/synchronization.cpp b/wsi/synchronization.cpp
index 99692bc..0160faf 100644
--- a/wsi/synchronization.cpp
+++ b/wsi/synchronization.cpp
@@ -30,6 +30,7 @@
#include "synchronization.hpp"
#include "layer/private_data.hpp"
+#include "util/log.hpp"
#include <algorithm>
@@ -170,6 +171,7 @@ std::optional<sync_fd_fence_sync> sync_fd_fence_sync::create(layer::device_priva
device.disp.CreateFence(device.device, &fence_info, device.get_allocator().get_original_callbacks(), &fence);
if (res != VK_SUCCESS)
{
+ WSI_LOG_ERROR("create fence failed[%d]", res);
return std::nullopt;
}
return sync_fd_fence_sync{ device, fence };
diff --git a/wsi/tizen/surface_properties.cpp b/wsi/tizen/surface_properties.cpp
index 0f3b4af..30af26c 100644
--- a/wsi/tizen/surface_properties.cpp
+++ b/wsi/tizen/surface_properties.cpp
@@ -76,8 +76,10 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_
tpl_display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(specific_surface->get_wl_display()));
}
- if (!tpl_display)
+ if (!tpl_display) {
+ WSI_LOG_ERROR("Create new tpl_display failed");
return VK_ERROR_SURFACE_LOST_KHR;
+ }
int cnt_min = 0, cnt_max = 0;
res = tpl_display_query_supported_buffer_count_from_native_window(tpl_display, specific_surface->get_wl_display(), &cnt_min, &cnt_max);
@@ -85,6 +87,7 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_
return VK_ERROR_SURFACE_LOST_KHR;
}
+
tpl_object_unreference(reinterpret_cast<tpl_object_t *>(tpl_display));
/* Image count limits */
@@ -208,6 +211,7 @@ VkResult surface_properties::get_surface_present_modes(VkPhysicalDevice physical
return VK_ERROR_SURFACE_LOST_KHR;
}
+
tpl_object_unreference(reinterpret_cast<tpl_object_t *>(tpl_display));
std::vector<VkPresentModeKHR> modes = {};
diff --git a/wsi/tizen/swapchain.cpp b/wsi/tizen/swapchain.cpp
index 9ddddc6..87a2278 100644
--- a/wsi/tizen/swapchain.cpp
+++ b/wsi/tizen/swapchain.cpp
@@ -33,9 +33,12 @@
#include <cstdio>
#include <climits>
#include <drm_fourcc.h>
+#include <tbm_bufmgr.h>
+
#include "util/log.hpp"
#include "util/macros.hpp"
+#include "util/helper.hpp"
#define MAX_PLANES 4
@@ -62,7 +65,6 @@ struct swapchain::tizen_image_data
uint32_t num_planes;
- sync_fd_fence_sync present_fence;
bool is_disjoint;
};
@@ -74,9 +76,8 @@ swapchain::swapchain(layer::device_private_data &dev_data, const VkAllocationCal
, m_wsi_surface(&wsi_surface)
, m_tpl_display(nullptr)
, m_tpl_surface(nullptr)
- , m_image_creation_parameters({}, m_allocator, {}, {})
+ , m_image_creation_parameters(m_allocator, {}, {})
{
- m_image_creation_parameters.m_image_create_info.format = VK_FORMAT_UNDEFINED;
}
swapchain::~swapchain()
@@ -102,10 +103,8 @@ swapchain::~swapchain()
return TBM_FORMAT_##pre; \
else if (comp == VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR) \
return TBM_FORMAT_##post; \
- else if (comp == VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR) \
- return TBM_FORMAT_##inherit; \
else \
- return 0; \
+ return TBM_FORMAT_##inherit; \
} while (0)
@@ -176,6 +175,7 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
if (!m_tpl_display)
return VK_ERROR_SURFACE_LOST_KHR;
+
m_tpl_surface = tpl_surface_get(m_tpl_display, m_wl_surface);
WSI_LOG_INFO("Get tpl_surface[%p] from tpl_display[%p] for wl_surface[%p]", m_tpl_surface, m_tpl_display, m_wl_surface);
if (m_tpl_surface == NULL) {
@@ -213,6 +213,7 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
res = tpl_surface_create_swapchain(m_tpl_surface, format,
swapchain_create_info->imageExtent.width, swapchain_create_info->imageExtent.height,
swapchain_create_info->minImageCount, tpl_present_mode);
+
if (res != TPL_ERROR_NONE) {
WSI_LOG_ERROR("create swapchain failed, ret[%d].\n", res);
if (res == TPL_ERROR_OUT_OF_MEMORY) {
@@ -257,6 +258,7 @@ VkResult swapchain::allocate_plane_memory(int fd, VkDeviceMemory *memory)
{
uint32_t mem_index = -1;
VkResult result = get_fd_mem_type_index(fd, mem_index);
+
if (result != VK_SUCCESS)
{
return result;
@@ -285,7 +287,7 @@ VkResult swapchain::allocate_plane_memory(int fd, VkDeviceMemory *memory)
if (result != VK_SUCCESS)
{
- WSI_LOG_ERROR("Failed to import memory.");
+ WSI_LOG_ERROR("Failed to import memory:result[%s]", util::vk_result_string(result));
return result;
}
@@ -301,10 +303,9 @@ VkResult swapchain::get_fd_mem_type_index(int fd, uint32_t &mem_idx)
m_device, VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, fd, &mem_props);
if (result != VK_SUCCESS)
{
- WSI_LOG_ERROR("Error querying Fd properties.");
+ WSI_LOG_ERROR("Error querying Fd properties:result[%s]", util::vk_result_string(result));
return result;
}
-
for (mem_idx = 0; mem_idx < VK_MAX_MEMORY_TYPES; mem_idx++)
{
if (mem_props.memoryTypeBits & (1 << mem_idx))
@@ -354,12 +355,6 @@ static uint32_t get_same_fd_index(int fd, int const *fds)
return index;
}
-VkResult swapchain::create_aliased_image_handle(const VkImageCreateInfo *image_create_info, VkImage *image)
-{
- return m_device_data.disp.CreateImage(m_device, &m_image_creation_parameters.m_image_create_info,
- get_allocation_callbacks(), image);
-}
-
static bool get_free_tbm_surface(tbm_surface_h &buffer, std::unordered_map<tbm_surface_h, bool> &buffer_map)
{
buffer = nullptr;
@@ -374,7 +369,7 @@ static bool get_free_tbm_surface(tbm_surface_h &buffer, std::unordered_map<tbm_s
return buffer == nullptr ? false : true;
}
-VkResult swapchain::allocate_image(VkImageCreateInfo &image_create_info, tizen_image_data *image_data, VkImage *image)
+VkResult swapchain::allocate_image(tizen_image_data *image_data, VkImage *image)
{
image_data->buffer = nullptr;
image_data->num_planes = 0;
@@ -385,86 +380,65 @@ VkResult swapchain::allocate_image(VkImageCreateInfo &image_create_info, tizen_i
}
bool is_disjoint = false;
- auto &m_image_create_info = m_image_creation_parameters.m_image_create_info;
- if (m_image_create_info.format != VK_FORMAT_UNDEFINED)
- {
- is_disjoint = (m_image_create_info.flags & VK_IMAGE_CREATE_DISJOINT_BIT) == VK_IMAGE_CREATE_DISJOINT_BIT;
- if (!get_free_tbm_surface(image_data->buffer, m_tbm_buffers)) {
- return VK_ERROR_OUT_OF_DEVICE_MEMORY;
- }
-
- tbm_surface_info_s info;
- tbm_surface_get_info(image_data->buffer, &info);
- image_data->num_planes = info.num_planes;
-
- for (uint32_t plane = 0; plane < info.num_planes; plane++) {
- tbm_bo bo = tbm_surface_internal_get_bo(image_data->buffer, plane);
- image_data->buffer_fd[plane] = tbm_bo_export_fd(bo);
- image_data->stride[plane] = info.planes[plane].stride;
- image_data->offset[plane] = info.planes[plane].offset;
- }
- } else {
- if (!get_free_tbm_surface(image_data->buffer, m_tbm_buffers)) {
- return VK_ERROR_OUT_OF_DEVICE_MEMORY;
- }
- tbm_surface_info_s info;
- tbm_surface_get_info(image_data->buffer, &info);
- image_data->num_planes = info.num_planes;
-
- for (uint32_t plane = 0; plane < info.num_planes; plane++) {
- tbm_bo bo = tbm_surface_internal_get_bo(image_data->buffer, plane);
- image_data->buffer_fd[plane] = tbm_bo_export_fd(bo);
- image_data->stride[plane] = info.planes[plane].stride;
- image_data->offset[plane] = info.planes[plane].offset;
- if (image_data->buffer_fd[plane] != image_data->buffer_fd[0]) {
- is_disjoint = true;
- }
- }
-
- auto &image_layout = m_image_creation_parameters.m_image_layout;
- if (!image_layout.try_resize(image_data->num_planes))
- {
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
+ if (!get_free_tbm_surface(image_data->buffer, m_tbm_buffers)) {
+ return VK_ERROR_OUT_OF_DEVICE_MEMORY;
+ }
- for (uint32_t plane = 0; plane < image_data->num_planes; plane++)
- {
- assert(image_data->stride[plane] >= 0);
- image_layout[plane].offset = image_data->offset[plane];
- image_layout[plane].rowPitch = static_cast<uint32_t>(image_data->stride[plane]);
- }
+ tbm_surface_info_s info;
+ tbm_surface_get_info(image_data->buffer, &info);
+ image_data->num_planes = info.num_planes;
- if (is_disjoint)
- {
- image_create_info.flags |= VK_IMAGE_CREATE_DISJOINT_BIT;
+ for (uint32_t plane = 0; plane < info.num_planes; plane++) {
+ tbm_bo bo = tbm_surface_internal_get_bo(image_data->buffer, plane);
+ image_data->buffer_fd[plane] = tbm_bo_export_fd(bo);
+ image_data->stride[plane] = info.planes[plane].stride;
+ image_data->offset[plane] = info.planes[plane].offset;
+ if (image_data->buffer_fd[plane] != image_data->buffer_fd[0]) {
+ is_disjoint = true;
}
+ }
- auto &drm_mod_info = m_image_creation_parameters.m_drm_mod_info;
- drm_mod_info.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT;
- drm_mod_info.pNext = image_create_info.pNext;
- drm_mod_info.drmFormatModifier = DRM_FORMAT_MOD_LINEAR;
- drm_mod_info.drmFormatModifierPlaneCount = image_data->num_planes;
- drm_mod_info.pPlaneLayouts = image_layout.data();
+ auto &image_layout = m_image_creation_parameters.m_image_layout;
+ if (!image_layout.try_resize(image_data->num_planes))
+ {
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
- auto &external_info = m_image_creation_parameters.m_external_info;
- external_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR;
- external_info.pNext = &drm_mod_info;
- external_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
+ for (uint32_t plane = 0; plane < image_data->num_planes; plane++)
+ {
+ assert(image_data->stride[plane] >= 0);
+ image_layout[plane].offset = image_data->offset[plane];
+ image_layout[plane].rowPitch = static_cast<uint32_t>(image_data->stride[plane]);
+ }
- m_image_create_info = image_create_info;
- m_image_create_info.pNext = &external_info;
- m_image_create_info.tiling = VK_IMAGE_TILING_LINEAR;
+ if (is_disjoint)
+ {
+ m_image_create_info.flags |= VK_IMAGE_CREATE_DISJOINT_BIT;
+ }
+#if 0 /* Not all platform support this */
+ auto &drm_mod_info = m_image_creation_parameters.m_drm_mod_info;
+ drm_mod_info.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT;
+ drm_mod_info.pNext = image_create_info.pNext;
+ drm_mod_info.drmFormatModifier = DRM_FORMAT_MOD_LINEAR;
+ drm_mod_info.drmFormatModifierPlaneCount = image_data->num_planes;
+ drm_mod_info.pPlaneLayouts = image_layout.data();
+#endif
+ auto &external_info = m_image_creation_parameters.m_external_info;
+ external_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR;
+ external_info.pNext = nullptr;
+ external_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
+
+ m_image_create_info.pNext = &external_info;
+ m_image_create_info.tiling = VK_IMAGE_TILING_LINEAR;
- }
image_data->is_disjoint = is_disjoint;
VkResult result = m_device_data.disp.CreateImage(m_device, &m_image_create_info, get_allocation_callbacks(), image);
if (result != VK_SUCCESS)
{
- WSI_LOG_ERROR("Image creation failed.");
+ WSI_LOG_ERROR("Image creation failed:result[%s]", util::vk_result_string(result));
return result;
}
- WSI_LOG_INFO("Create image[%p]", (void *)*image);
if (is_disjoint)
{
@@ -476,6 +450,7 @@ VkResult swapchain::allocate_image(VkImageCreateInfo &image_create_info, tizen_i
result = allocate_plane_memory(image_data->buffer_fd[plane], &image_data->memory[fd_index]);
if (result != VK_SUCCESS)
{
+ WSI_LOG_ERROR("allocate memory failed:result[%s]", util::vk_result_string(result));
return result;
}
}
@@ -486,6 +461,7 @@ VkResult swapchain::allocate_image(VkImageCreateInfo &image_create_info, tizen_i
result = allocate_plane_memory(image_data->buffer_fd[0], &image_data->memory[0]);
if (result != VK_SUCCESS)
{
+ WSI_LOG_ERROR("allocate memory failed:result[%s]", util::vk_result_string(result));
return result;
}
}
@@ -502,11 +478,12 @@ VkResult swapchain::create_and_bind_swapchain_image(VkImageCreateInfo image_crea
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
+ m_image_create_info = image_create_info;
std::unique_lock<std::recursive_mutex> image_status_lock(m_image_status_mutex);
image.data = image_data;
image.status = swapchain_image::INVALID;
- VkResult result = allocate_image(image_create_info, image_data, &image.image);
+ VkResult result = allocate_image(image_data, &image.image);
image_status_lock.unlock();
@@ -516,20 +493,11 @@ VkResult swapchain::create_and_bind_swapchain_image(VkImageCreateInfo image_crea
destroy_image(image);
return result;
}
-
- /* Initialize presentation fence. */
- auto present_fence = sync_fd_fence_sync::create(m_device_data);
- if (!present_fence.has_value())
- {
- destroy_image(image);
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
- image_data->present_fence = std::move(present_fence.value());
+ WSI_LOG_INFO("allocate_image succeed.");
for (uint32_t i = 0; i < m_swapchain_images.size(); i++) {
if (m_swapchain_images[i].data == image_data) {
m_tbm_buffer_idx.insert(std::make_pair(image_data->buffer, i));
- WSI_LOG_INFO("tbm surface[%p] - idx[%d]", image_data->buffer, i);
}
}
@@ -540,6 +508,7 @@ void swapchain::present_image(uint32_t pendingIndex)
{
tizen_image_data *image_data = reinterpret_cast<tizen_image_data *>(m_swapchain_images[pendingIndex].data);
const VkPresentRegionKHR *region = get_present_regions();
+ tpl_result_t ret = TPL_ERROR_NONE;
int *rects = NULL;
int rect_count = 0;
@@ -556,7 +525,11 @@ void swapchain::present_image(uint32_t pendingIndex)
}
}
- tpl_surface_enqueue_buffer_with_damage_and_sync(m_tpl_surface, image_data->buffer, rect_count, rects, -1);
+ ret = tpl_surface_enqueue_buffer_with_damage_and_sync(m_tpl_surface, image_data->buffer, rect_count, rects, -1);
+ if (ret != TPL_ERROR_NONE)
+ {
+ WSI_LOG_ERROR("TPL enqueue failed: ret[%d]", ret);
+ }
if (rects)
delete rects;
@@ -612,11 +585,11 @@ VkResult swapchain::get_free_buffer(uint64_t *timeout)
/* Returning VK_ERROR_OUT_OF_DATE_KHR calls swapchain_tpl_deinit
* to destroy the existing swapchain, but does not want the existing
* tpl_surface and tpl_display to be destroyed. */
- tpl_object_reference(reinterpret_cast<tpl_object_t *>(m_tpl_display));
+ //tpl_object_reference(reinterpret_cast<tpl_object_t *>(m_tpl_display));
tpl_object_reference(reinterpret_cast<tpl_object_t *>(m_tpl_surface));
+ WSI_LOG_ERROR("+++[%s] tpl_display[%p] refcount[%d]", __func__, m_tpl_display, tpl_object_get_reference(reinterpret_cast<tpl_object_t *>(m_tpl_display)));
return VK_ERROR_OUT_OF_DATE_KHR;
}
-
WSI_LOG_ERROR("Dequeue buffer failed, swapchain [%p], tpl_surface [%p]", this, m_tpl_surface);
return VK_ERROR_SURFACE_LOST_KHR;
}
diff --git a/wsi/tizen/swapchain.hpp b/wsi/tizen/swapchain.hpp
index a9f2836..07bc46d 100644
--- a/wsi/tizen/swapchain.hpp
+++ b/wsi/tizen/swapchain.hpp
@@ -46,18 +46,15 @@ namespace tizen
struct image_creation_parameters
{
- VkImageCreateInfo m_image_create_info;
util::vector<VkSubresourceLayout> m_image_layout;
VkExternalMemoryImageCreateInfoKHR m_external_info;
- VkImageDrmFormatModifierExplicitCreateInfoEXT m_drm_mod_info;
+ //VkImageDrmFormatModifierExplicitCreateInfoEXT m_drm_mod_info;
- image_creation_parameters(VkImageCreateInfo image_create_info, util::allocator allocator,
- VkExternalMemoryImageCreateInfoKHR external_info,
- VkImageDrmFormatModifierExplicitCreateInfoEXT drm_mod_info)
- : m_image_create_info(image_create_info)
- , m_image_layout(allocator)
+ image_creation_parameters(util::allocator allocator, VkExternalMemoryImageCreateInfoKHR external_info,
+ VkImageDrmFormatModifierExplicitCreateInfoEXT drm_mod_info)
+ : m_image_layout(allocator)
, m_external_info(external_info)
- , m_drm_mod_info(drm_mod_info)
+// , m_drm_mod_info(drm_mod_info)
{
}
};
@@ -70,17 +67,6 @@ public:
~swapchain();
- /**
- * @brief Creates a VkImage handle.
- *
- * @param image_create_info Data to be used to create the image.
- * @param[out] image Handle to the image.
- *
- * @return If image creation is successful returns VK_SUCCESS, otherwise
- * will return VK_ERROR_OUT_OF_DEVICE_MEMORY or VK_ERROR_OUT_OF_HOST_MEMORY
- * depending on the error that occured.
- */
- VkResult create_aliased_image_handle(const VkImageCreateInfo *image_create_info, VkImage *image) override;
/**
* @brief Bind image to a swapchain
@@ -175,7 +161,7 @@ protected:
private:
struct tizen_image_data;
- VkResult allocate_image(VkImageCreateInfo &image_create_info, tizen_image_data *image_data, VkImage *image);
+ VkResult allocate_image(tizen_image_data *image_data, VkImage *image);
VkResult internal_bind_swapchain_image(VkDevice &device, tizen_image_data *swapchain_image,
const VkImage &image);
diff --git a/wsi/wsi_factory.cpp b/wsi/wsi_factory.cpp
index b06a036..7631430 100644
--- a/wsi/wsi_factory.cpp
+++ b/wsi/wsi_factory.cpp
@@ -141,7 +141,6 @@ static VkResult get_available_device_extensions(VkPhysicalDevice physical_device
uint32_t count = 0;
TRY_LOG(instance_data.disp.EnumerateDeviceExtensionProperties(physical_device, nullptr, &count, nullptr),
"Failed to enumurate properties of available physical device extensions");
-
if (!properties.try_resize(count))
{
return VK_ERROR_OUT_OF_HOST_MEMORY;
@@ -192,6 +191,7 @@ VkResult add_extensions_required_by_layer(VkPhysicalDevice phys_dev, const util:
util::extension_list extensions_required_by_layer{ allocator };
surface_properties *props = get_surface_properties(wsi_ext.platform);
+
if (props == nullptr)
{
return VK_ERROR_INITIALIZATION_FAILED;
@@ -199,7 +199,7 @@ VkResult add_extensions_required_by_layer(VkPhysicalDevice phys_dev, const util:
TRY_LOG(props->get_required_device_extensions(extensions_required_by_layer),
"Failed to acquire required device extensions");
-
+#if 0 /* Added by xuelian.bai: we can't treat it as error for now */
bool supported = available_device_extensions.contains(extensions_required_by_layer);
if (!supported)
{
@@ -210,7 +210,7 @@ VkResult add_extensions_required_by_layer(VkPhysicalDevice phys_dev, const util:
*/
return VK_ERROR_INITIALIZATION_FAILED;
}
-
+#endif
TRY_LOG_CALL(extensions_to_enable.add(extensions_required_by_layer));
}