GAL profiling output is enabled with WXTRACE env variable.

This commit is contained in:
Maciej Suminski 2016-05-02 15:56:17 +02:00
parent c0465e5519
commit 36dd6eb6b3
4 changed files with 87 additions and 26 deletions

View File

@ -45,9 +45,10 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#ifdef __WXDEBUG__ #ifdef PROFILE
#include <profile.h> #include <profile.h>
#endif /* __WXDEBUG__ */ #endif /* PROFILE */
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize, const wxPoint& aPosition, const wxSize& aSize,
@ -142,6 +143,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
if( m_drawing ) if( m_drawing )
return; return;
#ifdef PROFILE
prof_counter totalRealTime;
prof_start( &totalRealTime );
#endif /* PROFILE */
m_drawing = true; m_drawing = true;
KIGFX::PCB_RENDER_SETTINGS* settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_painter->GetSettings() ); KIGFX::PCB_RENDER_SETTINGS* settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_painter->GetSettings() );
@ -167,6 +173,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_gal->DrawCursor( m_viewControls->GetCursorPosition() ); m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
m_gal->EndDrawing(); m_gal->EndDrawing();
#ifdef PROFILE
prof_end( &totalRealTime );
wxLogDebug( wxT( "EDA_DRAW_PANEL_GAL::onPaint(): %.1f ms" ), totalRealTime.msecs() );
#endif /* PROFILE */
m_lastRefresh = wxGetLocalTimeMillis(); m_lastRefresh = wxGetLocalTimeMillis();
m_drawing = false; m_drawing = false;
} }

View File

@ -35,11 +35,11 @@
#include <typeinfo> #include <typeinfo>
#include <confirm.h> #include <confirm.h>
#ifdef PROFILE
#ifdef __WXDEBUG__
#include <profile.h> #include <profile.h>
#include <wx/debug.h>
#include <wx/log.h> #include <wx/log.h>
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
using namespace KIGFX; using namespace KIGFX;
@ -153,6 +153,11 @@ void GPU_CACHED_MANAGER::DrawAll()
void GPU_CACHED_MANAGER::EndDrawing() void GPU_CACHED_MANAGER::EndDrawing()
{ {
#ifdef __WXDEBUG__
prof_counter totalRealTime;
prof_start( &totalRealTime );
#endif /* __WXDEBUG__ */
wxASSERT( m_isDrawing ); wxASSERT( m_isDrawing );
// Prepare buffers // Prepare buffers
@ -177,6 +182,10 @@ void GPU_CACHED_MANAGER::EndDrawing()
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, 0 ); glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, 0 );
#ifdef __WXDEBUG__
wxLogTrace( "GAL_PROFILE", wxT( "Cached manager size: %d" ), m_indicesSize );
#endif /* __WXDEBUG__ */
glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
@ -191,15 +200,21 @@ void GPU_CACHED_MANAGER::EndDrawing()
} }
m_isDrawing = false; m_isDrawing = false;
#ifdef __WXDEBUG__
prof_end( &totalRealTime );
wxLogTrace( "GAL_PROFILE",
wxT( "GPU_CACHED_MANAGER::EndDrawing(): %.1f ms" ), totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
} }
void GPU_CACHED_MANAGER::uploadToGpu() void GPU_CACHED_MANAGER::uploadToGpu()
{ {
#ifdef PROFILE #ifdef __WXDEBUG__
prof_counter totalTime; prof_counter totalTime;
prof_start( &totalTime ); prof_start( &totalTime );
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
if( !m_buffersInitialized ) if( !m_buffersInitialized )
Initialize(); Initialize();
@ -218,11 +233,11 @@ void GPU_CACHED_MANAGER::uploadToGpu()
// Allocate the biggest possible buffer for indices // Allocate the biggest possible buffer for indices
resizeIndices( bufferSize ); resizeIndices( bufferSize );
#ifdef PROFILE #ifdef __WXDEBUG__
prof_end( &totalTime ); prof_end( &totalTime );
wxLogTrace( "GAL_PROFILE",
wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() ); wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() );
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
} }
@ -270,6 +285,11 @@ void GPU_NONCACHED_MANAGER::DrawAll()
void GPU_NONCACHED_MANAGER::EndDrawing() void GPU_NONCACHED_MANAGER::EndDrawing()
{ {
#ifdef __WXDEBUG__
prof_counter totalRealTime;
prof_start( &totalRealTime );
#endif /* __WXDEBUG__ */
VERTEX* vertices = m_container->GetAllVertices(); VERTEX* vertices = m_container->GetAllVertices();
GLfloat* coordinates = (GLfloat*) ( vertices ); GLfloat* coordinates = (GLfloat*) ( vertices );
GLubyte* colors = (GLubyte*) ( vertices ) + ColorOffset; GLubyte* colors = (GLubyte*) ( vertices ) + ColorOffset;
@ -293,6 +313,10 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
glDrawArrays( GL_TRIANGLES, 0, m_container->GetSize() ); glDrawArrays( GL_TRIANGLES, 0, m_container->GetSize() );
#ifdef __WXDEBUG__
wxLogTrace( "GAL_PROFILE", wxT( "Noncached manager size: %d" ), m_container->GetSize() );
#endif /* __WXDEBUG__ */
// Deactivate vertex array // Deactivate vertex array
glDisableClientState( GL_COLOR_ARRAY ); glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_VERTEX_ARRAY );
@ -302,4 +326,10 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
glDisableVertexAttribArray( m_shaderAttrib ); glDisableVertexAttribArray( m_shaderAttrib );
m_shader->Deactivate(); m_shader->Deactivate();
} }
#ifdef __WXDEBUG__
prof_end( &totalRealTime );
wxLogTrace( "GAL_PROFILE",
wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ), totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
} }

