vulkan/wsi: Promote EXT_swapchain/surface_maintenance1.

No spec changes, just update the enums and types.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37157>
This commit is contained in:
Hans-Kristian Arntzen 2025-09-03 12:27:44 +02:00
parent 6b9c4535f9
commit 974dba2afe
8 changed files with 60 additions and 56 deletions

View file

@ -592,6 +592,8 @@ Khronos extensions that are not part of any Vulkan version:
VK_KHR_win32_surface DONE (dzn, lvp)
VK_KHR_xcb_surface DONE (anv, dzn, hasvk, hk, lvp, nvk, panvk, radv, tu, v3dv, vn)
VK_KHR_xlib_surface DONE (anv, dzn, hasvk, hk, lvp, nvk, panvk, radv, tu, v3dv, vn)
VK_KHR_surface_maintenance1 DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn)
VK_KHR_swapchain_maintenance1 DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn)
VK_EXT_acquire_xlib_display DONE (anv, hk, lvp, nvk, panvk, radv, tu, v3dv, vn)
VK_EXT_attachment_feedback_loop_dynamic_state DONE (anv, lvp, radv, tu, vn)
VK_EXT_attachment_feedback_loop_layout DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn)

View file

@ -14,3 +14,5 @@ VK_EXT_custom_resolve on RADV
GL_EXT_shader_pixel_local_storage on Panfrost v6+
sparseResidencyImage2D on panvk v10+
sparseResidencyStandard2DBlockShape on panvk v10+
VK_KHR_surface_maintenance1 promotion everywhere EXT is exposed
VK_KHR_swapchain_maintenance1 promotion everywhere EXT is exposed

View file

@ -1137,8 +1137,8 @@ wsi_DestroySwapchainKHR(VkDevice _device,
}
VKAPI_ATTR VkResult VKAPI_CALL
wsi_ReleaseSwapchainImagesEXT(VkDevice _device,
const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo)
wsi_ReleaseSwapchainImagesKHR(VkDevice _device,
const VkReleaseSwapchainImagesInfoKHR *pReleaseInfo)
{
VK_FROM_HANDLE(wsi_swapchain, swapchain, pReleaseInfo->swapchain);
@ -1519,8 +1519,8 @@ wsi_common_queue_present(const struct wsi_device *wsi,
vk_find_struct_const(pPresentInfo->pNext, PRESENT_ID_KHR);
const VkPresentId2KHR *present_ids2 =
vk_find_struct_const(pPresentInfo->pNext, PRESENT_ID_2_KHR);
const VkSwapchainPresentFenceInfoEXT *present_fence_info =
vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_FENCE_INFO_EXT);
const VkSwapchainPresentFenceInfoKHR *present_fence_info =
vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_FENCE_INFO_KHR);
/* Gather up all the semaphores and fences we need to signal per-image */
STACK_ARRAY(struct wsi_image_signal_info, image_signal_infos,
@ -1726,8 +1726,8 @@ wsi_common_queue_present(const struct wsi_device *wsi,
/* Finally, we can present */
const VkPresentRegionsKHR *regions =
vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
const VkSwapchainPresentModeInfoEXT *present_mode_info =
vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_MODE_INFO_EXT);
const VkSwapchainPresentModeInfoKHR *present_mode_info =
vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_MODE_INFO_KHR);
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);

View file

