From 4eb8acc973cd4295cf5b9e6e5a082346045d42e3 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 10 Nov 2019 02:27:46 +0100 Subject: [PATCH] Magic vectors in automatic GPU drift detection. --- server/TracyView.cpp | 52 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index badecf6d..d3cc5102 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -7039,12 +7039,27 @@ void View::DrawOptions() #endif { size_t lastidx = 0; - for( size_t j=timeline.size()-1; j > 0; j-- ) + if( timeline.is_magic() ) { - if( timeline[j]->GpuEnd() >= 0 ) + auto& tl = *((Vector*)&timeline); + for( size_t j=tl.size()-1; j > 0; j-- ) { - lastidx = j; - break; + if( tl[j].GpuEnd() >= 0 ) + { + lastidx = j; + break; + } + } + } + else + { + for( size_t j=timeline.size()-1; j > 0; j-- ) + { + if( timeline[j]->GpuEnd() >= 0 ) + { + lastidx = j; + break; + } } } @@ -7054,16 +7069,33 @@ void View::DrawOptions() std::uniform_int_distribution dist( 0, lastidx - 1 ); float slopes[NumSlopes]; size_t idx = 0; - do + if( timeline.is_magic() ) { - const auto p0 = dist( gen ); - const auto p1 = dist( gen ); - if( p0 != p1 ) + auto& tl = *((Vector*)&timeline); + do { - slopes[idx++] = float( 1.0 - double( timeline[p1]->GpuStart() - timeline[p0]->GpuStart() ) / double( timeline[p1]->CpuStart() - timeline[p0]->CpuStart() ) ); + const auto p0 = dist( gen ); + const auto p1 = dist( gen ); + if( p0 != p1 ) + { + slopes[idx++] = float( 1.0 - double( tl[p1].GpuStart() - tl[p0].GpuStart() ) / double( tl[p1].CpuStart() - tl[p0].CpuStart() ) ); + } } + while( idx < NumSlopes ); + } + else + { + do + { + const auto p0 = dist( gen ); + const auto p1 = dist( gen ); + if( p0 != p1 ) + { + slopes[idx++] = float( 1.0 - double( timeline[p1]->GpuStart() - timeline[p0]->GpuStart() ) / double( timeline[p1]->CpuStart() - timeline[p0]->CpuStart() ) ); + } + } + while( idx < NumSlopes ); } - while( idx < NumSlopes ); std::sort( slopes, slopes+NumSlopes ); drift = int( 1000000000 * -slopes[NumSlopes/2] ); }