diff --git a/src/amd/vulkan/radv_instance.c b/src/amd/vulkan/radv_instance.c index 7b07da3321c..d31a719198b 100644 --- a/src/amd/vulkan/radv_instance.c +++ b/src/amd/vulkan/radv_instance.c @@ -135,6 +135,7 @@ static const driOptionDescription radv_dri_options[] = { DRI_CONF_SECTION_DEBUG DRI_CONF_OVERRIDE_VRAM_SIZE() DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(false) + DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_RADV_ZERO_VRAM(false) DRI_CONF_RADV_LOWER_DISCARD_TO_DEMOTE(false) DRI_CONF_RADV_INVARIANT_GEOM(false) diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc index e977824aecb..78786b6c8fe 100644 --- a/src/freedreno/vulkan/tu_device.cc +++ b/src/freedreno/vulkan/tu_device.cc @@ -745,6 +745,7 @@ static const driOptionDescription tu_dri_options[] = { DRI_CONF_SECTION_DEBUG DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(false) + DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_VK_DONT_CARE_AS_LOAD(false) DRI_CONF_SECTION_END diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 0602da77087..448b7a101ca 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -88,6 +88,7 @@ static const driOptionDescription anv_dri_options[] = { DRI_CONF_SECTION_DEBUG DRI_CONF_ALWAYS_FLUSH_CACHE(false) DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(false) + DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_LIMIT_TRIG_INPUT_RANGE(false) DRI_CONF_ANV_MESH_CONV_PRIM_ATTRS_TO_VERT_ATTRS(-2) DRI_CONF_FORCE_VK_VENDOR(0) diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index 5b4371a89ba..0016c4007f0 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -75,6 +75,7 @@ static const driOptionDescription anv_dri_options[] = { DRI_CONF_SECTION_DEBUG DRI_CONF_ALWAYS_FLUSH_CACHE(false) DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(false) + DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_LIMIT_TRIG_INPUT_RANGE(false) DRI_CONF_SECTION_END diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c index f6189b725f7..a11a482e1e1 100644 --- a/src/microsoft/vulkan/dzn_device.c +++ b/src/microsoft/vulkan/dzn_device.c @@ -1442,6 +1442,7 @@ static const driOptionDescription dzn_dri_options[] = { DRI_CONF_SECTION_DEBUG DRI_CONF_DZN_CLAIM_WIDE_LINES(false) DRI_CONF_DZN_ENABLE_8BIT_LOADS_STORES(false) + DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_SECTION_END }; diff --git a/src/util/driconf.h b/src/util/driconf.h index 009fcce7b0c..3c598c96d66 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -394,6 +394,10 @@ DRI_CONF_OPT_B(vk_wsi_force_bgra8_unorm_first, def, \ "Force vkGetPhysicalDeviceSurfaceFormatsKHR to return VK_FORMAT_B8G8R8A8_UNORM as the first format") +#define DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(def) \ + DRI_CONF_OPT_B(vk_wsi_force_swapchain_to_current_extent, def, \ + "Force VkSwapchainCreateInfoKHR::imageExtent to be VkSurfaceCapabilities2KHR::currentExtent") + #define DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(def) \ DRI_CONF_OPT_I(vk_x11_override_min_image_count, def, 0, 999, \ "Override the VkSurfaceCapabilitiesKHR::minImageCount (0 = no override)") diff --git a/src/virtio/vulkan/vn_instance.c b/src/virtio/vulkan/vn_instance.c index 233a2614132..29aae7b243c 100644 --- a/src/virtio/vulkan/vn_instance.c +++ b/src/virtio/vulkan/vn_instance.c @@ -63,6 +63,7 @@ static const driOptionDescription vn_dri_options[] = { DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(false) + DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false) DRI_CONF_SECTION_END /* clang-format on */ }; diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 4e848dd769c..27fd4edeffa 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -240,6 +240,11 @@ wsi_device_init(struct wsi_device *wsi, wsi->force_bgra8_unorm_first = driQueryOptionb(dri_options, "vk_wsi_force_bgra8_unorm_first"); } + + if (driCheckOption(dri_options, "vk_wsi_force_swapchain_to_current_extent", DRI_BOOL)) { + wsi->force_swapchain_to_currentExtent = + driQueryOptionb(dri_options, "vk_wsi_force_swapchain_to_current_extent"); + } } return VK_SUCCESS; @@ -923,12 +928,22 @@ wsi_CreateSwapchainKHR(VkDevice _device, else alloc = &device->alloc; + VkSwapchainCreateInfoKHR info = *pCreateInfo; + + if (wsi_device->force_swapchain_to_currentExtent) { + VkSurfaceCapabilities2KHR caps2 = { + .sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR, + }; + iface->get_capabilities2(surface, wsi_device, NULL, &caps2); + info.imageExtent = caps2.surfaceCapabilities.currentExtent; + } + /* Ignore DEFERRED_MEMORY_ALLOCATION_BIT. Would require deep plumbing to be able to take advantage of it. * bool deferred_allocation = pCreateInfo->flags & VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT; */ VkResult result = iface->create_swapchain(surface, _device, wsi_device, - pCreateInfo, alloc, + &info, alloc, &swapchain); if (result != VK_SUCCESS) return result; diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index fc30beeb0d2..8fe8fb9a748 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -135,6 +135,8 @@ struct wsi_device { /* Create headless swapchains. */ bool force_headless_swapchain; + bool force_swapchain_to_currentExtent; + struct { /* Override the minimum number of images on the swapchain. * 0 = no override */