From 36dd6eb6b3e429f02e08e6ccd7ca5895b00bff43 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 2 May 2016 15:56:17 +0200 Subject: [PATCH] GAL profiling output is enabled with WXTRACE env variable. --- common/draw_panel_gal.cpp | 15 ++++++++-- common/gal/opengl/gpu_manager.cpp | 48 +++++++++++++++++++++++++------ common/gal/opengl/opengl_gal.cpp | 24 +++++++++++++++- common/view/view.cpp | 26 ++++++++--------- 4 files changed, 87 insertions(+), 26 deletions(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index fd844b3117..ee079c4dd0 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -45,9 +45,10 @@ #include -#ifdef __WXDEBUG__ +#ifdef PROFILE #include -#endif /* __WXDEBUG__ */ +#endif /* PROFILE */ + EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition, const wxSize& aSize, @@ -142,6 +143,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) if( m_drawing ) return; +#ifdef PROFILE + prof_counter totalRealTime; + prof_start( &totalRealTime ); +#endif /* PROFILE */ + m_drawing = true; KIGFX::PCB_RENDER_SETTINGS* settings = static_cast( m_painter->GetSettings() ); @@ -167,6 +173,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) m_gal->DrawCursor( m_viewControls->GetCursorPosition() ); 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_drawing = false; } diff --git a/common/gal/opengl/gpu_manager.cpp b/common/gal/opengl/gpu_manager.cpp index 04b8a14f68..2012f4ed25 100644 --- a/common/gal/opengl/gpu_manager.cpp +++ b/common/gal/opengl/gpu_manager.cpp @@ -35,11 +35,11 @@ #include #include -#ifdef PROFILE + +#ifdef __WXDEBUG__ #include -#include #include -#endif /* PROFILE */ +#endif /* __WXDEBUG__ */ using namespace KIGFX; @@ -153,6 +153,11 @@ void GPU_CACHED_MANAGER::DrawAll() void GPU_CACHED_MANAGER::EndDrawing() { +#ifdef __WXDEBUG__ + prof_counter totalRealTime; + prof_start( &totalRealTime ); +#endif /* __WXDEBUG__ */ + wxASSERT( m_isDrawing ); // Prepare buffers @@ -177,6 +182,10 @@ void GPU_CACHED_MANAGER::EndDrawing() 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_ELEMENT_ARRAY_BUFFER, 0 ); @@ -191,15 +200,21 @@ void GPU_CACHED_MANAGER::EndDrawing() } 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() { -#ifdef PROFILE +#ifdef __WXDEBUG__ prof_counter totalTime; prof_start( &totalTime ); -#endif /* PROFILE */ +#endif /* __WXDEBUG__ */ if( !m_buffersInitialized ) Initialize(); @@ -218,11 +233,11 @@ void GPU_CACHED_MANAGER::uploadToGpu() // Allocate the biggest possible buffer for indices resizeIndices( bufferSize ); -#ifdef PROFILE +#ifdef __WXDEBUG__ prof_end( &totalTime ); - - wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() ); -#endif /* PROFILE */ + wxLogTrace( "GAL_PROFILE", + wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() ); +#endif /* __WXDEBUG__ */ } @@ -270,6 +285,11 @@ void GPU_NONCACHED_MANAGER::DrawAll() void GPU_NONCACHED_MANAGER::EndDrawing() { +#ifdef __WXDEBUG__ + prof_counter totalRealTime; + prof_start( &totalRealTime ); +#endif /* __WXDEBUG__ */ + VERTEX* vertices = m_container->GetAllVertices(); GLfloat* coordinates = (GLfloat*) ( vertices ); GLubyte* colors = (GLubyte*) ( vertices ) + ColorOffset; @@ -293,6 +313,10 @@ void GPU_NONCACHED_MANAGER::EndDrawing() 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 glDisableClientState( GL_COLOR_ARRAY ); glDisableClientState( GL_VERTEX_ARRAY ); @@ -302,4 +326,10 @@ void GPU_NONCACHED_MANAGER::EndDrawing() glDisableVertexAttribArray( m_shaderAttrib ); m_shader->Deactivate(); } + +#ifdef __WXDEBUG__ + prof_end( &totalRealTime ); + wxLogTrace( "GAL_PROFILE", + wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ), totalRealTime.msecs() ); +#endif /* __WXDEBUG__ */ } diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 1317e3a572..fc50c6f367 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -29,10 +29,11 @@ #include #include -#include #include + #ifdef __WXDEBUG__ #include +#include #endif /* __WXDEBUG__ */ #include @@ -137,6 +138,11 @@ void OPENGL_GAL::BeginDrawing() if( !IsShownOnScreen() ) return; +#ifdef __WXDEBUG__ + prof_counter totalRealTime; + prof_start( &totalRealTime ); +#endif /* __WXDEBUG__ */ + SetCurrent( *glContext ); clientDC = new wxClientDC( this ); @@ -205,11 +211,22 @@ void OPENGL_GAL::BeginDrawing() cachedManager.BeginDrawing(); nonCachedManager.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() { +#ifdef __WXDEBUG__ + prof_counter totalRealTime; + prof_start( &totalRealTime ); +#endif /* __WXDEBUG__ */ + // Cached & non-cached containers are rendered to the same buffer compositor.SetBuffer( mainBuffer ); nonCachedManager.EndDrawing(); @@ -231,6 +248,11 @@ void OPENGL_GAL::EndDrawing() SwapBuffers(); delete clientDC; + +#ifdef __WXDEBUG__ + prof_end( &totalRealTime ); + wxLogTrace( "GAL_PROFILE", wxT( "OPENGL_GAL::EndDrawing(): %.1f ms" ), totalRealTime.msecs() ); +#endif /* __WXDEBUG__ */ } diff --git a/common/view/view.cpp b/common/view/view.cpp index 6f94af86ac..0b74988bdf 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -34,9 +34,9 @@ #include #include -#ifdef PROFILE +#ifdef __WXDEBUG__ #include -#endif /* PROFILE */ +#endif /* __WXDEBUG__ */ using namespace KIGFX; @@ -774,10 +774,10 @@ void VIEW::ClearTargets() void VIEW::Redraw() { -#ifdef PROFILE +#ifdef __WXDEBUG__ prof_counter totalRealTime; prof_start( &totalRealTime ); -#endif /* PROFILE */ +#endif /* __WXDEBUG__ */ VECTOR2D screenSize = m_gal->GetScreenPixelSize(); BOX2I rect( ToWorld( VECTOR2D( 0, 0 ) ), @@ -791,11 +791,10 @@ void VIEW::Redraw() markTargetClean( TARGET_NONCACHED ); markTargetClean( TARGET_OVERLAY ); -#ifdef PROFILE +#ifdef __WXDEBUG__ prof_end( &totalRealTime ); - - wxLogDebug( wxT( "Redraw: %.1f ms" ), totalRealTime.msecs() ); -#endif /* PROFILE */ + wxLogTrace( "GAL_PROFILE", wxT( "VIEW::Redraw(): %.1f ms" ), totalRealTime.msecs() ); +#endif /* __WXDEBUG__ */ } @@ -1005,10 +1004,10 @@ void VIEW::RecacheAllItems( bool aImmediately ) r.SetMaximum(); -#ifdef PROFILE +#ifdef __WXDEBUG__ prof_counter totalRealTime; prof_start( &totalRealTime ); -#endif /* PROFILE */ +#endif /* __WXDEBUG__ */ 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 ); - - wxLogDebug( wxT( "RecacheAllItems::immediately: %u %.1f ms" ), + wxLogTrace( "GAL_PROFILE", wxT( "RecacheAllItems::immediately: %u %.1f ms" ), aImmediately, totalRealTime.msecs() ); -#endif /* PROFILE */ +#endif /* __WXDEBUG__ */ }