mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2025-12-20 08:00:12 +01:00
Adds initial support to the headless and Wayland backends to query swapchain timing properties. This patch also moves all present timing backend specific code into its own file and refactors the private_data code that is specific to present timing entrypoints into a more common format. Change-Id: I377197a6e14b3cbd968e35735d43060d19dfe5bc Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
117 lines
4.6 KiB
C++
117 lines
4.6 KiB
C++
/*
|
|
* Copyright (c) 2024-2025 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 present_timing.cpp
|
|
*
|
|
* @brief Contains the Vulkan entrypoints for the present timing.
|
|
*/
|
|
#include <cassert>
|
|
#include "wsi_layer_experimental.hpp"
|
|
|
|
#include <wsi/extensions/present_timing.hpp>
|
|
#include <wsi/swapchain_base.hpp>
|
|
#include "util/macros.hpp"
|
|
|
|
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
|
/**
|
|
* @brief Implements vkSetSwapchainPresentTimingQueueSizeEXT Vulkan entrypoint.
|
|
*/
|
|
VWL_VKAPI_CALL(VkResult)
|
|
wsi_layer_vkSetSwapchainPresentTimingQueueSizeEXT(VkDevice device, VkSwapchainKHR swapchain, uint32_t size) VWL_API_POST
|
|
{
|
|
assert(swapchain != VK_NULL_HANDLE);
|
|
|
|
auto &device_data = layer::device_private_data::get(device);
|
|
if (!device_data.layer_owns_swapchain(swapchain))
|
|
{
|
|
return device_data.disp.SetSwapchainPresentTimingQueueSizeEXT(device, swapchain, size);
|
|
}
|
|
|
|
auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapchain);
|
|
auto *ext = sc->get_swapchain_extension<wsi::wsi_ext_present_timing>(true);
|
|
|
|
return ext->present_timing_queue_set_size(size);
|
|
}
|
|
|
|
/**
|
|
* @brief Implements vkGetSwapchainTimingPropertiesEXT Vulkan entrypoint.
|
|
*/
|
|
VWL_VKAPI_CALL(VkResult)
|
|
wsi_layer_vkGetSwapchainTimingPropertiesEXT(VkDevice device, VkSwapchainKHR swapchain,
|
|
uint64_t *pSwapchainTimingPropertiesCounter,
|
|
VkSwapchainTimingPropertiesEXT *pSwapchainTimingProperties) VWL_API_POST
|
|
{
|
|
assert(swapchain != VK_NULL_HANDLE);
|
|
|
|
auto &device_data = layer::device_private_data::get(device);
|
|
if (!device_data.layer_owns_swapchain(swapchain))
|
|
{
|
|
return device_data.disp.GetSwapchainTimingPropertiesEXT(device, swapchain, pSwapchainTimingPropertiesCounter,
|
|
pSwapchainTimingProperties);
|
|
}
|
|
|
|
auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapchain);
|
|
auto *ext = sc->get_swapchain_extension<wsi::wsi_ext_present_timing>(true);
|
|
|
|
return ext->get_swapchain_timing_properties(*pSwapchainTimingPropertiesCounter, *pSwapchainTimingProperties);
|
|
}
|
|
|
|
/**
|
|
* @brief Implements vkGetSwapchainTimeDomainPropertiesEXT Vulkan entrypoint.
|
|
*/
|
|
VWL_VKAPI_CALL(VkResult)
|
|
wsi_layer_vkGetSwapchainTimeDomainPropertiesEXT(
|
|
VkDevice device, VkSwapchainKHR swapchain, uint64_t *pTimeDomainsCounter,
|
|
VkSwapchainTimeDomainPropertiesEXT *pSwapchainTimeDomainProperties) VWL_API_POST
|
|
{
|
|
auto &device_data = layer::device_private_data::get(device);
|
|
|
|
if (!device_data.layer_owns_swapchain(swapchain))
|
|
{
|
|
return device_data.disp.GetSwapchainTimeDomainPropertiesEXT(device, swapchain, pTimeDomainsCounter,
|
|
pSwapchainTimeDomainProperties);
|
|
}
|
|
|
|
auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapchain);
|
|
auto *ext = sc->get_swapchain_extension<wsi::wsi_ext_present_timing>(true);
|
|
return ext->get_swapchain_time_domains().get_swapchain_time_domain_properties(pSwapchainTimeDomainProperties,
|
|
pTimeDomainsCounter);
|
|
}
|
|
|
|
/**
|
|
* @brief Implements vkGetPastPresentationTimingEXT Vulkan entrypoint.
|
|
*/
|
|
VWL_VKAPI_CALL(VkResult)
|
|
wsi_layer_vkGetPastPresentationTimingEXT(
|
|
VkDevice device, const VkPastPresentationTimingInfoEXT *pPastPresentationTimingInfo,
|
|
VkPastPresentationTimingPropertiesEXT *pPastPresentationTimingProperties) VWL_API_POST
|
|
{
|
|
UNUSED(device);
|
|
UNUSED(pPastPresentationTimingInfo);
|
|
UNUSED(pPastPresentationTimingProperties);
|
|
VkResult result = VK_SUCCESS;
|
|
return result;
|
|
}
|
|
#endif /* VULKAN_WSI_LAYER_EXPERIMENTAL */
|