mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
Support multiple displays in VK_KHR_display.
This commit is contained in:
parent
a3ae537c02
commit
c4ba8d26a0
@ -1892,6 +1892,10 @@ static bool vulkan_create_display_surface(gfx_ctx_vulkan_data_t *vk,
|
||||
VkDisplayPlaneAlphaFlagBitsKHR alpha_mode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR;
|
||||
VkDisplaySurfaceCreateInfoKHR create_info = { VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR };
|
||||
VkDisplayModeKHR best_mode = VK_NULL_HANDLE;
|
||||
/* Monitor index starts on 1, 0 is auto. */
|
||||
unsigned monitor_index = info->monitor_index;
|
||||
unsigned saved_width = *width;
|
||||
unsigned saved_height = *height;
|
||||
|
||||
/* We need to decide on GPU here to be able to query support. */
|
||||
if (!vulkan_context_init_gpu(vk))
|
||||
@ -1933,8 +1937,18 @@ static bool vulkan_create_display_surface(gfx_ctx_vulkan_data_t *vk,
|
||||
if (vkGetPhysicalDeviceDisplayPlanePropertiesKHR(vk->context.gpu, &plane_count, planes) != VK_SUCCESS)
|
||||
GOTO_FAIL();
|
||||
|
||||
if (monitor_index > display_count)
|
||||
{
|
||||
RARCH_WARN("Monitor index is out of range, using automatic display.\n");
|
||||
monitor_index = 0;
|
||||
}
|
||||
|
||||
retry:
|
||||
for (dpy = 0; dpy < display_count; dpy++)
|
||||
{
|
||||
if (monitor_index != 0 && (monitor_index - 1) != dpy)
|
||||
continue;
|
||||
|
||||
VkDisplayKHR display = displays[dpy].display;
|
||||
best_mode = VK_NULL_HANDLE;
|
||||
best_plane = UINT32_MAX;
|
||||
@ -2016,6 +2030,18 @@ static bool vulkan_create_display_surface(gfx_ctx_vulkan_data_t *vk,
|
||||
}
|
||||
out:
|
||||
|
||||
if (best_plane == UINT32_MAX && monitor_index != 0)
|
||||
{
|
||||
RARCH_WARN("Could not find suitable surface for monitor index: %u.\n",
|
||||
monitor_index);
|
||||
RARCH_WARN("Retrying first suitable monitor.\n");
|
||||
monitor_index = 0;
|
||||
best_mode = VK_NULL_HANDLE;
|
||||
*width = saved_width;
|
||||
*height = saved_height;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if (best_mode == VK_NULL_HANDLE)
|
||||
GOTO_FAIL();
|
||||
if (best_plane == UINT32_MAX)
|
||||
|
@ -139,6 +139,7 @@ struct vulkan_display_surface_info
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned monitor_index;
|
||||
};
|
||||
|
||||
struct vk_color
|
||||
|
@ -126,8 +126,9 @@ static bool gfx_ctx_khr_display_set_video_mode(void *data,
|
||||
height = 0;
|
||||
}
|
||||
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.width = width;
|
||||
info.height = height;
|
||||
info.monitor_index = video_info->monitor_index;
|
||||
|
||||
if (!vulkan_surface_create(&khr->vk, VULKAN_WSI_DISPLAY, &info, NULL,
|
||||
0, 0, khr->swap_interval))
|
||||
|
Loading…
x
Reference in New Issue
Block a user