Merge 'present_id2 dependency handling in present_timing extension' into 'main'

See merge request mesa/vulkan-wsi-layer!207
This commit is contained in:
Rosen Zhelev 2025-09-29 16:11:01 +01:00
commit e1e184300e
2 changed files with 24 additions and 32 deletions

View file

@ -191,36 +191,26 @@ wsi_layer_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
VkResult ret = VK_SUCCESS; VkResult ret = VK_SUCCESS;
struct present_ids const uint64_t *p_present_ids{ nullptr };
auto *present_id2_ext =
util::find_extension<VkPresentId2KHR>(VK_STRUCTURE_TYPE_PRESENT_ID_2_KHR, pPresentInfo->pNext);
if (present_id2_ext != nullptr)
{ {
uint32_t ids_num{ 0 }; p_present_ids = present_id2_ext->pPresentIds;
const uint64_t *p_present_ids{ nullptr };
bool has_ids()
{
return ids_num > 0;
}
};
present_ids present_ids{};
if (device_data.is_present_id2_enabled())
{
auto *ext2 = util::find_extension<VkPresentIdKHR>(VK_STRUCTURE_TYPE_PRESENT_ID_2_KHR, pPresentInfo->pNext);
if (ext2 != nullptr)
{
present_ids.ids_num = ext2->swapchainCount;
present_ids.p_present_ids = ext2->pPresentIds;
}
} }
else
if (!present_ids.has_ids())
{ {
auto *ext = util::find_extension<VkPresentIdKHR>(VK_STRUCTURE_TYPE_PRESENT_ID_KHR, pPresentInfo->pNext); auto *ext = util::find_extension<VkPresentIdKHR>(VK_STRUCTURE_TYPE_PRESENT_ID_KHR, pPresentInfo->pNext);
if (ext != nullptr) if (ext != nullptr)
{ {
present_ids.ids_num = ext->swapchainCount; p_present_ids = ext->pPresentIds;
present_ids.p_present_ids = ext->pPresentIds; /* If a VkPresentIdKHR structure is included in the pNext chain, and the presentId feature is not enabled,
* each presentIds entry in that structure must be NULL */
if (p_present_ids != nullptr)
{
assert(device_data.is_present_id_enabled());
}
} }
} }
@ -244,9 +234,16 @@ wsi_layer_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
uint64_t present_id = 0; /* No present ID by default */ uint64_t present_id = 0; /* No present ID by default */
if (present_ids.p_present_ids && present_ids.ids_num == pPresentInfo->swapchainCount) if (p_present_ids != nullptr)
{ {
present_id = present_ids.p_present_ids[i]; present_id = p_present_ids[i];
/* If a VkPresentId2KHR structure is included in the pNext chain, and the presentId2 feature is not enabled,
* each presentIds entry in that structure must be zero. */
if (present_id2_ext && present_id != 0)
{
assert(device_data.is_present_id2_enabled());
}
} }
wsi::swapchain_presentation_parameters present_params{}; wsi::swapchain_presentation_parameters present_params{};

View file

@ -64,12 +64,7 @@ wsi_ext_present_timing::wsi_ext_present_timing(const util::allocator &allocator,
, m_present_semaphore(allocator) , m_present_semaphore(allocator)
, m_timestamp_period(0.f) , m_timestamp_period(0.f)
{ {
if (!m_device.is_present_id_enabled()) assert(m_device.is_device_extension_enabled(VK_KHR_PRESENT_ID_2_EXTENSION_NAME));
{
WSI_LOG_ERROR(VK_EXT_PRESENT_TIMING_EXTENSION_NAME
" enabled but required extension " VK_KHR_PRESENT_ID_EXTENSION_NAME " is not enabled.");
}
VkPhysicalDeviceProperties2KHR physical_device_properties{}; VkPhysicalDeviceProperties2KHR physical_device_properties{};
physical_device_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; physical_device_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
auto &inst = layer::instance_private_data::get(m_device.physical_device); auto &inst = layer::instance_private_data::get(m_device.physical_device);