mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2026-02-04 07:00:27 +01:00
Merge 'Shared present mode, free image on release and limit image count to 1' into 'main'
See merge request mesa/vulkan-wsi-layer!228
This commit is contained in:
commit
b8c4b0fee1
7 changed files with 52 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2024-2025 Arm Limited.
|
||||
* Copyright (c) 2024-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -59,7 +59,9 @@ surface_properties::surface_properties()
|
|||
VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_device,
|
||||
VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
|
||||
{
|
||||
get_surface_capabilities_common(physical_device, pSurfaceCapabilities);
|
||||
/* Image count limits */
|
||||
surface_properties_override_params override_params = { 2, 3 };
|
||||
get_surface_capabilities_common(physical_device, pSurfaceCapabilities, &override_params);
|
||||
|
||||
if (m_specific_surface != nullptr)
|
||||
{
|
||||
|
|
@ -68,10 +70,6 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_
|
|||
pSurfaceCapabilities->maxImageExtent = m_specific_surface->get_extent();
|
||||
}
|
||||
|
||||
/* Image count limits */
|
||||
pSurfaceCapabilities->minImageCount = 2;
|
||||
pSurfaceCapabilities->maxImageCount = 3;
|
||||
|
||||
/* Composite alpha */
|
||||
pSurfaceCapabilities->supportedCompositeAlpha =
|
||||
static_cast<VkCompositeAlphaFlagsKHR>(VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR | VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2019, 2021-2025 Arm Limited.
|
||||
* Copyright (c) 2017-2019, 2021-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -93,7 +93,16 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_
|
|||
VkSurfaceCapabilities2KHR *surface_capabilities)
|
||||
{
|
||||
TRY(check_surface_present_mode_query_is_supported(surface_info, m_supported_modes));
|
||||
get_surface_capabilities_common(physical_device, &surface_capabilities->surfaceCapabilities);
|
||||
surface_properties_override_params override_params = {};
|
||||
auto surface_present_mode =
|
||||
util::find_extension<VkSurfacePresentModeEXT>(VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT, surface_info);
|
||||
if ((surface_present_mode != nullptr) &&
|
||||
((surface_present_mode->presentMode == VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR) ||
|
||||
(surface_present_mode->presentMode == VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR)))
|
||||
{
|
||||
override_params = { 1, 1 };
|
||||
}
|
||||
get_surface_capabilities_common(physical_device, &surface_capabilities->surfaceCapabilities, &override_params);
|
||||
m_compatible_present_modes.get_surface_present_mode_compatibility_common(surface_info, surface_capabilities);
|
||||
|
||||
auto surface_scaling_capabilities = util::find_extension<VkSurfacePresentScalingCapabilitiesEXT>(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 2024-2025 Arm Limited.
|
||||
* Copyright (c) 2022, 2024-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -95,12 +95,25 @@ void surface_format_properties::fill_format_properties(VkSurfaceFormat2KHR &surf
|
|||
}
|
||||
}
|
||||
|
||||
void get_surface_capabilities_common(VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR *surface_capabilities)
|
||||
void get_surface_capabilities_common(VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR *surface_capabilities,
|
||||
const surface_properties_override_params *override_params)
|
||||
{
|
||||
/* Image count limits */
|
||||
surface_capabilities->minImageCount = 1;
|
||||
surface_capabilities->maxImageCount = surface_properties::MAX_SWAPCHAIN_IMAGE_COUNT;
|
||||
|
||||
if (override_params != nullptr)
|
||||
{
|
||||
if (override_params->min_swapchain_image_count != 0)
|
||||
{
|
||||
surface_capabilities->minImageCount = override_params->min_swapchain_image_count;
|
||||
}
|
||||
if (override_params->max_swapchain_image_count != 0)
|
||||
{
|
||||
surface_capabilities->maxImageCount = override_params->max_swapchain_image_count;
|
||||
}
|
||||
}
|
||||
|
||||
/* Surface extents */
|
||||
surface_capabilities->currentExtent = { 0xffffffff, 0xffffffff };
|
||||
surface_capabilities->minImageExtent = { 1, 1 };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2019, 2021-2025 Arm Limited.
|
||||
* Copyright (c) 2017-2019, 2021-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -42,7 +42,11 @@
|
|||
|
||||
namespace wsi
|
||||
{
|
||||
|
||||
struct surface_properties_override_params
|
||||
{
|
||||
uint32_t min_swapchain_image_count = 0;
|
||||
uint32_t max_swapchain_image_count = 0;
|
||||
};
|
||||
/**
|
||||
* @brief The base surface property query interface.
|
||||
*/
|
||||
|
|
@ -285,9 +289,10 @@ VkResult check_surface_present_mode_query_is_supported(const VkPhysicalDeviceSur
|
|||
*
|
||||
* @param physical_device Vulkan physical_device.
|
||||
* @param surface_capabilities address of Vulkan surface capabilities struct.
|
||||
*
|
||||
* @param override_params Backend specfic parameters to override.
|
||||
*/
|
||||
void get_surface_capabilities_common(VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR *surface_capabilities);
|
||||
void get_surface_capabilities_common(VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR *surface_capabilities,
|
||||
const surface_properties_override_params *override_params = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Common function for the get_surface_present_modes.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2025 Arm Limited.
|
||||
* Copyright (c) 2017-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -176,7 +176,7 @@ VkResult swapchain_base::init_page_flip_thread()
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void swapchain_base::unpresent_image(uint32_t presented_index)
|
||||
void swapchain_base::unpresent_image(uint32_t presented_index, bool release_image)
|
||||
{
|
||||
util::unique_lock<util::recursive_mutex> image_status_lock(m_image_status_mutex);
|
||||
if (!image_status_lock)
|
||||
|
|
@ -186,11 +186,12 @@ void swapchain_base::unpresent_image(uint32_t presented_index)
|
|||
}
|
||||
|
||||
const bool is_shared_present = is_using_shared_present_mode();
|
||||
m_swapchain_images[presented_index].set_status(is_shared_present ? swapchain_image::ACQUIRED :
|
||||
swapchain_image::FREE);
|
||||
const bool should_keep_acquired = is_shared_present && !release_image;
|
||||
m_swapchain_images[presented_index].set_status(should_keep_acquired ? swapchain_image::ACQUIRED :
|
||||
swapchain_image::FREE);
|
||||
|
||||
image_status_lock.unlock();
|
||||
if (!is_shared_present)
|
||||
if (!should_keep_acquired)
|
||||
{
|
||||
m_free_image_semaphore.post();
|
||||
}
|
||||
|
|
@ -781,7 +782,7 @@ void swapchain_base::release_images(uint32_t image_count, const uint32_t *indice
|
|||
assert(index < m_swapchain_images.size());
|
||||
/* Applications can only pass acquired images that the device doesn't own */
|
||||
assert(m_swapchain_images[index].get_status() == swapchain_image::ACQUIRED);
|
||||
unpresent_image(index);
|
||||
unpresent_image(index, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2025 Arm Limited.
|
||||
* Copyright (c) 2017-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -538,8 +538,9 @@ protected:
|
|||
* Called by swapchain implementation when a new image has been presented.
|
||||
*
|
||||
* @param presented_index Index of the image to be marked as free.
|
||||
* @param release_image The image is released.
|
||||
*/
|
||||
void unpresent_image(uint32_t presented_index);
|
||||
void unpresent_image(uint32_t presented_index, bool release_image = false);
|
||||
|
||||
/**
|
||||
* @brief Hook for any actions to free up a buffer for acquire
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2019, 2021-2025 Arm Limited.
|
||||
* Copyright (c) 2017-2019, 2021-2026 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
|
@ -90,8 +90,8 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_
|
|||
{
|
||||
|
||||
/* Image count limits */
|
||||
get_surface_capabilities_common(physical_device, pSurfaceCapabilities);
|
||||
pSurfaceCapabilities->minImageCount = 2;
|
||||
surface_properties_override_params override_params = { 2, 0 };
|
||||
get_surface_capabilities_common(physical_device, pSurfaceCapabilities, &override_params);
|
||||
|
||||
/* Composite alpha */
|
||||
pSurfaceCapabilities->supportedCompositeAlpha = static_cast<VkCompositeAlphaFlagsKHR>(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue