vk: add better scope macro for profiler

also cover synchrnoized slow uploading for staging
This commit is contained in:
Ivan 'provod' Avdeev 2023-03-18 11:36:05 -07:00 committed by Ivan Avdeev
parent 9a5e1fec4a
commit be95b65b22
3 changed files with 16 additions and 7 deletions

View File

@ -14,6 +14,13 @@
#define APROF_SCOPE_BEGIN(scope) \
aprof_scope_event(_aprof_scope_id_##scope, 1)
#define APROF_SCOPE_DECLARE_BEGIN(scope, scope_name) \
static aprof_scope_id_t _aprof_scope_id_##scope = -1; \
if (_aprof_scope_id_##scope == -1) { \
_aprof_scope_id_##scope = aprof_scope_init(scope_name); \
} \
aprof_scope_event(_aprof_scope_id_##scope, 1)
#define APROF_TOKENPASTE(x, y) x ## y
#define APROF_TOKENPASTE2(x, y) APROF_TOKENPASTE(x, y)

View File

@ -2,6 +2,7 @@
#include "vk_buffer.h"
#include "alolcator.h"
#include "vk_commandpool.h"
#include "profiler.h"
#include <memory.h>
@ -52,9 +53,11 @@ void R_VkStagingShutdown(void) {
}
void R_VkStagingFlushSync( void ) {
APROF_SCOPE_DECLARE_BEGIN(__FUNCTION__, __FUNCTION__);
const VkCommandBuffer cmdbuf = R_VkStagingCommit();
if (!cmdbuf)
return;
goto end;
XVK_CHECK(vkEndCommandBuffer(cmdbuf));
g_staging.cmdbuf = VK_NULL_HANDLE;
@ -75,6 +78,9 @@ void R_VkStagingFlushSync( void ) {
g_staging.buffers.count = 0;
g_staging.images.count = 0;
R_FlippingBuffer_Clear(&g_staging.buffer_alloc);
end:
APROF_SCOPE_END(__FUNCTION__);
};
static uint32_t allocateInRing(uint32_t size, uint32_t alignment) {

View File

@ -193,11 +193,7 @@ void R_VkSwapchainShutdown( void ) {
}
r_vk_swapchain_framebuffer_t R_VkSwapchainAcquire( VkSemaphore sem_image_available ) {
static int _aprof_scope_id_scope = -1;
if (_aprof_scope_id_scope == -1)
_aprof_scope_id_scope = aprof_scope_init(__FUNCTION__);
APROF_SCOPE_BEGIN(scope);
APROF_SCOPE_DECLARE_BEGIN(__FUNCTION__, __FUNCTION__);
r_vk_swapchain_framebuffer_t ret = {0};
qboolean force_recreate = false;
@ -237,7 +233,7 @@ r_vk_swapchain_framebuffer_t R_VkSwapchainAcquire( VkSemaphore sem_image_availa
ret.image = g_swapchain.images[ret.index];
ret.view = g_swapchain.image_views[ret.index];
APROF_SCOPE_END(scope);
APROF_SCOPE_END(__FUNCTION__);
return ret;
}