@ -1264,8 +1264,8 @@ wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
struct wsi_surface_supported_counters *counters =
vk_find_struct( caps->pNext, WSI_SURFACE_SUPPORTED_COUNTERS_MESA);
const VkSurfacePresentModeEXT *present_mode =
vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_EXT);
const VkSurfacePresentModeKHR *present_mode =
vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_KHR);
if (counters) {
result = wsi_display_surface_get_surface_counters(&counters->supported_surface_counters);
@ -1279,9 +1279,9 @@ wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_KHR: {
/* Unsupported. */
VkSurfacePresentScalingCapabilitiesEXT *scaling = (void *)ext;
VkSurfacePresentScalingCapabilitiesKHR *scaling = (void *)ext;
scaling->supportedPresentScaling = 0;
scaling->supportedPresentGravityX = 0;
scaling->supportedPresentGravityY = 0;
@ -1290,9 +1290,9 @@ wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR: {
/* We only support FIFO. */
VkSurfacePresentModeCompatibilityEXT *compat = (void *)ext;
VkSurfacePresentModeCompatibilityKHR *compat = (void *)ext;
if (compat->pPresentModes) {
if (compat->presentModeCount) {
assert(present_mode);

View file

@ -92,8 +92,8 @@ wsi_metal_surface_get_capabilities2(VkIcdSurfaceBase *surface,
{
assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR);
const VkSurfacePresentModeEXT *present_mode =
(const VkSurfacePresentModeEXT *)vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_EXT);
const VkSurfacePresentModeKHR *present_mode =
(const VkSurfacePresentModeKHR *)vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_KHR);
VkResult result =
wsi_metal_surface_get_capabilities(surface, wsi_device,
@ -107,10 +107,10 @@ wsi_metal_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_KHR: {
/* TODO: support scaling */
VkSurfacePresentScalingCapabilitiesEXT *scaling =
(VkSurfacePresentScalingCapabilitiesEXT *)ext;
VkSurfacePresentScalingCapabilitiesKHR *scaling =
(VkSurfacePresentScalingCapabilitiesKHR *)ext;
scaling->supportedPresentScaling = 0;
scaling->supportedPresentGravityX = 0;
scaling->supportedPresentGravityY = 0;
@ -119,10 +119,10 @@ wsi_metal_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR: {
/* Unsupported, just report the input present mode. */
VkSurfacePresentModeCompatibilityEXT *compat =
(VkSurfacePresentModeCompatibilityEXT *)ext;
VkSurfacePresentModeCompatibilityKHR *compat =
(VkSurfacePresentModeCompatibilityKHR *)ext;
if (compat->pPresentModes) {
if (compat->presentModeCount) {
assert(present_mode);
@ -131,8 +131,8 @@ wsi_metal_surface_get_capabilities2(VkIcdSurfaceBase *surface,
}
} else {
if (!present_mode)
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityKHR "
"without a VkSurfacePresentModeKHR set. This is an "
"application bug.\n");
compat->presentModeCount = 1;
}

View file

@ -1704,7 +1704,7 @@ wsi_wl_surface_get_support(VkIcdSurfaceBase *surface,
static uint32_t
wsi_wl_surface_get_min_image_count(struct wsi_wl_display *display,
const VkSurfacePresentModeEXT *present_mode)
const VkSurfacePresentModeKHR *present_mode)
{
if (present_mode) {
return present_mode->presentMode == VK_PRESENT_MODE_MAILBOX_KHR ?
@ -1737,7 +1737,7 @@ wsi_wl_surface_get_min_image_count(struct wsi_wl_display *display,
static VkResult
wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
struct wsi_device *wsi_device,
const VkSurfacePresentModeEXT *present_mode,
const VkSurfacePresentModeKHR *present_mode,
VkSurfaceCapabilitiesKHR* caps)
{
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
@ -1817,7 +1817,7 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface,
struct wsi_wl_surface *wsi_wl_surface =
wl_container_of((VkIcdSurfaceWayland *)surface, wsi_wl_surface, base);
const VkSurfacePresentModeEXT *present_mode = vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_EXT);
const VkSurfacePresentModeKHR *present_mode = vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_KHR);
VkResult result =
wsi_wl_surface_get_capabilities(surface, wsi_device, present_mode,
@ -1832,9 +1832,9 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_KHR: {
/* Unsupported. */
VkSurfacePresentScalingCapabilitiesEXT *scaling = (void *)ext;
VkSurfacePresentScalingCapabilitiesKHR *scaling = (void *)ext;
scaling->supportedPresentScaling = 0;
scaling->supportedPresentGravityX = 0;
scaling->supportedPresentGravityY = 0;
@ -1843,9 +1843,9 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR: {
/* Can easily toggle between FIFO and MAILBOX on Wayland. */
VkSurfacePresentModeCompatibilityEXT *compat = (void *)ext;
VkSurfacePresentModeCompatibilityKHR *compat = (void *)ext;
if (compat->pPresentModes) {
assert(present_mode);
VK_OUTARRAY_MAKE_TYPED(VkPresentModeKHR, modes, compat->pPresentModes, &compat->presentModeCount);
@ -1869,8 +1869,8 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface,
}
} else {
if (!present_mode) {
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityKHR "
"without a VkSurfacePresentModeKHR set. This is an "
"application bug.\n");
compat->presentModeCount = 1;
} else {
@ -3006,7 +3006,7 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
if (ret != VK_SUCCESS)
return ret;
/* For EXT_swapchain_maintenance1. We might have transitioned from FIFO to MAILBOX.
/* For KHR_swapchain_maintenance1. We might have transitioned from FIFO to MAILBOX.
* In this case we need to let the FIFO request complete, before presenting MAILBOX. */
while (!chain->legacy_fifo_ready) {
int ret = wl_display_dispatch_queue(wsi_wl_surface->display->wl_display,
@ -3172,7 +3172,7 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
* When using timestamps, we already emit a dummy commit with the wait barrier anyway. */
chain->next_present_force_wait_barrier = !timestamped;
} else if (chain->fifo && chain->next_present_force_wait_barrier) {
/* If we're using EXT_swapchain_maintenance1 to transition from FIFO to something non-FIFO
/* If we're using KHR_swapchain_maintenance1 to transition from FIFO to something non-FIFO
* the previous frame's FIFO must persist for a refresh cycle, i.e. it cannot be replaced by a MAILBOX presentation.
* From 1.4.303 spec:
* "Transition from VK_PRESENT_MODE_FIFO_KHR or VK_PRESENT_MODE_FIFO_RELAXED_KHR or VK_PRESENT_MODE_FIFO_LATEST_READY_EXT to
@ -3382,7 +3382,7 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain,
assert(!chain->present_ids.dispatch_in_progress);
/* In VK_EXT_swapchain_maintenance1 there is no requirement to wait for all present IDs to be complete.
/* In VK_KHR_swapchain_maintenance1 there is no requirement to wait for all present IDs to be complete.
* Waiting for the swapchain fence is enough.
* Just clean up anything user did not wait for. */
struct wsi_wl_present_id *id, *tmp;
@ -3498,13 +3498,13 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
uint32_t num_images = pCreateInfo->minImageCount;
/* If app provides a present mode list from EXT_swapchain_maintenance1,
/* If app provides a present mode list from KHR_swapchain_maintenance1,
* we don't know which present mode will be used.
* Application is assumed to be well-behaved and be spec-compliant.
* It needs to query all per-present mode minImageCounts individually and use the max() of those modes,
* so there should never be any need to bump image counts. */
bool uses_present_mode_group = vk_find_struct_const(
pCreateInfo->pNext, SWAPCHAIN_PRESENT_MODES_CREATE_INFO_EXT) != NULL;
pCreateInfo->pNext, SWAPCHAIN_PRESENT_MODES_CREATE_INFO_KHR) != NULL;
/* If FIFO manager is not used, minImageCount is already the bumped value for reasons outlined in
* wsi_wl_surface_get_min_image_count(), so skip any attempt to bump the counts. */
@ -3512,8 +3512,8 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
/* With proper FIFO, we return a lower minImageCount to make FIFO viable without requiring the use of KHR_present_wait.
* The image count for MAILBOX should be bumped for performance reasons in this case.
* This matches strategy for X11. */
const VkSurfacePresentModeEXT mode =
{ VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT, NULL, pCreateInfo->presentMode };
const VkSurfacePresentModeKHR mode =
{ VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_KHR, NULL, pCreateInfo->presentMode };
uint32_t min_images = wsi_wl_surface_get_min_image_count(wsi_wl_surface->display, &mode);
bool requires_image_count_bump = min_images == WSI_WL_BUMPED_NUM_IMAGES;

View file

@ -229,8 +229,8 @@ wsi_win32_surface_get_capabilities2(VkIcdSurfaceBase *surface,
{
assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR);
const VkSurfacePresentModeEXT *present_mode =
(const VkSurfacePresentModeEXT *)vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_EXT);
const VkSurfacePresentModeKHR *present_mode =
(const VkSurfacePresentModeKHR *)vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_KHR);
VkResult result =
wsi_win32_surface_get_capabilities(surface, wsi_device,
@ -244,7 +244,7 @@ wsi_win32_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_KHR: {
/* Unsupported. */
VkSurfacePresentScalingCapabilitiesEXT *scaling =
(VkSurfacePresentScalingCapabilitiesEXT *)ext;
@ -256,10 +256,10 @@ wsi_win32_surface_get_capabilities2(VkIcdSurfaceBase *surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR: {
/* Unsupported, just report the input present mode. */
VkSurfacePresentModeCompatibilityEXT *compat =
(VkSurfacePresentModeCompatibilityEXT *)ext;
VkSurfacePresentModeCompatibilityKHR *compat =
(VkSurfacePresentModeCompatibilityKHR *)ext;
if (compat->pPresentModes) {
if (compat->presentModeCount) {
assert(present_mode);
@ -268,8 +268,8 @@ wsi_win32_surface_get_capabilities2(VkIcdSurfaceBase *surface,
}
} else {
if (!present_mode)
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityKHR "
"without a VkSurfacePresentModeKHR set. This is an "
"application bug.\n");
compat->presentModeCount = 1;
}

View file

@ -728,7 +728,7 @@ x11_get_min_image_count_for_present_mode(struct wsi_device *wsi_device,
static VkResult
x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
struct wsi_device *wsi_device,
const VkSurfacePresentModeEXT *present_mode,
const VkSurfacePresentModeKHR *present_mode,
VkSurfaceCapabilitiesKHR *caps)
{
xcb_connection_t *conn = x11_surface_get_connection(icd_surface);
@ -791,7 +791,7 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
{
assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR);
const VkSurfacePresentModeEXT *present_mode = vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_EXT);
const VkSurfacePresentModeKHR *present_mode = vk_find_struct_const(info_next, SURFACE_PRESENT_MODE_KHR);
VkResult result =
x11_surface_get_capabilities(icd_surface, wsi_device, present_mode,
@ -809,9 +809,9 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_KHR: {
/* Unsupported. */
VkSurfacePresentScalingCapabilitiesEXT *scaling = (void *)ext;
VkSurfacePresentScalingCapabilitiesKHR *scaling = (void *)ext;
scaling->supportedPresentScaling = 0;
scaling->supportedPresentGravityX = 0;
scaling->supportedPresentGravityY = 0;
@ -820,9 +820,9 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
break;
}
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT: {
case VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR: {
/* All present modes are compatible with each other. */
VkSurfacePresentModeCompatibilityEXT *compat = (void *)ext;
VkSurfacePresentModeCompatibilityKHR *compat = (void *)ext;
if (compat->pPresentModes) {
assert(present_mode);
VK_OUTARRAY_MAKE_TYPED(VkPresentModeKHR, modes, compat->pPresentModes, &compat->presentModeCount);
@ -840,8 +840,8 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
}
} else {
if (!present_mode)
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityEXT "
"without a VkSurfacePresentModeEXT set. This is an "
wsi_common_vk_warn_once("Use of VkSurfacePresentModeCompatibilityKHR "
"without a VkSurfacePresentModeKHR set. This is an "
"application bug.\n");
compat->presentModeCount = ARRAY_SIZE(present_modes);
@ -1710,7 +1710,7 @@ x11_requires_mailbox_image_count(const struct wsi_device *device,
*
* - IMMEDIATE expects tearing, and when tearing, 3 images are more than enough.
*
* - With EXT_swapchain_maintenance1, toggling between FIFO / IMMEDIATE (used extensively by D3D layering)
* - With KHR_swapchain_maintenance1, toggling between FIFO / IMMEDIATE (used extensively by D3D layering)
* would require application to allocate >3 images which is unfortunate for memory usage,
* and potentially disastrous for latency unless KHR_present_wait is used.
*/
@ -1872,7 +1872,7 @@ x11_queue_present(struct wsi_swapchain *wsi_chain,
}
chain->images[image_index].update_area = update_area;
chain->images[image_index].present_id = present_id;
/* With EXT_swapchain_maintenance1, the present mode can change per present. */
/* With KHR_swapchain_maintenance1, the present mode can change per present. */
chain->images[image_index].present_mode = chain->base.present_mode;
wsi_queue_push(&chain->present_queue, image_index);