make profiler work on windows

This commit is contained in:
Ivan 'provod' Avdeev 2021-10-19 10:10:22 -07:00 committed by Ivan Avdeev
parent 084e35b3fd
commit debf9bd2e6
3 changed files with 17 additions and 3 deletions

2
ref_vk/profiler.c Normal file
View File

@ -0,0 +1,2 @@
#define APROF_IMPLEMENT
#include "profiler.h"

View File

@ -68,6 +68,16 @@ static uint64_t _aprof_time_now( void ) {
clock_gettime(CLOCK_MONOTONIC, &tp);
return tp.tv_nsec + tp.tv_sec * 1000000000ull;
}
#elif defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>
static LARGE_INTEGER _aprof_frequency;
static uint64_t _aprof_time_now( void ) {
LARGE_INTEGER pc;
QueryPerformanceCounter(&pc);
return pc.QuadPart * 1000000000ull / _aprof_frequency.QuadPart;
}
#else
#error aprof is not implemented for this os
#endif
@ -75,6 +85,11 @@ static uint64_t _aprof_time_now( void ) {
aprof_state_t g_aprof = {0};
aprof_scope_id_t aprof_scope_init(const char *scope_name) {
#if defined(_WIN32)
if (_aprof_frequency.QuadPart == 0)
QueryPerformanceFrequency(&_aprof_frequency);
#endif
if (g_aprof.num_scopes == APROF_MAX_SCOPES)
return -1;

View File

@ -28,9 +28,6 @@
#include <string.h>
#include <errno.h>
#define APROF_IMPLEMENT
#include "profiler.h"
#define XVK_PARSE_VERSION(v) \
VK_VERSION_MAJOR(v), \
VK_VERSION_MINOR(v), \