[HOTFIX] Avoid duplication of surface_formats in querying 62/148862/2
authorxuelian.bai <xuelian.bai@samsung.com>
Mon, 11 Sep 2017 13:03:25 +0000 (21:03 +0800)
committerHoyub Lee <hoyub.lee@samsung.com>
Thu, 14 Sep 2017 00:04:20 +0000 (09:04 +0900)
Currently, tbm formats and vulkan formats are not mapped perfectly.
By this, in querying supported formats with tpl_get_surface_formats(),
duplication occurs in supported formats.

Therefore, apply hotfix to avoid duplicated results.

Change-Id: I28474c462276d1549142ae2300695b1680e59832
Signed-off-by: Xuelian Bai <xuelian.bai@samsung.com>
Signed-off-by: Hoyub Lee <hoyub.lee@samsung.com>
src/wsi/surface.c

index 2bfcfad..e8d35ae 100644 (file)
@@ -204,15 +204,21 @@ tpl_get_surface_formats(VkIcdSurfaceBase  *sfc,
        uint32_t                         surface_format_count = 0;
        VkSurfaceFormatKHR       surface_formats[ARRAY_LENGTH(supported_formats)];
        uint32_t                         i, j;
+       uint8_t                          vk_format_map[VK_FORMAT_RANGE_SIZE];
+       VkFormat                         vk_format;
 
        if (tbm_surface_query_formats(&tbm_formats, &tbm_format_count) != TBM_SURFACE_ERROR_NONE)
                return VK_ERROR_DEVICE_LOST;
 
+       memset(vk_format_map, 0, sizeof(vk_format_map));
        for (i = 0; i < ARRAY_LENGTH(supported_formats); i++) {
+               vk_format = supported_formats[i].surface_format.format;
                for (j = 0; j < tbm_format_count; j++) {
-                       if (tbm_formats[j] == supported_formats[i].tbm_format) {
+                       /* FIXME Currently, hotfix is applied to avoid duplication of supported VkFormat */
+                       if (tbm_formats[j] == supported_formats[i].tbm_format && vk_format_map[vk_format] == 0) {
                                /* TODO Check if ICD support the format. */
                                surface_formats[surface_format_count++] = supported_formats[i].surface_format;
+                               vk_format_map[vk_format] = 1;
                                break;
                        }
                }