Profiler - Display CPU/GPU times on tooltips

This commit is contained in:
Emmanuel BENOîT 2017-12-24 18:40:12 +01:00
parent 646ec5a423
commit 98ecedfaae
2 changed files with 26 additions and 3 deletions

View file

@ -56,6 +56,8 @@ void T_Profiler::endFrame( )
}
while ( secDurations_.size( ) < n ) {
secCPUDurations_.add( 0 );
secGPUDurations_.add( 0 );
secDurations_.add( 0 );
secStarts_.add( 0 );
}
@ -63,6 +65,8 @@ void T_Profiler::endFrame( )
for ( auto i = 0u ; i < n ; i ++ ) {
const float cpuD = computeDuration( samples_[ i ] );
const float gpuD = computeDuration( gpuSamples_[ i ] );
secCPUDurations_[ i ] = cpuD;
secGPUDurations_[ i ] = gpuD;
secDurations_[ i ] = std::max( cpuD , gpuD );
if ( parents_[ i ] != Invalid ) {
assert( parents_[ i ] < i );
@ -158,11 +162,28 @@ void T_Profiler::makeUI( )
ebcl::T_StringBuilder sb;
char tms[ 12 ];
snprintf( tms , 12 , "%.3f" , secDurations_[ i ] );
sb << sections_[ i ] << " ("
<< tms << "ms)" << '\0';
snprintf( tms , 12 , "%.1f" , secDurations_[ i ] );
sb << sections_[ i ] << " (" << tms << "ms)" << '\0';
ImGui::Checkbox( sb.data( ) , (bool*) &displayed_[ i ] );
ImGui::PopStyleColor( );
if ( ImGui::IsItemHovered( ) ) {
ImGui::BeginTooltip( );
snprintf( tms , 12 , "%.3f" , secDurations_[ i ] );
sb.clear( ) << sections_[ i ] << '\0';
ImGui::PushStyleColor( ImGuiCol_Text , color );
ImGui::Text( "%s" , sb.data( ) );
ImGui::PopStyleColor( );
sb.clear( ) << "\nTime: " << tms << "ms\n\nCPU: ";
snprintf( tms , 12 , "%.3f" , secCPUDurations_[ i ] );
sb << tms << "ms\nGPU: ";
snprintf( tms , 12 , "%.3f" , secGPUDurations_[ i ] );
sb << tms << "ms" << '\0';
ImGui::Text( "%s" , sb.data( ) );
ImGui::EndTooltip( );
}
}
ImGui::EndChild( );
ImGui::SameLine( );

View file

@ -63,6 +63,8 @@ struct T_Profiler
T_Data_ samples_;
T_Array< uint64_t > cpuStarts_;
T_Array< float > secCPUDurations_;
T_Array< float > secGPUDurations_;
T_Array< float > secDurations_;
T_Array< float > secStarts_;