diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-28 10:27:58 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-28 10:29:16 -0400 |
commit | 535529ca98954fed250d20a9b0742df74833ecc7 (patch) | |
tree | 334a14aea86c62ba340224fe61390bcce8d1a530 | |
parent | 72d043d51f0d00366d5c170610ca5d60aae78c68 (diff) | |
download | gtk+-535529ca98954fed250d20a9b0742df74833ecc7.tar.gz |
vulkan: Measure gpu time
Since this value is only meaningful if we wait for the rendering
to end, we only keep this timer if GSK_RENDERING_MODE=sync is
enabled.
-rw-r--r-- | gsk/gskvulkanrender.c | 14 | ||||
-rw-r--r-- | gsk/gskvulkanrenderer.c | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c index cddc331645..ee0b59f7b3 100644 --- a/gsk/gskvulkanrender.c +++ b/gsk/gskvulkanrender.c @@ -56,6 +56,7 @@ struct _GskVulkanRender GSList *cleanup_images; GQuark render_pass_counter; + GQuark gpu_time_timer; }; static void @@ -208,6 +209,7 @@ gsk_vulkan_render_new (GskRenderer *renderer, #ifdef G_ENABLE_DEBUG self->render_pass_counter = g_quark_from_static_string ("render-passes"); + self->gpu_time_timer = g_quark_from_static_string ("gpu-time"); #endif return self; @@ -537,6 +539,11 @@ gsk_vulkan_render_draw (GskVulkanRender *self, { GList *l; +#ifdef G_ENABLE_DEBUG + if (GSK_RENDER_MODE_CHECK (SYNC)) + gsk_profiler_timer_begin (gsk_renderer_get_profiler (self->renderer), self->gpu_time_timer); +#endif + gsk_vulkan_render_prepare_descriptor_sets (self, sampler); for (l = self->render_passes; l; l = l->next) @@ -566,11 +573,18 @@ gsk_vulkan_render_draw (GskVulkanRender *self, if (GSK_RENDER_MODE_CHECK (SYNC)) { + GskProfiler *profiler; + gint64 gpu_time; + GSK_VK_CHECK (vkWaitForFences, gdk_vulkan_context_get_device (self->vulkan), 1, &self->fence, VK_TRUE, INT64_MAX); + + profiler = gsk_renderer_get_profiler (self->renderer); + gpu_time = gsk_profiler_timer_end (profiler, self->gpu_time_timer); + gsk_profiler_timer_set (profiler, self->gpu_time_timer, gpu_time); } } diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c index 7a422dc66d..20c204f8dd 100644 --- a/gsk/gskvulkanrenderer.c +++ b/gsk/gskvulkanrenderer.c @@ -314,6 +314,8 @@ gsk_vulkan_renderer_init (GskVulkanRenderer *self) self->profile_counters.fallback_pixels = gsk_profiler_add_counter (profiler, "fallback-pixels", "Fallback pixels", TRUE); self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE); + if (GSK_RENDER_MODE_CHECK (SYNC)) + self->profile_timers.gpu_time = gsk_profiler_add_timer (profiler, "gpu-time", "GPU time", FALSE, TRUE); #endif } |