Skip to content

Commit

Permalink
vulkan: explicitly disallow full screen exclusive mode
Browse files Browse the repository at this point in the history
This change is to workaround AMD driver on Windows, which even though
VK_EXT_full_screen_exclusive is not enabled still tries to enter
exclusive mode.

Fixes: mpv-player/mpv#8008
Signed-off-by: Kacper Michajłow <[email protected]>
Co-authored-by: Niklas Haas <[email protected]>
Co-authored-by: Hendrik Leppkes <[email protected]>
  • Loading branch information
3 people committed Oct 19, 2022
1 parent 806de09 commit 91516f1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/vulkan/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,7 @@ struct vk_ctx {
#ifdef VK_EXT_metal_objects
PL_VK_FUN(ExportMetalObjectsEXT);
#endif
#ifdef VK_EXT_full_screen_exclusive
PL_VK_FUN(AcquireFullScreenExclusiveModeEXT);
#endif
};
11 changes: 11 additions & 0 deletions src/vulkan/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static const char *vk_instance_extensions[] = {
VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME,
VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME,
VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
};

// List of mandatory instance-level function pointers, including functions
Expand Down Expand Up @@ -188,6 +189,13 @@ static const struct vk_ext vk_device_extensions[] = {
PL_VK_DEV_FUN(ExportMetalObjectsEXT),
{0}
},
#endif
#ifdef VK_EXT_full_screen_exclusive
}, {
.name = VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME,
.funs = (struct vk_fun[]) {
PL_VK_DEV_FUN(AcquireFullScreenExclusiveModeEXT),
},
#endif
},
};
Expand Down Expand Up @@ -215,6 +223,9 @@ const char * const pl_vulkan_recommended_extensions[] = {
#ifdef VK_EXT_metal_objects
VK_EXT_METAL_OBJECTS_EXTENSION_NAME,
#endif
#ifdef VK_EXT_full_screen_exclusive
VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME,
#endif
};

const int pl_vulkan_num_recommended_extensions =
Expand Down
10 changes: 10 additions & 0 deletions src/vulkan/swapchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@ static bool vk_sw_recreate(pl_swapchain sw, int w, int h)
if (!update_swapchain_info(p, &sinfo, w, h))
return false;

#ifdef VK_EXT_full_screen_exclusive
// Explicitly disallow full screen exclusive mode if possible
static const VkSurfaceFullScreenExclusiveInfoEXT fsinfo = {
.sType = VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
.fullScreenExclusive = VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT,
};
if (vk->AcquireFullScreenExclusiveModeEXT)
vk_link_struct(&sinfo, &fsinfo);
#endif

p->suboptimal = false;
p->needs_recreate = false;
p->cur_width = sinfo.imageExtent.width;
Expand Down

0 comments on commit 91516f1

Please sign in to comment.