diff --git a/layer/swapchain_api.cpp b/layer/swapchain_api.cpp index bfe8bfb..d23e25b 100644 --- a/layer/swapchain_api.cpp +++ b/layer/swapchain_api.cpp @@ -191,36 +191,26 @@ wsi_layer_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) VkResult ret = VK_SUCCESS; - struct present_ids + const uint64_t *p_present_ids{ nullptr }; + + auto *present_id2_ext = + util::find_extension(VK_STRUCTURE_TYPE_PRESENT_ID_2_KHR, pPresentInfo->pNext); + if (present_id2_ext != nullptr) { - uint32_t ids_num{ 0 }; - 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(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; - } + p_present_ids = present_id2_ext->pPresentIds; } - - if (!present_ids.has_ids()) + else { auto *ext = util::find_extension(VK_STRUCTURE_TYPE_PRESENT_ID_KHR, pPresentInfo->pNext); if (ext != nullptr) { - present_ids.ids_num = ext->swapchainCount; - present_ids.p_present_ids = ext->pPresentIds; + 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 */ - 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{}; diff --git a/wsi/extensions/present_timing.cpp b/wsi/extensions/present_timing.cpp index fe15e86..84605d4 100644 --- a/wsi/extensions/present_timing.cpp +++ b/wsi/extensions/present_timing.cpp @@ -64,12 +64,7 @@ wsi_ext_present_timing::wsi_ext_present_timing(const util::allocator &allocator, , m_present_semaphore(allocator) , m_timestamp_period(0.f) { - if (!m_device.is_present_id_enabled()) - { - WSI_LOG_ERROR(VK_EXT_PRESENT_TIMING_EXTENSION_NAME - " enabled but required extension " VK_KHR_PRESENT_ID_EXTENSION_NAME " is not enabled."); - } - + assert(m_device.is_device_extension_enabled(VK_KHR_PRESENT_ID_2_EXTENSION_NAME)); VkPhysicalDeviceProperties2KHR physical_device_properties{}; physical_device_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; auto &inst = layer::instance_private_data::get(m_device.physical_device);