vk: profiler: fixup time scaling on windows
This commit is contained in:
parent
22d4202ad9
commit
b4b63492f2
|
@ -40,10 +40,10 @@ void aprof_scope_event(aprof_scope_id_t, int begin);
|
|||
uint32_t aprof_scope_frame( void );
|
||||
uint64_t aprof_time_now_ns( void );
|
||||
|
||||
#ifdef WIN32
|
||||
uint64_t aprof_time_now_native_divider( void );
|
||||
#if defined(_WIN32)
|
||||
uint64_t aprof_time_platform_to_ns( uint64_t );
|
||||
#else
|
||||
#define aprof_time_now_native_divider() 1
|
||||
#define aprof_time_platform_to_ns(time) (time)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
@ -122,8 +122,9 @@ uint64_t aprof_time_now_ns( void ) {
|
|||
QueryPerformanceCounter(&pc);
|
||||
return pc.QuadPart * 1000000000ull / _aprof_frequency.QuadPart;
|
||||
}
|
||||
uint64_t aprof_time_now_native_divider( void ) {
|
||||
return _aprof_frequency.QuadPart;
|
||||
|
||||
uint64_t aprof_time_platform_to_ns( uint64_t platform_time ) {
|
||||
return platform_time * 1000000000ull / _aprof_frequency.QuadPart;
|
||||
}
|
||||
#else
|
||||
#error aprof is not implemented for this os
|
||||
|
|
|
@ -56,7 +56,7 @@ static uint64_t getGpuTimestampOffsetNs( const vk_query_pool_t *pool ) {
|
|||
{
|
||||
.sType = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT,
|
||||
.pNext = NULL,
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32)
|
||||
.timeDomain = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT,
|
||||
#else
|
||||
.timeDomain = VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT,
|
||||
|
@ -68,7 +68,7 @@ static uint64_t getGpuTimestampOffsetNs( const vk_query_pool_t *pool ) {
|
|||
uint64_t max_deviation[2] = {0};
|
||||
vkGetCalibratedTimestampsEXT(vk_core.device, 2, cti, timestamps, max_deviation);
|
||||
|
||||
const uint64_t cpu = (double)timestamps[1] / aprof_time_now_native_divider();
|
||||
const uint64_t cpu = aprof_time_platform_to_ns(timestamps[1]);
|
||||
const uint64_t gpu = (double)timestamps[0] * vk_core.physical_device.properties.limits.timestampPeriod;
|
||||
return cpu - gpu;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue