mirror of
https://github.com/wolfpld/tracy
synced 2025-05-04 06:13:53 +00:00
Implement automatic GPU clock drift calculation.
This commit is contained in:
parent
401b879ece
commit
a642abfde0
@ -5264,6 +5264,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( size_t i=0; i<gpuData.size(); i++ )
|
for( size_t i=0; i<gpuData.size(); i++ )
|
||||||
{
|
{
|
||||||
|
const auto& timeline = gpuData[i]->timeline;
|
||||||
const bool isVulkan = gpuData[i]->thread == 0;
|
const bool isVulkan = gpuData[i]->thread == 0;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
if( isVulkan )
|
if( isVulkan )
|
||||||
@ -5276,10 +5277,47 @@ void View::DrawOptions()
|
|||||||
}
|
}
|
||||||
SmallCheckbox( buf, &Vis( gpuData[i] ).visible );
|
SmallCheckbox( buf, &Vis( gpuData[i] ).visible );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "%s top level zones", RealToString( gpuData[i]->timeline.size(), true ) );
|
ImGui::TextDisabled( "%s top level zones", RealToString( timeline.size(), true ) );
|
||||||
ImGui::TreePush();
|
ImGui::TreePush();
|
||||||
auto& drift = GpuDrift( gpuData[i] );
|
auto& drift = GpuDrift( gpuData[i] );
|
||||||
|
ImGui::SetNextItemWidth( 120 );
|
||||||
ImGui::InputInt( "Drift (ns/s)", &drift );
|
ImGui::InputInt( "Drift (ns/s)", &drift );
|
||||||
|
if( timeline.size() > 1 )
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
|
if( ImGui::Button( ICON_FA_ROBOT " Auto" ) )
|
||||||
|
#else
|
||||||
|
if( ImGui::Button( "Auto" ) )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
double gsum = 0;
|
||||||
|
size_t lastidx = 0;
|
||||||
|
for( size_t j=0; j<timeline.size(); j++ )
|
||||||
|
{
|
||||||
|
if( timeline[j]->gpuEnd >= 0 )
|
||||||
|
{
|
||||||
|
lastidx = j;
|
||||||
|
gsum += timeline[j]->gpuStart - timeline[j]->cpuStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( lastidx > 0 )
|
||||||
|
{
|
||||||
|
const double cavg = ( timeline[lastidx]->cpuStart + timeline.front()->cpuStart ) * 0.5;
|
||||||
|
const double gavg = gsum / double( lastidx );
|
||||||
|
double cov = 0;
|
||||||
|
double var = 0;
|
||||||
|
for( size_t j=0; j<lastidx; j++ )
|
||||||
|
{
|
||||||
|
const auto csub = timeline[j]->cpuStart - cavg;
|
||||||
|
cov += csub * ( timeline[j]->gpuStart - timeline[j]->cpuStart - gavg );
|
||||||
|
var += csub * csub;
|
||||||
|
}
|
||||||
|
const double beta = cov / var;
|
||||||
|
drift = int( 1000000000 * -beta );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user