View File

@ -29,10 +29,11 @@
#include <gal/opengl/opengl_gal.h> #include <gal/opengl/opengl_gal.h>
#include <gal/definitions.h> #include <gal/definitions.h>
#include <wx/log.h>
#include <macros.h> #include <macros.h>
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
#include <profile.h> #include <profile.h>
#include <wx/log.h>
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
#include <limits> #include <limits>
@ -137,6 +138,11 @@ void OPENGL_GAL::BeginDrawing()
if( !IsShownOnScreen() ) if( !IsShownOnScreen() )
return; return;
#ifdef __WXDEBUG__
prof_counter totalRealTime;
prof_start( &totalRealTime );
#endif /* __WXDEBUG__ */
SetCurrent( *glContext ); SetCurrent( *glContext );
clientDC = new wxClientDC( this ); clientDC = new wxClientDC( this );
@ -205,11 +211,22 @@ void OPENGL_GAL::BeginDrawing()
cachedManager.BeginDrawing(); cachedManager.BeginDrawing();
nonCachedManager.BeginDrawing(); nonCachedManager.BeginDrawing();
overlayManager.BeginDrawing(); overlayManager.BeginDrawing();
#ifdef __WXDEBUG__
prof_end( &totalRealTime );
wxLogTrace( "GAL_PROFILE",
wxT( "OPENGL_GAL::BeginDrawing(): %.1f ms" ), totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
} }
void OPENGL_GAL::EndDrawing() void OPENGL_GAL::EndDrawing()
{ {
#ifdef __WXDEBUG__
prof_counter totalRealTime;
prof_start( &totalRealTime );
#endif /* __WXDEBUG__ */
// Cached & non-cached containers are rendered to the same buffer // Cached & non-cached containers are rendered to the same buffer
compositor.SetBuffer( mainBuffer ); compositor.SetBuffer( mainBuffer );
nonCachedManager.EndDrawing(); nonCachedManager.EndDrawing();
@ -231,6 +248,11 @@ void OPENGL_GAL::EndDrawing()
SwapBuffers(); SwapBuffers();
delete clientDC; delete clientDC;
#ifdef __WXDEBUG__
prof_end( &totalRealTime );
wxLogTrace( "GAL_PROFILE", wxT( "OPENGL_GAL::EndDrawing(): %.1f ms" ), totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
} }

View File

@ -34,9 +34,9 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <painter.h> #include <painter.h>
#ifdef PROFILE #ifdef __WXDEBUG__
#include <profile.h> #include <profile.h>
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
using namespace KIGFX; using namespace KIGFX;
@ -774,10 +774,10 @@ void VIEW::ClearTargets()
void VIEW::Redraw() void VIEW::Redraw()
{ {
#ifdef PROFILE #ifdef __WXDEBUG__
prof_counter totalRealTime; prof_counter totalRealTime;
prof_start( &totalRealTime ); prof_start( &totalRealTime );
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
VECTOR2D screenSize = m_gal->GetScreenPixelSize(); VECTOR2D screenSize = m_gal->GetScreenPixelSize();
BOX2I rect( ToWorld( VECTOR2D( 0, 0 ) ), BOX2I rect( ToWorld( VECTOR2D( 0, 0 ) ),
@ -791,11 +791,10 @@ void VIEW::Redraw()
markTargetClean( TARGET_NONCACHED ); markTargetClean( TARGET_NONCACHED );
markTargetClean( TARGET_OVERLAY ); markTargetClean( TARGET_OVERLAY );
#ifdef PROFILE #ifdef __WXDEBUG__
prof_end( &totalRealTime ); prof_end( &totalRealTime );
wxLogTrace( "GAL_PROFILE", wxT( "VIEW::Redraw(): %.1f ms" ), totalRealTime.msecs() );
wxLogDebug( wxT( "Redraw: %.1f ms" ), totalRealTime.msecs() ); #endif /* __WXDEBUG__ */
#endif /* PROFILE */
} }
@ -1005,10 +1004,10 @@ void VIEW::RecacheAllItems( bool aImmediately )
r.SetMaximum(); r.SetMaximum();
#ifdef PROFILE #ifdef __WXDEBUG__
prof_counter totalRealTime; prof_counter totalRealTime;
prof_start( &totalRealTime ); prof_start( &totalRealTime );
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i ) for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
{ {
@ -1024,12 +1023,11 @@ void VIEW::RecacheAllItems( bool aImmediately )
} }
} }
#ifdef PROFILE #ifdef __WXDEBUG__
prof_end( &totalRealTime ); prof_end( &totalRealTime );
wxLogTrace( "GAL_PROFILE", wxT( "RecacheAllItems::immediately: %u %.1f ms" ),
wxLogDebug( wxT( "RecacheAllItems::immediately: %u %.1f ms" ),
aImmediately, totalRealTime.msecs() ); aImmediately, totalRealTime.msecs() );
#endif /* PROFILE */ #endif /* __WXDEBUG__ */
} }