mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2025-12-30 06:00:10 +01:00
Merge 'Use the KHR version for vkGetCalibratedTimestamps' into 'main'
See merge request mesa/vulkan-wsi-layer!156
This commit is contained in:
commit
089418f0a8
5 changed files with 33 additions and 29 deletions
|
|
@ -31,18 +31,13 @@
|
|||
#include <wsi/extensions/present_timing.hpp>
|
||||
#include <wsi/swapchain_base.hpp>
|
||||
|
||||
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
||||
VWL_VKAPI_CALL(VkResult)
|
||||
wsi_layer_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount,
|
||||
wsi_layer_vkGetCalibratedTimestampsKHR(VkDevice device, uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps,
|
||||
uint64_t *pMaxDeviation) VWL_API_POST
|
||||
{
|
||||
auto &device_data = layer::device_private_data::get(device);
|
||||
auto get_calibrated_timestamps =
|
||||
device_data.disp.get_fn<PFN_vkGetCalibratedTimestampsEXT>("PFN_vkGetCalibratedTimestampsEXT").has_value() ?
|
||||
device_data.disp.get_fn<PFN_vkGetCalibratedTimestampsEXT>("vkGetCalibratedTimestampsEXT") :
|
||||
device_data.disp.get_fn<PFN_vkGetCalibratedTimestampsEXT>("vkGetCalibratedTimestampsKHR");
|
||||
assert(get_calibrated_timestamps.has_value());
|
||||
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
||||
struct stage_local_index_and_offset
|
||||
{
|
||||
uint32_t index;
|
||||
|
|
@ -90,7 +85,8 @@ wsi_layer_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount,
|
|||
time_stamp_info[i].timeDomain = calibrated_time.time_domain;
|
||||
}
|
||||
}
|
||||
TRY_LOG_CALL((*get_calibrated_timestamps)(device, timestampCount, &time_stamp_info[0], pTimestamps, pMaxDeviation));
|
||||
TRY_LOG_CALL(device_data.disp.GetCalibratedTimestampsKHR(device, timestampCount, &time_stamp_info[0], pTimestamps,
|
||||
pMaxDeviation));
|
||||
|
||||
/* Loop through the calibration_index_and_offset vector and update the timestamps that are stage local
|
||||
with its respective offset. */
|
||||
|
|
@ -99,14 +95,13 @@ wsi_layer_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount,
|
|||
pTimestamps[iter.index] += iter.calibration_offset;
|
||||
}
|
||||
return VK_SUCCESS;
|
||||
#endif /* VULKAN_WSI_LAYER_EXPERIMENTAL */
|
||||
return (*get_calibrated_timestamps)(device, timestampCount, pTimestampInfos, pTimestamps, pMaxDeviation);
|
||||
}
|
||||
|
||||
VWL_VKAPI_CALL(VkResult)
|
||||
wsi_layer_vkGetCalibratedTimestampsKHR(VkDevice device, uint32_t timestampCount,
|
||||
wsi_layer_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps,
|
||||
uint64_t *pMaxDeviation) VWL_API_POST
|
||||
{
|
||||
return wsi_layer_vkGetCalibratedTimestampsEXT(device, timestampCount, pTimestampInfos, pTimestamps, pMaxDeviation);
|
||||
}
|
||||
return wsi_layer_vkGetCalibratedTimestampsKHR(device, timestampCount, pTimestampInfos, pTimestamps, pMaxDeviation);
|
||||
}
|
||||
#endif /* VULKAN_WSI_LAYER_EXPERIMENTAL */
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#pragma once
|
||||
#include "util/macros.hpp"
|
||||
|
||||
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
||||
VWL_VKAPI_CALL(VkResult)
|
||||
wsi_layer_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps,
|
||||
|
|
@ -40,4 +41,5 @@ wsi_layer_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount,
|
|||
VWL_VKAPI_CALL(VkResult)
|
||||
wsi_layer_vkGetCalibratedTimestampsKHR(VkDevice device, uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps,
|
||||
uint64_t *pMaxDeviation) VWL_API_POST;
|
||||
uint64_t *pMaxDeviation) VWL_API_POST;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -562,6 +562,12 @@ wsi_layer_vkGetDeviceProcAddr(VkDevice device, const char *funcName) VWL_API_POS
|
|||
GET_PROC_ADDR(vkGetSwapchainTimingPropertiesEXT);
|
||||
GET_PROC_ADDR(vkGetSwapchainTimeDomainPropertiesEXT);
|
||||
GET_PROC_ADDR(vkGetPastPresentationTimingEXT);
|
||||
GET_PROC_ADDR(vkGetCalibratedTimestampsKHR);
|
||||
if (layer::device_private_data::get(device).is_device_extension_enabled(
|
||||
VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME))
|
||||
{
|
||||
GET_PROC_ADDR(vkGetCalibratedTimestampsEXT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
GET_PROC_ADDR(vkDestroyDevice);
|
||||
|
|
@ -582,14 +588,6 @@ wsi_layer_vkGetDeviceProcAddr(VkDevice device, const char *funcName) VWL_API_POS
|
|||
{
|
||||
GET_PROC_ADDR(vkReleaseSwapchainImagesEXT);
|
||||
}
|
||||
if (layer::device_private_data::get(device).is_device_extension_enabled(VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME))
|
||||
{
|
||||
GET_PROC_ADDR(vkGetCalibratedTimestampsEXT);
|
||||
}
|
||||
if (layer::device_private_data::get(device).is_device_extension_enabled(VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME))
|
||||
{
|
||||
GET_PROC_ADDR(vkGetCalibratedTimestampsKHR);
|
||||
}
|
||||
#if VULKAN_WSI_LAYER_EXPERIMENTAL
|
||||
if (layer::device_private_data::get(device).is_device_extension_enabled(VK_KHR_PRESENT_WAIT_EXTENSION_NAME))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -436,7 +436,9 @@ private:
|
|||
false, GetImageSparseMemoryRequirements2KHR) \
|
||||
/* VK_EXT_swapchain_maintenance1 */ \
|
||||
EP(ReleaseSwapchainImagesEXT, VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME, VK_API_VERSION_1_1, false, ) \
|
||||
/* VK_EXT_calibrated_timestamps */ \
|
||||
EP(GetCalibratedTimestampsEXT, VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME, API_VERSION_MAX, false, ) \
|
||||
/* VK_KHR_calibrated_timestamps */ \
|
||||
EP(GetCalibratedTimestampsKHR, VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME, API_VERSION_MAX, false, ) \
|
||||
/* Custom entrypoints */ \
|
||||
DEVICE_ENTRYPOINTS_LIST_EXPANSION(EP)
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ struct swapchain_calibrated_time
|
|||
class swapchain_time_domain
|
||||
{
|
||||
public:
|
||||
swapchain_time_domain(VkPresentStageFlagsEXT presentStages)
|
||||
: m_present_stages(presentStages)
|
||||
swapchain_time_domain(VkPresentStageFlagsEXT present_stage)
|
||||
: m_present_stage(present_stage)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -101,18 +101,18 @@ public:
|
|||
|
||||
VkPresentStageFlagsEXT get_present_stages()
|
||||
{
|
||||
return m_present_stages;
|
||||
return m_present_stage;
|
||||
}
|
||||
|
||||
private:
|
||||
VkPresentStageFlagsEXT m_present_stages;
|
||||
VkPresentStageFlagsEXT m_present_stage;
|
||||
};
|
||||
|
||||
class vulkan_time_domain : public swapchain_time_domain
|
||||
{
|
||||
public:
|
||||
vulkan_time_domain(VkPresentStageFlagsEXT presentStages, VkTimeDomainKHR time_domain)
|
||||
: swapchain_time_domain(presentStages)
|
||||
vulkan_time_domain(VkPresentStageFlagsEXT present_stage, VkTimeDomainKHR time_domain)
|
||||
: swapchain_time_domain(present_stage)
|
||||
, m_time_domain(time_domain)
|
||||
{
|
||||
}
|
||||
|
|
@ -148,7 +148,14 @@ public:
|
|||
*/
|
||||
bool add_time_domain(util::unique_ptr<swapchain_time_domain> time_domain);
|
||||
|
||||
VkResult calibrate(VkPresentStageFlagBitsEXT presentStages, swapchain_calibrated_time *calibrated_time);
|
||||
/**
|
||||
* @brief The calibrate returns a Vulkan time domain + an offset
|
||||
*
|
||||
* @param present_stage The present stage to calibrate
|
||||
* @param calibrated_time The calibrated time output
|
||||
* @return VK_SUCCESS when calibrated successfully VK_ERROR_OUT_OF_HOST_MEMORY otherwise.
|
||||
*/
|
||||
VkResult calibrate(VkPresentStageFlagBitsEXT present_stage, swapchain_calibrated_time *calibrated_time);
|
||||
|
||||
/**
|
||||
* @brief Get swapchain time domain properties.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue