[PATCH] winex11: Add simple fps counter for Vulkan.

Józef Kucia jkucia at codeweavers.com
Wed Aug 15 03:43:23 CDT 2018


The fps counter is implemented in winex11 because winevulkan thunks can
be bypassed.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/winex11.drv/vulkan.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c
index 5de855715f36..063281d3d542 100644
--- a/dlls/winex11.drv/vulkan.c
+++ b/dlls/winex11.drv/vulkan.c
@@ -41,6 +41,7 @@
 #include "wine/vulkan_driver.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
+WINE_DECLARE_DEBUG_CHANNEL(fps);
 
 #ifdef SONAME_LIBVULKAN
 
@@ -513,8 +514,34 @@ static VkResult X11DRV_vkGetSwapchainImagesKHR(VkDevice device,
 
 static VkResult X11DRV_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *present_info)
 {
+    VkResult res;
+
     TRACE("%p, %p\n", queue, present_info);
-    return pvkQueuePresentKHR(queue, present_info);
+
+    res = pvkQueuePresentKHR(queue, present_info);
+
+    if (TRACE_ON(fps))
+    {
+        static unsigned long frames, frames_total;
+        static long prev_time, start_time;
+        DWORD time;
+
+        time = GetTickCount();
+        frames++;
+        frames_total++;
+        if (time - prev_time > 1500)
+        {
+            TRACE_(fps)("%p @ approx %.2ffps, total %.2ffps\n",
+                    queue, 1000.0 * frames / (time - prev_time),
+                    1000.0 * frames_total / (time - start_time));
+            prev_time = time;
+            frames = 0;
+            if (!start_time)
+                start_time = time;
+        }
+    }
+
+    return res;
 }
 
 static const struct vulkan_funcs vulkan_funcs =
-- 
2.16.4




More information about the wine-devel mailing list