demotool/ui-profiling.hh

78 lines
1.6 KiB
C++
Raw Normal View History

2017-10-01 11:37:04 +02:00
#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
2017-10-01 11:37:04 +02:00
struct T_ProfilerSamples
{
float sum;
uint32_t nSamples;
};
struct T_Profiler
{
static constexpr uint32_t Samples = 4;
static constexpr uint32_t History = 4;
2017-10-01 12:48:55 +02:00
static constexpr uint32_t Invalid = 0xffffffff;
2017-10-01 11:37:04 +02:00
~T_Profiler( );
2017-10-01 11:37:04 +02:00
void clear( );
void startFrame( );
2017-11-03 11:55:26 +01:00
void start( T_String const& section );
void end( T_String const& section );
2017-10-01 12:48:55 +02:00
void endFrame( );
2017-10-01 11:37:04 +02:00
uint32_t sections( ) const noexcept
{ return sections_.size( ); }
2017-11-03 11:55:26 +01:00
T_String const& nameOf(
const uint32_t section ) const
2017-10-01 11:37:04 +02:00
{ return sections_[ section ]; }
2017-11-03 11:55:26 +01:00
float durationOf( const uint32_t section ) const
2017-10-01 12:48:55 +02:00
{ return secDurations_[ section ]; }
2017-11-03 11:55:26 +01:00
float startOf( const uint32_t section ) const
2017-10-01 12:48:55 +02:00
{ return secStarts_[ section ]; }
2017-10-01 11:37:04 +02:00
2017-10-01 14:10:00 +02:00
void makeUI( );
bool& uiEnabled( ) { return uiEnabled_; }
2017-10-01 11:37:04 +02:00
private:
using T_SamplesList_ = T_StaticArray< T_ProfilerSamples , History >;
2017-11-03 11:55:26 +01:00
using T_Data_ = T_Array< T_SamplesList_ >;
2017-10-01 11:37:04 +02:00
void extendGPUQueries( ) noexcept;
static void addSample(
T_SamplesList_& list ,
uint64_t duration ) noexcept;
2017-11-03 11:55:26 +01:00
uint32_t find( T_String const& section ) const;
static float computeDuration(
T_SamplesList_ const& list ) noexcept;
2017-10-01 12:48:55 +02:00
uint32_t previous_;
uint32_t current_;
2017-10-01 11:37:04 +02:00
2017-11-03 11:55:26 +01:00
T_Array< T_String > sections_;
T_Array< uint32_t > chain_;
T_Array< uint32_t > parents_;
2017-10-01 11:37:04 +02:00
T_Data_ samples_;
T_Array< uint64_t > cpuStarts_;
2017-10-01 12:48:55 +02:00
T_Array< float > secCPUDurations_;
T_Array< float > secGPUDurations_;
2017-11-03 11:55:26 +01:00
T_Array< float > secDurations_;
T_Array< float > secStarts_;
2017-10-01 14:10:00 +02:00
bool uiEnabled_ = false;
2017-12-24 18:40:34 +01:00
T_Array< bool > displayed_;
T_Array< GLuint > gpuQueries_{ T_Array< GLuint >( 64 ) };
T_Data_ gpuSamples_;
2017-10-01 11:37:04 +02:00
};
2017-10-01 12:48:55 +02:00