mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2025-12-20 04:30:11 +01:00
Add vkReleaseSwapchainImagesEXT entrypoint
Adds the vkReleaseSwapchainImagesEXT entrypoint in the WSI layer which allows applications to release the acquired images back to the swapchain without presenting them. Change-Id: I52900547f95661e6ec40cb586b035da0ca2d266f Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com> Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com> Signed-off-by: Fufu Fang <fufu.fang@arm.com>
This commit is contained in:
parent
8e02a7ffe3
commit
d2b8eb3135
9 changed files with 137 additions and 4 deletions
|
|
@ -224,6 +224,7 @@ add_library(${PROJECT_NAME} SHARED
|
|||
layer/private_data.cpp
|
||||
layer/surface_api.cpp
|
||||
layer/swapchain_api.cpp
|
||||
layer/swapchain_maintenance_api.cpp
|
||||
util/timed_semaphore.cpp
|
||||
util/custom_allocator.cpp
|
||||
util/extension_list.cpp
|
||||
|
|
|
|||
|
|
@ -36,10 +36,16 @@
|
|||
"vkGetPhysicalDevicePresentRectanglesKHR"
|
||||
]
|
||||
},
|
||||
{"name": "VK_EXT_swapchain_maintenance1", "spec_version": "1"}
|
||||
{
|
||||
"name": "VK_EXT_swapchain_maintenance1",
|
||||
"spec_version": "1",
|
||||
"entrypoints": [
|
||||
"vkReleaseSwapchainImagesEXT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"disable_environment": {
|
||||
"DISABLE_WSI_LAYER": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
#include "private_data.hpp"
|
||||
#include "surface_api.hpp"
|
||||
#include "swapchain_api.hpp"
|
||||
#include "swapchain_maintenance_api.hpp"
|
||||
#include "util/extension_list.hpp"
|
||||
#include "util/custom_allocator.hpp"
|
||||
#include "wsi/wsi_factory.hpp"
|
||||
|
|
@ -462,6 +463,13 @@ wsi_layer_vkGetDeviceProcAddr(VkDevice device, const char *funcName) VWL_API_POS
|
|||
GET_PROC_ADDR(vkCreateImage);
|
||||
GET_PROC_ADDR(vkBindImageMemory2);
|
||||
|
||||
/* VK_EXT_swapchain_maintenance1 */
|
||||
if (layer::device_private_data::get(device).is_device_extension_enabled(
|
||||
VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME))
|
||||
{
|
||||
GET_PROC_ADDR(vkReleaseSwapchainImagesEXT);
|
||||
}
|
||||
|
||||
return layer::device_private_data::get(device).disp.get_user_enabled_entrypoint(
|
||||
device, layer::device_private_data::get(device).instance_data.api_version, funcName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -403,7 +403,9 @@ private:
|
|||
/* VK_KHR_get_memory_requirements2 */ \
|
||||
EP(GetImageMemoryRequirements2KHR, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_API_VERSION_1_1, false) \
|
||||
EP(GetBufferMemoryRequirements2KHR, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_API_VERSION_1_1, false) \
|
||||
EP(GetImageSparseMemoryRequirements2KHR, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_API_VERSION_1_1, false)
|
||||
EP(GetImageSparseMemoryRequirements2KHR, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_API_VERSION_1_1, \
|
||||
false) \
|
||||
EP(ReleaseSwapchainImagesEXT, VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME, VK_API_VERSION_1_1, false)
|
||||
|
||||
/**
|
||||
* @brief Struct representing the device dispatch table.
|
||||
|
|
|
|||
|
|
@ -117,7 +117,6 @@ wsi_layer_vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapc, uint64_t
|
|||
}
|
||||
|
||||
assert(swapc != VK_NULL_HANDLE);
|
||||
assert(semaphore != VK_NULL_HANDLE || fence != VK_NULL_HANDLE);
|
||||
assert(pImageIndex != nullptr);
|
||||
auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
|
||||
return sc->acquire_next_image(timeout, semaphore, fence, pImageIndex);
|
||||
|
|
|
|||
58
layer/swapchain_maintenance_api.cpp
Normal file
58
layer/swapchain_maintenance_api.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file swapchain_maintenance_api.cpp
|
||||
*
|
||||
* @brief Contains the Vulkan entrypoints for the swapchain maintenance.
|
||||
*/
|
||||
|
||||
#include "swapchain_maintenance_api.hpp"
|
||||
#include "private_data.hpp"
|
||||
|
||||
#include <wsi/wsi_factory.hpp>
|
||||
#include <cassert>
|
||||
|
||||
VWL_VKAPI_CALL(VkResult)
|
||||
wsi_layer_vkReleaseSwapchainImagesEXT(VkDevice device, const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo) VWL_API_POST
|
||||
{
|
||||
if (pReleaseInfo == nullptr || pReleaseInfo->imageIndexCount == 0)
|
||||
{
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
assert(pReleaseInfo->pImageIndices != nullptr);
|
||||
assert(pReleaseInfo->swapchain != VK_NULL_HANDLE);
|
||||
|
||||
auto &device_data = layer::device_private_data::get(device);
|
||||
if (!device_data.layer_owns_swapchain(pReleaseInfo->swapchain))
|
||||
{
|
||||
return device_data.disp.ReleaseSwapchainImagesEXT(device, pReleaseInfo);
|
||||
}
|
||||
|
||||
auto *sc = reinterpret_cast<wsi::swapchain_base *>(pReleaseInfo->swapchain);
|
||||
sc->release_images(pReleaseInfo->imageIndexCount, pReleaseInfo->pImageIndices);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
38
layer/swapchain_maintenance_api.hpp
Normal file
38
layer/swapchain_maintenance_api.hpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Arm Limited.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file swapchain_maintenance_api.hpp
|
||||
*
|
||||
* @brief Contains the Vulkan entrypoints for the swapchain maintenance.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "util/macros.hpp"
|
||||
|
||||
VWL_VKAPI_CALL(VkResult)
|
||||
wsi_layer_vkReleaseSwapchainImagesEXT(VkDevice device,
|
||||
const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo) VWL_API_POST;
|
||||
|
|
@ -693,4 +693,16 @@ VkResult swapchain_base::wait_for_free_buffer(uint64_t timeout)
|
|||
return retval;
|
||||
}
|
||||
|
||||
void swapchain_base::release_images(uint32_t image_count, const uint32_t *indices)
|
||||
{
|
||||
for (uint32_t i = 0; i < image_count; i++)
|
||||
{
|
||||
uint32_t index = indices[i];
|
||||
assert(index < m_swapchain_images.size());
|
||||
/* Applications can only pass acquired images that the device doesn't own */
|
||||
assert(m_swapchain_images[index].status == swapchain_image::ACQUIRED);
|
||||
unpresent_image(index);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace wsi */
|
||||
|
|
|
|||
|
|
@ -214,6 +214,15 @@ public:
|
|||
*/
|
||||
VkResult get_swapchain_status();
|
||||
|
||||
/**
|
||||
* @brief Release all images not belonging to the device
|
||||
* by making them available to be acquired again
|
||||
*
|
||||
* @param image_count Amount of images in the indices array
|
||||
* @param indices Array of image indices
|
||||
*/
|
||||
void release_images(uint32_t image_count, const uint32_t *indices);
|
||||
|
||||
protected:
|
||||
layer::device_private_data &m_device_data;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue