Skip to content

Commit 03d0f1a

Browse files
authored
Move VK_EXT_full_screen_exclusive to optional extensions + extension debug logs & FSE guard (#18673)
1 parent d75d53c commit 03d0f1a

2 files changed

Lines changed: 63 additions & 24 deletions

File tree

gfx/common/vulkan_common.c

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ static bool vulkan_find_instance_extensions(
396396
memcpy((void*)(enabled + count), exts, num_exts * sizeof(*exts));
397397
count += num_exts;
398398

399+
400+
for (i = 0; i < num_exts; i++)
401+
{
402+
if (vulkan_find_extensions(&exts[i], 1, properties, property_count))
403+
RARCH_DBG("[Vulkan] Instance extension supported: %s.\n", exts[i]);
404+
else
405+
RARCH_DBG("[Vulkan] Instance extension NOT supported: %s.\n", exts[i]);
406+
}
407+
399408
for (i = 0; i < num_optional_exts; i++)
400409
if (vulkan_find_extensions(&optional_exts[i], 1, properties, property_count))
401410
enabled[count++] = optional_exts[i];
@@ -443,9 +452,31 @@ static bool vulkan_find_device_extensions(VkPhysicalDevice gpu,
443452
memcpy((void*)(enabled + count), exts, num_exts * sizeof(*exts));
444453
count += num_exts;
445454

455+
for (i = 0; i < num_exts; i++)
456+
{
457+
if (vulkan_find_extensions(&exts[i], 1, properties, property_count))
458+
{
459+
RARCH_DBG("[Vulkan] Device extension supported: %s.\n", exts[i]);
460+
enabled[count++] = exts[i];
461+
}
462+
else
463+
{
464+
RARCH_DBG("[Vulkan] Device extension NOT supported: %s.\n", exts[i]);
465+
}
466+
}
467+
446468
for (i = 0; i < num_optional_exts; i++)
469+
{
447470
if (vulkan_find_extensions(&optional_exts[i], 1, properties, property_count))
471+
{
472+
RARCH_DBG("[Vulkan] Optional device extension supported: %s.\n", optional_exts[i]);
448473
enabled[count++] = optional_exts[i];
474+
}
475+
else
476+
{
477+
RARCH_DBG("[Vulkan] Optional device extension NOT supported: %s.\n", optional_exts[i]);
478+
}
479+
}
449480

450481
end:
451482
free(properties);
@@ -525,14 +556,12 @@ static bool vulkan_context_init_gpu(gfx_ctx_vulkan_data_t *vk)
525556
}
526557

527558
static const char *vulkan_device_extensions[] = {
528-
"VK_KHR_swapchain",
529-
#ifdef VK_USE_PLATFORM_WIN32_KHR
530-
"VK_EXT_full_screen_exclusive"
531-
#endif
559+
"VK_KHR_swapchain"
532560
};
533561

534562
static const char *vulkan_optional_device_extensions[] = {
535563
"VK_KHR_sampler_mirror_clamp_to_edge",
564+
"VK_EXT_full_screen_exclusive"
536565
};
537566

538567
static VkDevice vulkan_context_create_device_wrapper(
@@ -800,6 +829,16 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
800829
return false;
801830
}
802831

832+
vk->fse_supported = false;
833+
for (unsigned i = 0; i < enabled_device_extension_count; i++)
834+
{
835+
if (!strcmp(enabled_device_extensions[i], "VK_EXT_full_screen_exclusive"))
836+
{
837+
vk->fse_supported = true;
838+
break;
839+
}
840+
}
841+
803842
queue_info.queueFamilyIndex = vk->context.graphics_queue_index;
804843
queue_info.queueCount = 1;
805844
queue_info.pQueuePriorities = &one;
@@ -892,7 +931,6 @@ static VkInstance vulkan_context_create_instance_wrapper(void *opaque, const VkI
892931
break;
893932
case VULKAN_WSI_WIN32:
894933
required_extensions[required_extension_count++] = "VK_KHR_win32_surface";
895-
required_extensions[required_extension_count++] = "VK_KHR_get_surface_capabilities2";
896934
break;
897935
case VULKAN_WSI_XLIB:
898936
required_extensions[required_extension_count++] = "VK_KHR_xlib_surface";
@@ -1940,21 +1978,21 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
19401978
settings_t *settings = config_get_ptr();
19411979
bool vsync = settings->bools.video_vsync;
19421980
bool adaptive_vsync = settings->bools.video_adaptive_vsync;
1981+
bool fse_supported;
19431982
#ifdef VK_USE_PLATFORM_WIN32_KHR
19441983
bool video_windowed_fullscreen = settings->bools.video_windowed_fullscreen;
1945-
HMONITOR fse_monitor;
1946-
VkSurfaceFullScreenExclusiveWin32InfoEXT fs_win32 = {
1947-
VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT,
1948-
NULL,
1949-
NULL
1984+
HMONITOR hmonitor;
1985+
VkSurfaceFullScreenExclusiveInfoEXT fse_info = {
1986+
VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
1987+
NULL,
1988+
video_windowed_fullscreen
1989+
? VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT
1990+
: VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT
19501991
};
1951-
/* Allow or disallow exclusive fullscreen based on user setting. */
1952-
VkSurfaceFullScreenExclusiveInfoEXT fs_info = {
1953-
VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
1954-
NULL,
1955-
video_windowed_fullscreen
1956-
? VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT
1957-
: VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT
1992+
VkSurfaceFullScreenExclusiveWin32InfoEXT fse_win32_info = {
1993+
VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT,
1994+
NULL,
1995+
NULL
19581996
};
19591997
#endif
19601998

@@ -2305,13 +2343,13 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
23052343
vkDestroySwapchainKHR(vk->context.device, old_swapchain, NULL);
23062344

23072345
#ifdef VK_USE_PLATFORM_WIN32_KHR
2308-
/* Tie exclusive mode to the window's monitor. */
2309-
fse_monitor = MonitorFromWindow(GetActiveWindow(), MONITOR_DEFAULTTONEAREST);
2310-
fs_win32.hmonitor = fse_monitor;
2311-
/* Allow or disallow exclusive fullscreen based on user setting. */
2312-
fs_info.pNext = &fs_win32;
2313-
/* Attach fullscreen info to swapchain creation struct. */
2314-
info.pNext = &fs_info;
2346+
if (vk->fse_supported)
2347+
{
2348+
hmonitor = MonitorFromWindow(GetActiveWindow(), MONITOR_DEFAULTTONEAREST);
2349+
fse_win32_info.hmonitor = hmonitor;
2350+
fse_info.pNext = &fse_win32_info;
2351+
info.pNext = &fse_info;
2352+
}
23152353
#endif
23162354

23172355
if (vkCreateSwapchainKHR(vk->context.device,

gfx/common/vulkan_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ typedef struct gfx_ctx_vulkan_data
385385
struct vulkan_emulated_mailbox mailbox;
386386
uint8_t flags;
387387
enum vulkan_wsi_type wsi_type;
388+
bool fse_supported;
388389
} gfx_ctx_vulkan_data_t;
389390

390391
struct vulkan_display_surface_info

0 commit comments

Comments
 (0)