From 4a48c09a3982a449885c380819c5953a7f061717 Mon Sep 17 00:00:00 2001 From: Ginu Jacob Date: Thu, 22 Jan 2026 11:26:21 +0000 Subject: [PATCH] Add wait flag on querying present timing queue operations end timestamp Signed-off-by: Ginu Jacob Change-Id: I10064e5144d542e41dd36b4dd7d5555a215b2a31 --- CMakeLists.txt | 6 ++++++ README.md | 6 ++++++ wsi/extensions/present_timing.cpp | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee96bfc..957dee0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ set(WSIALLOC_MEMORY_HEAP_NAME "linux,cma" CACHE STRING "Heap name used by the dm option(BUILD_WSI_DISPLAY_SUPPORT_FORMAT_MODIFIERS "Build with support for format modifiers in VK_KHR_display" ON) option(VULKAN_WSI_LAYER_EXPERIMENTAL "Enable the Vulkan WSI Experimental features" OFF) option(ENABLE_WAYLAND_FIFO_PRESENTATION_THREAD "Enable the non-conformant FIFO presentation thread implementation in the Wayland backend" OFF) +option(ENABLE_WAIT_FOR_QUERY_RESULT "Enable waiting for result while querying present timing queue operations end timestamp" OFF) # Enables the layer to pass frame boundary events if the ICD or layers below have support for it by # making use of the VK_EXT_frame_boundary extension. If the application itself makes use of the @@ -357,6 +358,11 @@ else() add_definitions("-DENABLE_INSTRUMENTATION=0") endif() +if(ENABLE_WAIT_FOR_QUERY_RESULT) + target_compile_definitions(${PROJECT_NAME} PRIVATE WAIT_FOR_QUERY_RESULT_ENABLED=1) +else() + target_compile_definitions(${PROJECT_NAME} PRIVATE WAIT_FOR_QUERY_RESULT_ENABLED=0) +endif() target_link_libraries(${PROJECT_NAME} ${LINK_WSI_LIBS}) add_custom_target(manifest_json ALL COMMAND diff --git a/README.md b/README.md index bccd447..082677a 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,12 @@ for applications that do not make use of this extension. In order to enable this feature `-DENABLE_INSTRUMENTATION=1` option can be passed at build time. +### Build with wait for present timing query results + +The option `-DENABLE_WAIT_FOR_QUERY_RESULT=1` provides a way to wait for +present timing queue operations end bit timestamps to be available when +queried. + ### Debug builds The layer can be built with different values of the CMAKE_BUILD_TYPE variable. diff --git a/wsi/extensions/present_timing.cpp b/wsi/extensions/present_timing.cpp index 9c670e3..4b6aa1a 100644 --- a/wsi/extensions/present_timing.cpp +++ b/wsi/extensions/present_timing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024-2025 Arm Limited. + * Copyright (c) 2024-2026 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -168,9 +168,11 @@ VkResult wsi_ext_present_timing::write_pending_results() } uint64_t timestamp; + VkQueryResultFlags wait_for_result = WAIT_FOR_QUERY_RESULT_ENABLED ? VK_QUERY_RESULT_WAIT_BIT : 0; VkResult res = m_device.disp.GetQueryPoolResults( m_device.device, m_queue_family_resources.m_query_pool, slot.m_image_index, 1u, sizeof(timestamp), - ×tamp, static_cast(0), static_cast(VK_QUERY_RESULT_64_BIT)); + ×tamp, static_cast(0), + static_cast(VK_QUERY_RESULT_64_BIT | wait_for_result)); if (res != VK_SUCCESS && res != VK_NOT_READY) { return res;