Hide gal profiling behind KICAD_GAL_PROFILE cmake option

__WXDEBUG__ is too easy to get set
This commit is contained in:
Marek Roszko 2021-04-30 19:24:09 -04:00
parent 51fee0a3ad
commit cbad18ad98
7 changed files with 64 additions and 56 deletions

View File

@ -157,6 +157,10 @@ option( KICAD_DRC_PROTO
"Build the DRC prototype QA tool"
OFF )
option( KICAD_GAL_PROFILE
"Enable profiling info for GAL"
OFF )
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
# PYTHON_EXECUTABLE can be defined when invoking cmake
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
@ -199,6 +203,10 @@ if( KICAD_USE_VALGRIND )
add_definitions( -DKICAD_USE_VALGRIND )
endif()
if( KICAD_GAL_PROFILE )
add_definitions( -DKICAD_GAL_PROFILE )
endif()
# Ensure DEBUG is defined for all platforms in Debug builds
# change to add_compile_definitions() after minimum required CMake version is 3.12
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG> )

View File

@ -40,10 +40,10 @@
#include <algorithm>
#include <cassert>
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
#include <wx/log.h>
#include <profile.h>
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
using namespace KIGFX;
@ -308,9 +308,9 @@ void CACHED_CONTAINER::mergeFreeChunks()
if( m_freeChunks.size() <= 1 ) // There are no chunks that can be merged
return;
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
// Reversed free chunks map - this one stores chunk size with its offset as the key
std::list<CHUNK> freeChunks;
@ -379,7 +379,7 @@ void CACHED_CONTAINER::showUsedChunks()
void CACHED_CONTAINER::test()
{
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
// Free space check
unsigned int freeSpace = 0;
FREE_CHUNK_MAP::iterator itf;
@ -405,5 +405,5 @@ void CACHED_CONTAINER::test()
assert( ( m_freeSpace + used_space ) == m_currentSize );
// Overlapping check TODO
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
}

View File

