return VK_SUCCESS;
}
-static VkPresentModeKHR present_modes[] = {
- VK_PRESENT_MODE_FIFO_KHR
-};
-
VKAPI_ATTR VkResult VKAPI_CALL
vk_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice pdev,
VkSurfaceKHR surface,
uint32_t *mode_count,
VkPresentModeKHR *modes)
{
- /* TODO: */
+ VkIcdSurfaceWayland *sfc = (VkIcdSurfaceWayland *)(uintptr_t)surface;
+ tpl_display_t *display;
+ tpl_result_t res;
+ int tpl_support_modes;
+ uint32_t support_mode_cnt = 0;
- if (modes) {
- *mode_count = MIN(*mode_count, ARRAY_LENGTH(present_modes));
- memcpy(modes, &present_modes[0], sizeof(VkPresentModeKHR) * (*mode_count));
+ VK_CHECK(sfc->base.platform == VK_ICD_WSI_PLATFORM_WAYLAND, return VK_ERROR_DEVICE_LOST,
+ "Not supported platform surface.\n");
- if (*mode_count < ARRAY_LENGTH(present_modes))
+ display = vk_get_tpl_display(sfc->display);
+ VK_CHECK(display, return VK_ERROR_DEVICE_LOST, "vk_get_tpl_display() failed.\n");
+
+ res = tpl_display_query_supported_present_modes_from_native_window(display, sfc->surface,
+ &tpl_support_modes);
+ tpl_object_unreference((tpl_object_t *)display);
+ VK_CHECK(res == TPL_ERROR_NONE, return VK_ERROR_DEVICE_LOST,
+ "tpl_display_query_native_window_supported_buffer_count() failed.\n");
+
+ if (tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_MAILBOX)
+ support_mode_cnt++;
+ if (tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_FIFO)
+ support_mode_cnt++;
+ if (tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_IMMEDIATE)
+ support_mode_cnt++;
+ if (tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED)
+ support_mode_cnt++;
+
+ if (modes) {
+ uint32_t i = 0;
+ *mode_count = MIN(*mode_count, support_mode_cnt);
+
+ if (i < *mode_count && tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_MAILBOX)
+ modes[i++] = VK_PRESENT_MODE_MAILBOX_KHR;
+ if (i < *mode_count && tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_FIFO)
+ modes[i++] = VK_PRESENT_MODE_FIFO_KHR;
+ if (i < *mode_count && tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_IMMEDIATE)
+ modes[i++] = VK_PRESENT_MODE_IMMEDIATE_KHR;
+ if (i < *mode_count && tpl_support_modes & TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED)
+ modes[i++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR;
+
+ if (*mode_count < support_mode_cnt)
return VK_INCOMPLETE;
} else {
- *mode_count = ARRAY_LENGTH(present_modes);
+ *mode_count = support_mode_cnt;
}
return VK_SUCCESS;
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)(uintptr_t)info->surface;
int buffer_count, i;
tbm_surface_h *buffers;
+ int tpl_present_mode;
+
VkResult error = VK_ERROR_DEVICE_LOST;
VK_ASSERT(surface->base.platform == VK_ICD_WSI_PLATFORM_WAYLAND);
TPL_SURFACE_TYPE_WINDOW, format);
VK_CHECK(chain->tpl_surface, goto error, "tpl_surface_create() failed.\n");
+ switch(info->presentMode) {
+ case VK_PRESENT_MODE_IMMEDIATE_KHR:
+ tpl_present_mode = TPL_DISPLAY_PRESENT_MODE_IMMEDIATE;
+ break;
+ case VK_PRESENT_MODE_MAILBOX_KHR:
+ tpl_present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX;
+ break;
+ case VK_PRESENT_MODE_FIFO_KHR:
+ tpl_present_mode = TPL_DISPLAY_PRESENT_MODE_FIFO;
+ break;
+ case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
+ tpl_present_mode = TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED;
+ break;
+ default:
+ VK_DEBUG("Unsupported present mode: 0x%x\n", info->presentMode);
+ goto error;
+ }
+
res = tpl_surface_create_swapchain(chain->tpl_surface, format,
info->imageExtent.width, info->imageExtent.height,
- info->minImageCount);
+ info->minImageCount, tpl_present_mode);
if (res == TPL_ERROR_OUT_OF_MEMORY) {
error = VK_ERROR_OUT_OF_DEVICE_MEMORY;
VK_ERROR("tpl_surface_create_swapchain() failed.\n");