summaryrefslogtreecommitdiffstats
path: root/src/vulkan/overlay-layer/overlay.cpp
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2019-02-25 17:48:14 +0000
committerLionel Landwerlin <[email protected]>2019-02-28 12:40:57 +0000
commitadd4b8930a219008731f76830ffc12b260b7d1da (patch)
tree1f48e8a67bcc01055db853ca3e81472073239431 /src/vulkan/overlay-layer/overlay.cpp
parentb6b275212dc4eef9014f9e8bd247b72debde4b8b (diff)
vulkan/overlay: add support for fps output in file
Also make the sampling period configurable. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/vulkan/overlay-layer/overlay.cpp')
-rw-r--r--src/vulkan/overlay-layer/overlay.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/vulkan/overlay-layer/overlay.cpp b/src/vulkan/overlay-layer/overlay.cpp
index c6f49c2ad75..a2f6f24bdec 100644
--- a/src/vulkan/overlay-layer/overlay.cpp
+++ b/src/vulkan/overlay-layer/overlay.cpp
@@ -211,6 +211,8 @@ static struct instance_data *new_instance_data(VkInstance instance)
static void destroy_instance_data(struct instance_data *data)
{
+ if (data->params.output_file)
+ fclose(data->params.output_file);
unmap_object(data->instance);
ralloc_free(data);
}
@@ -338,7 +340,8 @@ static void destroy_swapchain_data(struct swapchain_data *data)
static void snapshot_swapchain_frame(struct swapchain_data *data)
{
- uint64_t now = os_time_get();
+ struct instance_data *instance_data = data->device->instance;
+ uint64_t now = os_time_get(); /* us */
if (data->last_present_time) {
data->frame_times[(data->n_frames - 1) % ARRAY_SIZE(data->frame_times)] =
@@ -346,11 +349,15 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
}
if (data->last_fps_update) {
- double elapsed = (double)(now - data->last_fps_update);
- if (elapsed >= 500000.0) {
- data->fps = ((uint64_t)data->n_frames_since_update * 1000000 / elapsed);
+ double elapsed = (double)(now - data->last_fps_update); /* us */
+ if (elapsed >= instance_data->params.fps_sampling_period) {
+ data->fps = 1000000.0f * data->n_frames_since_update / elapsed;
data->n_frames_since_update = 0;
data->last_fps_update = now;
+ if (instance_data->params.output_file) {
+ fprintf(instance_data->params.output_file, "%.2f\n", data->fps);
+ fflush(instance_data->params.output_file);
+ }
}
} else {
data->last_fps_update = now;