@ -34,9 +34,9 @@
#include <list>
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
#include <profile.h>
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
using namespace KIGFX;
@ -139,9 +139,9 @@ bool CACHED_CONTAINER_GPU::defragmentResize( unsigned int aNewSize )
if( usedSpace() > aNewSize )
return false;
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
GLuint newBuffer;
@ -153,11 +153,11 @@ bool CACHED_CONTAINER_GPU::defragmentResize( unsigned int aNewSize )
// It would be best to use GL_COPY_WRITE_BUFFER here,
// but it is not available everywhere
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
GLint eaBuffer = -1;
glGetIntegerv( GL_ELEMENT_ARRAY_BUFFER_BINDING, &eaBuffer );
wxASSERT( eaBuffer == 0 );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, newBuffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, aNewSize * VERTEX_SIZE, nullptr, GL_DYNAMIC_DRAW );
checkGlError( "creating buffer during defragmentation", __FILE__, __LINE__ );
@ -208,12 +208,12 @@ bool CACHED_CONTAINER_GPU::defragmentResize( unsigned int aNewSize )
Map();
checkGlError( "switching buffers during defragmentation", __FILE__, __LINE__ );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalTime.Stop();
wxLogTrace( traceGalCachedContainerGpu, "Defragmented container storing %d vertices / %.1f ms",
m_currentSize - m_freeSpace, totalTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
m_freeSpace += ( aNewSize - m_currentSize );
m_currentSize = aNewSize;
@ -238,9 +238,9 @@ bool CACHED_CONTAINER_GPU::defragmentResizeMemcpy( unsigned int aNewSize )
if( usedSpace() > aNewSize )
return false;
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
GLuint newBuffer;
VERTEX* newBufferMem;
@ -250,11 +250,11 @@ bool CACHED_CONTAINER_GPU::defragmentResizeMemcpy( unsigned int aNewSize )
// It would be best to use GL_COPY_WRITE_BUFFER here,
// but it is not available everywhere
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
GLint eaBuffer = -1;
glGetIntegerv( GL_ELEMENT_ARRAY_BUFFER_BINDING, &eaBuffer );
wxASSERT( eaBuffer == 0 );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, newBuffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, aNewSize * VERTEX_SIZE, nullptr, GL_DYNAMIC_DRAW );
newBufferMem = static_cast<VERTEX*>( glMapBuffer( GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY ) );
@ -273,12 +273,12 @@ bool CACHED_CONTAINER_GPU::defragmentResizeMemcpy( unsigned int aNewSize )
Map();
checkGlError( "switching buffers during defragmentation", __FILE__, __LINE__ );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalTime.Stop();
wxLogTrace( traceGalCachedContainerGpu, "Defragmented container storing %d vertices / %.1f ms",
m_currentSize - m_freeSpace, totalTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
m_freeSpace += ( aNewSize - m_currentSize );
m_currentSize = aNewSize;

View File

@ -34,10 +34,10 @@
#include <list>
#include <cassert>
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
#include <wx/log.h>
#include <profile.h>
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
using namespace KIGFX;
@ -100,9 +100,9 @@ bool CACHED_CONTAINER_RAM::defragmentResize( unsigned int aNewSize )
if( usedSpace() > aNewSize )
return false;
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
VERTEX* newBufferMem = static_cast<VERTEX*>( malloc( aNewSize * VERTEX_SIZE ) );
@ -115,12 +115,12 @@ bool CACHED_CONTAINER_RAM::defragmentResize( unsigned int aNewSize )
free( m_vertices );
m_vertices = newBufferMem;
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalTime.Stop();
wxLogTrace( traceGalCachedContainer, "Defragmented container storing %d vertices / %.1f ms",
m_currentSize - m_freeSpace, totalTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
m_freeSpace += ( aNewSize - m_currentSize );
m_currentSize = aNewSize;

View File

@ -35,10 +35,10 @@
#include <confirm.h>
#include <trace_helpers.h>
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
#include <profile.h>
#include <wx/log.h>
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
using namespace KIGFX;
@ -153,9 +153,9 @@ void GPU_CACHED_MANAGER::DrawAll()
void GPU_CACHED_MANAGER::EndDrawing()
{
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalRealTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
wxASSERT( m_isDrawing );
@ -198,9 +198,9 @@ void GPU_CACHED_MANAGER::EndDrawing()
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, NULL );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
wxLogTrace( traceGalProfile, wxT( "Cached manager size: %d" ), m_indicesSize );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
@ -218,11 +218,11 @@ void GPU_CACHED_MANAGER::EndDrawing()
m_isDrawing = false;
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalRealTime.Stop();
wxLogTrace( traceGalProfile, wxT( "GPU_CACHED_MANAGER::EndDrawing(): %.1f ms" ),
totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
}
@ -264,9 +264,9 @@ void GPU_NONCACHED_MANAGER::DrawAll()
void GPU_NONCACHED_MANAGER::EndDrawing()
{
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalRealTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
if( m_container->GetSize() == 0 )
return;
@ -299,9 +299,9 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
glDrawArrays( GL_TRIANGLES, 0, m_container->GetSize() );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
wxLogTrace( traceGalProfile, wxT( "Noncached manager size: %d" ), m_container->GetSize() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
// Deactivate vertex array
glDisableClientState( GL_COLOR_ARRAY );
@ -315,11 +315,11 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
m_container->Clear();
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalRealTime.Stop();
wxLogTrace( traceGalProfile, wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ),
totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
}
void GPU_MANAGER::EnableDepthTest( bool aEnabled )

View File

@ -49,10 +49,10 @@
#include <macros.h>
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
#include <profile.h>
#include <wx/log.h>
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
#include <functional>
#include <limits>
@ -412,9 +412,9 @@ VECTOR2D OPENGL_GAL::getScreenPixelSize() const
void OPENGL_GAL::beginDrawing()
{
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalRealTime( "OPENGL_GAL::beginDrawing()", true );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
wxASSERT_MSG( m_isContextLocked, "GAL_DRAWING_CONTEXT RAII object should have locked context. "
"Calling GAL::beginDrawing() directly is not allowed." );
@ -553,11 +553,11 @@ void OPENGL_GAL::beginDrawing()
// Unbind buffers - set compositor for direct drawing
m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalRealTime.Stop();
wxLogTrace( traceGalProfile, wxT( "OPENGL_GAL::beginDrawing(): %.1f ms" ),
totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
}
@ -565,9 +565,9 @@ void OPENGL_GAL::endDrawing()
{
wxASSERT_MSG( m_isContextLocked, "What happened to the context lock?" );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalRealTime( "OPENGL_GAL::endDrawing()", true );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
// Cached & non-cached containers are rendered to the same buffer
m_compositor->SetBuffer( m_mainBuffer );
@ -594,11 +594,11 @@ void OPENGL_GAL::endDrawing()
SwapBuffers();
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalRealTime.Stop();
wxLogTrace( traceGalProfile, wxT( "OPENGL_GAL::endDrawing(): %.1f ms" ),
totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
}

View File

@ -40,9 +40,9 @@
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
#include <profile.h>
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
namespace KIGFX {
@ -1124,9 +1124,9 @@ void VIEW::ClearTargets()
void VIEW::Redraw()
{
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
PROF_COUNTER totalRealTime;
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
VECTOR2D screenSize = m_gal->GetScreenPixelSize();
BOX2D rect( ToWorld( VECTOR2D( 0, 0 ) ),
@ -1147,10 +1147,10 @@ void VIEW::Redraw()
markTargetClean( TARGET_NONCACHED );
markTargetClean( TARGET_OVERLAY );
#ifdef __WXDEBUG__
#ifdef KICAD_GAL_PROFILE
totalRealTime.Stop();
wxLogTrace( traceGalProfile, "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
#endif /* __WXDEBUG__ */
#endif /* KICAD_GAL_PROFILE */
}