diff options
Diffstat (limited to 'vulkan/libvulkan/swapchain.cpp')
| -rw-r--r-- | vulkan/libvulkan/swapchain.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index 243ea6989c..08eee37af6 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -196,11 +196,22 @@ struct Swapchain { num_images(num_images_), frame_timestamps_enabled(false) { timing.clear(); + ANativeWindow* window = surface.window.get(); + int64_t min_rdur; + int64_t max_rdur; + native_window_get_refresh_cycle_period( + window, + &min_rdur, + &max_rdur); + min_refresh_duration = static_cast<uint64_t>(min_rdur); + max_refresh_duration = static_cast<uint64_t>(max_rdur); } Surface& surface; uint32_t num_images; bool frame_timestamps_enabled; + uint64_t min_refresh_duration; + uint64_t max_refresh_duration; struct Image { Image() : image(VK_NULL_HANDLE), dequeue_fence(-1), dequeued(false) {} @@ -345,9 +356,7 @@ uint32_t get_num_ready_timings(Swapchain& swapchain) { // timestamps to calculate the info that should // be reported to the user: // - // FIXME: GET ACTUAL VALUE RATHER THAN HARD-CODE - // IT: - ti->calculate(16666666); + ti->calculate(swapchain.min_refresh_duration); num_ready++; } break; @@ -1274,13 +1283,13 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) { VKAPI_ATTR VkResult GetRefreshCycleDurationGOOGLE( VkDevice, - VkSwapchainKHR, + VkSwapchainKHR swapchain_handle, VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties) { + Swapchain& swapchain = *SwapchainFromHandle(swapchain_handle); VkResult result = VK_SUCCESS; - // TODO(ianelliott): FULLY IMPLEMENT THIS FUNCTION!!! - pDisplayTimingProperties->minRefreshDuration = 16666666; - pDisplayTimingProperties->maxRefreshDuration = 16666666; + pDisplayTimingProperties->minRefreshDuration = swapchain.min_refresh_duration; + pDisplayTimingProperties->maxRefreshDuration = swapchain.max_refresh_duration; return result; } |