From a66c44a266d85a601ae7ae95607afc00bddb1ef3 Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Sat, 18 Mar 2023 13:28:14 -0700 Subject: [PATCH] vk: convert query timestamps to ns also, fix linux build --- ref/vk/vk_querypool.c | 4 ++++ ref/vk/vk_staging.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ref/vk/vk_querypool.c b/ref/vk/vk_querypool.c index 62d48026..34a43a3f 100644 --- a/ref/vk/vk_querypool.c +++ b/ref/vk/vk_querypool.c @@ -40,4 +40,8 @@ void R_VkQueryPoolGetFrameResults( vk_query_pool_t *pool ) { return; vkGetQueryPoolResults(vk_core.device, pool->pool, 0, pool->used, pool->used * sizeof(uint64_t), pool->results, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT); + + for (int i = 0; i < pool->used; ++i) { + pool->results[i] *= vk_core.physical_device.properties.limits.timestampPeriod; + } } diff --git a/ref/vk/vk_staging.c b/ref/vk/vk_staging.c index 3ecfc81a..9cd0c32b 100644 --- a/ref/vk/vk_staging.c +++ b/ref/vk/vk_staging.c @@ -64,16 +64,18 @@ void R_VkStagingFlushSync( void ) { //gEngine.Con_Reportf(S_WARN "flushing staging buffer img count=%d\n", g_staging.images.count); - const VkSubmitInfo subinfo = { - .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, - .commandBufferCount = 1, - .pCommandBuffers = &cmdbuf, - }; + { + const VkSubmitInfo subinfo = { + .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, + .commandBufferCount = 1, + .pCommandBuffers = &cmdbuf, + }; - // TODO wait for previous command buffer completion. Why: we might end up writing into the same dst + // TODO wait for previous command buffer completion. Why: we might end up writing into the same dst - XVK_CHECK(vkQueueSubmit(vk_core.queue, 1, &subinfo, VK_NULL_HANDLE)); - XVK_CHECK(vkQueueWaitIdle(vk_core.queue)); + XVK_CHECK(vkQueueSubmit(vk_core.queue, 1, &subinfo, VK_NULL_HANDLE)); + XVK_CHECK(vkQueueWaitIdle(vk_core.queue)); + } g_staging.buffers.count = 0; g_staging.images.count = 0;