OpenGL GAL tracing improvements.
This commit is contained in:
parent
49b1aceb8b
commit
d96cccbf20
|
@ -31,6 +31,7 @@
|
|||
#include <macros.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <cursors.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <view/view.h>
|
||||
|
@ -258,7 +259,8 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
|
|||
|
||||
#ifdef PROFILE
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", "EDA_DRAW_PANEL_GAL::DoRePaint(): %.1f ms", totalRealTime.msecs() );
|
||||
wxLogTrace( traceGalProfile, "EDA_DRAW_PANEL_GAL::DoRePaint(): %.1f ms",
|
||||
totalRealTime.msecs() );
|
||||
#endif /* PROFILE */
|
||||
|
||||
m_lastRefresh = wxGetLocalTimeMillis();
|
||||
|
|
|
@ -145,17 +145,17 @@ bool ANTIALIASING_SUPERSAMPLING::Init()
|
|||
x4_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_FRAGMENT,
|
||||
BUILTIN_SHADERS::ssaa_x4_fragment_shader );
|
||||
x4_shader->Link();
|
||||
checkGlError( "linking supersampling x4 shader" );
|
||||
checkGlError( "linking supersampling x4 shader", __FILE__, __LINE__ );
|
||||
|
||||
GLint source_parameter = x4_shader->AddParameter( "source" );
|
||||
checkGlError( "getting pass 1 colorTex" );
|
||||
checkGlError( "getting pass 1 colorTex", __FILE__, __LINE__ );
|
||||
|
||||
x4_shader->Use();
|
||||
checkGlError( "using pass 1 shader" );
|
||||
checkGlError( "using pass 1 shader", __FILE__, __LINE__ );
|
||||
x4_shader->SetParameter( source_parameter, 0 );
|
||||
checkGlError( "setting colorTex uniform" );
|
||||
checkGlError( "setting colorTex uniform", __FILE__, __LINE__ );
|
||||
x4_shader->Deactivate();
|
||||
checkGlError( "deactivating pass 2 shader" );
|
||||
checkGlError( "deactivating pass 2 shader", __FILE__, __LINE__ );
|
||||
|
||||
areShadersCreated = true;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ void ANTIALIASING_SUPERSAMPLING::Present()
|
|||
if( mode == SUPERSAMPLING_MODE::X4 )
|
||||
{
|
||||
x4_shader->Use();
|
||||
checkGlError( "activating supersampling x4 shader" );
|
||||
checkGlError( "activating supersampling x4 shader", __FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
draw_fullscreen_primitive();
|
||||
|
@ -218,7 +218,7 @@ void ANTIALIASING_SUPERSAMPLING::Present()
|
|||
if( mode == SUPERSAMPLING_MODE::X4 )
|
||||
{
|
||||
x4_shader->Deactivate();
|
||||
checkGlError( "deactivating supersampling x4 shader" );
|
||||
checkGlError( "deactivating supersampling x4 shader", __FILE__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ void ANTIALIASING_SMAA::loadShaders()
|
|||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RG8, AREATEX_WIDTH, AREATEX_HEIGHT, 0, GL_RG,
|
||||
GL_UNSIGNED_BYTE, areaTexBytes );
|
||||
checkGlError( "loading smaa area tex" );
|
||||
checkGlError( "loading smaa area tex", __FILE__, __LINE__ );
|
||||
|
||||
glGenTextures( 1, &smaaSearchTex );
|
||||
glBindTexture( GL_TEXTURE_2D, smaaSearchTex );
|
||||
|
@ -286,7 +286,7 @@ void ANTIALIASING_SMAA::loadShaders()
|
|||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_R8, SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 0, GL_RED,
|
||||
GL_UNSIGNED_BYTE, searchTexBytes );
|
||||
checkGlError( "loading smaa search tex" );
|
||||
checkGlError( "loading smaa search tex", __FILE__, __LINE__ );
|
||||
|
||||
std::string quality_string;
|
||||
|
||||
|
@ -332,19 +332,19 @@ uniform vec4 SMAA_RT_METRICS;
|
|||
quality_string, smaa_source,
|
||||
BUILTIN_SHADERS::smaa_pass_1_fragment_shader );
|
||||
pass_1_shader->Link();
|
||||
checkGlError( "linking pass 1 shader" );
|
||||
checkGlError( "linking pass 1 shader", __FILE__, __LINE__ );
|
||||
|
||||
GLint smaaColorTexParameter = pass_1_shader->AddParameter( "colorTex" );
|
||||
checkGlError( "pass1: getting colorTex uniform" );
|
||||
checkGlError( "pass1: getting colorTex uniform", __FILE__, __LINE__ );
|
||||
pass_1_metrics = pass_1_shader->AddParameter( "SMAA_RT_METRICS" );
|
||||
checkGlError( "pass1: getting metrics uniform" );
|
||||
checkGlError( "pass1: getting metrics uniform", __FILE__, __LINE__ );
|
||||
|
||||
pass_1_shader->Use();
|
||||
checkGlError( "pass1: using shader" );
|
||||
checkGlError( "pass1: using shader", __FILE__, __LINE__ );
|
||||
pass_1_shader->SetParameter( smaaColorTexParameter, 0 );
|
||||
checkGlError( "pass1: setting colorTex uniform" );
|
||||
checkGlError( "pass1: setting colorTex uniform", __FILE__, __LINE__ );
|
||||
pass_1_shader->Deactivate();
|
||||
checkGlError( "pass1: deactivating shader" );
|
||||
checkGlError( "pass1: deactivating shader", __FILE__, __LINE__ );
|
||||
|
||||
//
|
||||
// set up pass 2 shader
|
||||
|
@ -356,27 +356,27 @@ uniform vec4 SMAA_RT_METRICS;
|
|||
quality_string, smaa_source,
|
||||
BUILTIN_SHADERS::smaa_pass_2_fragment_shader );
|
||||
pass_2_shader->Link();
|
||||
checkGlError( "linking pass 2 shader" );
|
||||
checkGlError( "linking pass 2 shader", __FILE__, __LINE__ );
|
||||
|
||||
GLint smaaEdgesTexParameter = pass_2_shader->AddParameter( "edgesTex" );
|
||||
checkGlError( "pass2: getting colorTex uniform" );
|
||||
checkGlError( "pass2: getting colorTex uniform", __FILE__, __LINE__ );
|
||||
GLint smaaAreaTexParameter = pass_2_shader->AddParameter( "areaTex" );
|
||||
checkGlError( "pass2: getting areaTex uniform" );
|
||||
checkGlError( "pass2: getting areaTex uniform", __FILE__, __LINE__ );
|
||||
GLint smaaSearchTexParameter = pass_2_shader->AddParameter( "searchTex" );
|
||||
checkGlError( "pass2: getting searchTex uniform" );
|
||||
checkGlError( "pass2: getting searchTex uniform", __FILE__, __LINE__ );
|
||||
pass_2_metrics = pass_2_shader->AddParameter( "SMAA_RT_METRICS" );
|
||||
checkGlError( "pass2: getting metrics uniform" );
|
||||
checkGlError( "pass2: getting metrics uniform", __FILE__, __LINE__ );
|
||||
|
||||
pass_2_shader->Use();
|
||||
checkGlError( "pass2: using shader" );
|
||||
checkGlError( "pass2: using shader", __FILE__, __LINE__ );
|
||||
pass_2_shader->SetParameter( smaaEdgesTexParameter, 0 );
|
||||
checkGlError( "pass2: setting colorTex uniform" );
|
||||
checkGlError( "pass2: setting colorTex uniform", __FILE__, __LINE__ );
|
||||
pass_2_shader->SetParameter( smaaAreaTexParameter, 1 );
|
||||
checkGlError( "pass2: setting areaTex uniform" );
|
||||
checkGlError( "pass2: setting areaTex uniform", __FILE__, __LINE__ );
|
||||
pass_2_shader->SetParameter( smaaSearchTexParameter, 3 );
|
||||
checkGlError( "pass2: setting searchTex uniform" );
|
||||
checkGlError( "pass2: setting searchTex uniform", __FILE__, __LINE__ );
|
||||
pass_2_shader->Deactivate();
|
||||
checkGlError( "pass2: deactivating shader" );
|
||||
checkGlError( "pass2: deactivating shader", __FILE__, __LINE__ );
|
||||
|
||||
//
|
||||
// set up pass 3 shader
|
||||
|
@ -390,20 +390,20 @@ uniform vec4 SMAA_RT_METRICS;
|
|||
pass_3_shader->Link();
|
||||
|
||||
GLint smaaP3ColorTexParameter = pass_3_shader->AddParameter( "colorTex" );
|
||||
checkGlError( "pass3: getting colorTex uniform" );
|
||||
checkGlError( "pass3: getting colorTex uniform", __FILE__, __LINE__ );
|
||||
GLint smaaBlendTexParameter = pass_3_shader->AddParameter( "blendTex" );
|
||||
checkGlError( "pass3: getting blendTex uniform" );
|
||||
checkGlError( "pass3: getting blendTex uniform", __FILE__, __LINE__ );
|
||||
pass_3_metrics = pass_3_shader->AddParameter( "SMAA_RT_METRICS" );
|
||||
checkGlError( "pass3: getting metrics uniform" );
|
||||
checkGlError( "pass3: getting metrics uniform", __FILE__, __LINE__ );
|
||||
|
||||
pass_3_shader->Use();
|
||||
checkGlError( "pass3: using shader" );
|
||||
checkGlError( "pass3: using shader", __FILE__, __LINE__ );
|
||||
pass_3_shader->SetParameter( smaaP3ColorTexParameter, 0 );
|
||||
checkGlError( "pass3: setting colorTex uniform" );
|
||||
checkGlError( "pass3: setting colorTex uniform", __FILE__, __LINE__ );
|
||||
pass_3_shader->SetParameter( smaaBlendTexParameter, 1 );
|
||||
checkGlError( "pass3: setting blendTex uniform" );
|
||||
checkGlError( "pass3: setting blendTex uniform", __FILE__, __LINE__ );
|
||||
pass_3_shader->Deactivate();
|
||||
checkGlError( "pass3: deactivating shader" );
|
||||
checkGlError( "pass3: deactivating shader", __FILE__, __LINE__ );
|
||||
|
||||
shadersLoaded = true;
|
||||
}
|
||||
|
@ -414,28 +414,28 @@ void ANTIALIASING_SMAA::updateUniforms()
|
|||
auto dims = compositor->GetScreenSize();
|
||||
|
||||
pass_1_shader->Use();
|
||||
checkGlError( "pass1: using shader" );
|
||||
checkGlError( "pass1: using shader", __FILE__, __LINE__ );
|
||||
pass_1_shader->SetParameter( pass_1_metrics, 1.f / float( dims.x ), 1.f / float( dims.y ),
|
||||
float( dims.x ), float( dims.y ) );
|
||||
checkGlError( "pass1: setting metrics uniform" );
|
||||
checkGlError( "pass1: setting metrics uniform", __FILE__, __LINE__ );
|
||||
pass_1_shader->Deactivate();
|
||||
checkGlError( "pass1: deactivating shader" );
|
||||
checkGlError( "pass1: deactivating shader", __FILE__, __LINE__ );
|
||||
|
||||
pass_2_shader->Use();
|
||||
checkGlError( "pass2: using shader" );
|
||||
checkGlError( "pass2: using shader", __FILE__, __LINE__ );
|
||||
pass_2_shader->SetParameter( pass_2_metrics, 1.f / float( dims.x ), 1.f / float( dims.y ),
|
||||
float( dims.x ), float( dims.y ) );
|
||||
checkGlError( "pass2: setting metrics uniform" );
|
||||
checkGlError( "pass2: setting metrics uniform", __FILE__, __LINE__ );
|
||||
pass_2_shader->Deactivate();
|
||||
checkGlError( "pass2: deactivating shader" );
|
||||
checkGlError( "pass2: deactivating shader", __FILE__, __LINE__ );
|
||||
|
||||
pass_3_shader->Use();
|
||||
checkGlError( "pass3: using shader" );
|
||||
checkGlError( "pass3: using shader", __FILE__, __LINE__ );
|
||||
pass_3_shader->SetParameter( pass_3_metrics, 1.f / float( dims.x ), 1.f / float( dims.y ),
|
||||
float( dims.x ), float( dims.y ) );
|
||||
checkGlError( "pass3: setting metrics uniform" );
|
||||
checkGlError( "pass3: setting metrics uniform", __FILE__, __LINE__ );
|
||||
pass_3_shader->Deactivate();
|
||||
checkGlError( "pass3: deactivating shader" );
|
||||
checkGlError( "pass3: deactivating shader", __FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
|
||||
|
@ -536,9 +536,9 @@ void ANTIALIASING_SMAA::Present()
|
|||
|
||||
glActiveTexture( GL_TEXTURE0 );
|
||||
glBindTexture( GL_TEXTURE_2D, sourceTexture );
|
||||
checkGlError( "binding colorTex" );
|
||||
checkGlError( "binding colorTex", __FILE__, __LINE__ );
|
||||
pass_1_shader->Use();
|
||||
checkGlError( "using smaa pass 1 shader" );
|
||||
checkGlError( "using smaa pass 1 shader", __FILE__, __LINE__ );
|
||||
draw_fullscreen_triangle();
|
||||
pass_1_shader->Deactivate();
|
||||
|
||||
|
|
|
@ -40,6 +40,16 @@
|
|||
|
||||
using namespace KIGFX;
|
||||
|
||||
/**
|
||||
* Flag to enable debug output of the GAL OpenGL GPU cached container.
|
||||
*
|
||||
* Use "KICAD_GAL_CACHED_CONTAINER_GPU" to enable GAL OpenGL GPU cached container tracing.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
static const wxChar* const traceGalCachedContainerGpu = wxT( "KICAD_GAL_CACHED_CONTAINER_GPU" );
|
||||
|
||||
|
||||
CACHED_CONTAINER_GPU::CACHED_CONTAINER_GPU( unsigned int aSize ) :
|
||||
CACHED_CONTAINER( aSize ),
|
||||
m_isMapped( false ),
|
||||
|
@ -61,7 +71,7 @@ CACHED_CONTAINER_GPU::CACHED_CONTAINER_GPU( unsigned int aSize ) :
|
|||
glBindBuffer( GL_ARRAY_BUFFER, m_glBufferHandle );
|
||||
glBufferData( GL_ARRAY_BUFFER, m_currentSize * VERTEX_SIZE, nullptr, GL_DYNAMIC_DRAW );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
checkGlError( "allocating video memory for cached container" );
|
||||
checkGlError( "allocating video memory for cached container", __FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,7 +96,7 @@ void CACHED_CONTAINER_GPU::Map()
|
|||
glBindBuffer( GL_ARRAY_BUFFER, m_glBufferHandle );
|
||||
m_vertices = static_cast<VERTEX*>( glMapBuffer( GL_ARRAY_BUFFER, GL_READ_WRITE ) );
|
||||
|
||||
if( checkGlError( "mapping vertices buffer" ) == GL_NO_ERROR )
|
||||
if( checkGlError( "mapping vertices buffer", __FILE__, __LINE__ ) == GL_NO_ERROR )
|
||||
m_isMapped = true;
|
||||
}
|
||||
|
||||
|
@ -100,10 +110,10 @@ void CACHED_CONTAINER_GPU::Unmap()
|
|||
try
|
||||
{
|
||||
glUnmapBuffer( GL_ARRAY_BUFFER );
|
||||
checkGlError( "unmapping vertices buffer" );
|
||||
checkGlError( "unmapping vertices buffer", __FILE__, __LINE__ );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
m_vertices = nullptr;
|
||||
checkGlError( "unbinding vertices buffer" );
|
||||
checkGlError( "unbinding vertices buffer", __FILE__, __LINE__ );
|
||||
}
|
||||
catch( const std::runtime_error& err )
|
||||
{
|
||||
|
@ -121,7 +131,7 @@ bool CACHED_CONTAINER_GPU::defragmentResize( unsigned int aNewSize )
|
|||
|
||||
wxCHECK( IsMapped(), false );
|
||||
|
||||
wxLogTrace( "GAL_CACHED_CONTAINER_GPU",
|
||||
wxLogTrace( traceGalCachedContainerGpu,
|
||||
wxT( "Resizing & defragmenting container from %d to %d" ), m_currentSize,
|
||||
aNewSize );
|
||||
|
||||
|
@ -150,7 +160,7 @@ bool CACHED_CONTAINER_GPU::defragmentResize( unsigned int aNewSize )
|
|||
#endif /* __WXDEBUG__ */
|
||||
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, newBuffer );
|
||||
glBufferData( GL_ELEMENT_ARRAY_BUFFER, aNewSize * VERTEX_SIZE, nullptr, GL_DYNAMIC_DRAW );
|
||||
checkGlError( "creating buffer during defragmentation" );
|
||||
checkGlError( "creating buffer during defragmentation", __FILE__, __LINE__ );
|
||||
|
||||
ITEMS::iterator it, it_end;
|
||||
int newOffset = 0;
|
||||
|
@ -196,12 +206,12 @@ bool CACHED_CONTAINER_GPU::defragmentResize( unsigned int aNewSize )
|
|||
// Switch to the new vertex buffer
|
||||
m_glBufferHandle = newBuffer;
|
||||
Map();
|
||||
checkGlError( "switching buffers during defragmentation" );
|
||||
checkGlError( "switching buffers during defragmentation", __FILE__, __LINE__ );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
totalTime.Stop();
|
||||
|
||||
wxLogTrace( "GAL_CACHED_CONTAINER_GPU", "Defragmented container storing %d vertices / %.1f ms",
|
||||
wxLogTrace( traceGalCachedContainerGpu, "Defragmented container storing %d vertices / %.1f ms",
|
||||
m_currentSize - m_freeSpace, totalTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
|
@ -220,7 +230,7 @@ bool CACHED_CONTAINER_GPU::defragmentResizeMemcpy( unsigned int aNewSize )
|
|||
{
|
||||
wxCHECK( IsMapped(), false );
|
||||
|
||||
wxLogTrace( "GAL_CACHED_CONTAINER_GPU",
|
||||
wxLogTrace( traceGalCachedContainerGpu,
|
||||
wxT( "Resizing & defragmenting container (memcpy) from %d to %d" ), m_currentSize,
|
||||
aNewSize );
|
||||
|
||||
|
@ -248,7 +258,7 @@ bool CACHED_CONTAINER_GPU::defragmentResizeMemcpy( unsigned int aNewSize )
|
|||
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 ) );
|
||||
checkGlError( "creating buffer during defragmentation" );
|
||||
checkGlError( "creating buffer during defragmentation", __FILE__, __LINE__ );
|
||||
|
||||
defragment( newBufferMem );
|
||||
|
||||
|
@ -261,12 +271,12 @@ bool CACHED_CONTAINER_GPU::defragmentResizeMemcpy( unsigned int aNewSize )
|
|||
// Switch to the new vertex buffer
|
||||
m_glBufferHandle = newBuffer;
|
||||
Map();
|
||||
checkGlError( "switching buffers during defragmentation" );
|
||||
checkGlError( "switching buffers during defragmentation", __FILE__, __LINE__ );
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
totalTime.Stop();
|
||||
|
||||
wxLogTrace( "GAL_CACHED_CONTAINER_GPU", "Defragmented container storing %d vertices / %.1f ms",
|
||||
wxLogTrace( traceGalCachedContainerGpu, "Defragmented container storing %d vertices / %.1f ms",
|
||||
m_currentSize - m_freeSpace, totalTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
|
|
|
@ -41,12 +41,23 @@
|
|||
|
||||
using namespace KIGFX;
|
||||
|
||||
|
||||
/**
|
||||
* Flag to enable debug output of the GAL OpenGL cached container.
|
||||
*
|
||||
* Use "KICAD_GAL_CACHED_CONTAINER" to enable GAL OpenGL cached container tracing.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
static const wxChar* const traceGalCachedContainer = wxT( "KICAD_GAL_CACHED_CONTAINER" );
|
||||
|
||||
|
||||
CACHED_CONTAINER_RAM::CACHED_CONTAINER_RAM( unsigned int aSize ) :
|
||||
CACHED_CONTAINER( aSize ),
|
||||
m_verticesBuffer( 0 )
|
||||
{
|
||||
glGenBuffers( 1, &m_verticesBuffer );
|
||||
checkGlError( "generating vertices buffer" );
|
||||
checkGlError( "generating vertices buffer", __FILE__, __LINE__ );
|
||||
|
||||
m_vertices = static_cast<VERTEX*>( malloc( aSize * VERTEX_SIZE ) );
|
||||
|
||||
|
@ -71,17 +82,17 @@ void CACHED_CONTAINER_RAM::Unmap()
|
|||
|
||||
// Upload vertices coordinates and shader types to GPU memory
|
||||
glBindBuffer( GL_ARRAY_BUFFER, m_verticesBuffer );
|
||||
checkGlError( "binding vertices buffer" );
|
||||
checkGlError( "binding vertices buffer", __FILE__, __LINE__ );
|
||||
glBufferData( GL_ARRAY_BUFFER, m_maxIndex * VERTEX_SIZE, m_vertices, GL_STREAM_DRAW );
|
||||
checkGlError( "transferring vertices" );
|
||||
checkGlError( "transferring vertices", __FILE__, __LINE__ );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
checkGlError( "unbinding vertices buffer" );
|
||||
checkGlError( "unbinding vertices buffer", __FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
|
||||
bool CACHED_CONTAINER_RAM::defragmentResize( unsigned int aNewSize )
|
||||
{
|
||||
wxLogTrace( "GAL_CACHED_CONTAINER",
|
||||
wxLogTrace( traceGalCachedContainer,
|
||||
wxT( "Resizing & defragmenting container (memcpy) from %d to %d" ), m_currentSize,
|
||||
aNewSize );
|
||||
|
||||
|
@ -107,7 +118,7 @@ bool CACHED_CONTAINER_RAM::defragmentResize( unsigned int aNewSize )
|
|||
#ifdef __WXDEBUG__
|
||||
totalTime.Stop();
|
||||
|
||||
wxLogTrace( "GAL_CACHED_CONTAINER", "Defragmented container storing %d vertices / %.1f ms",
|
||||
wxLogTrace( traceGalCachedContainer, "Defragmented container storing %d vertices / %.1f ms",
|
||||
m_currentSize - m_freeSpace, totalTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <typeinfo>
|
||||
#include <confirm.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
#include <profile.h>
|
||||
|
@ -111,7 +112,7 @@ void GPU_CACHED_MANAGER::BeginDrawing()
|
|||
if( !m_buffersInitialized )
|
||||
{
|
||||
glGenBuffers( 1, &m_indicesBuffer );
|
||||
checkGlError( "generating vertices buffer" );
|
||||
checkGlError( "generating vertices buffer", __FILE__, __LINE__ );
|
||||
m_buffersInitialized = true;
|
||||
}
|
||||
|
||||
|
@ -198,7 +199,7 @@ 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 );
|
||||
wxLogTrace( traceGalProfile, wxT( "Cached manager size: %d" ), m_indicesSize );
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
|
@ -219,7 +220,7 @@ void GPU_CACHED_MANAGER::EndDrawing()
|
|||
|
||||
#ifdef __WXDEBUG__
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", wxT( "GPU_CACHED_MANAGER::EndDrawing(): %.1f ms" ),
|
||||
wxLogTrace( traceGalProfile, wxT( "GPU_CACHED_MANAGER::EndDrawing(): %.1f ms" ),
|
||||
totalRealTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
}
|
||||
|
@ -299,7 +300,7 @@ 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() );
|
||||
wxLogTrace( traceGalProfile, wxT( "Noncached manager size: %d" ), m_container->GetSize() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
// Deactivate vertex array
|
||||
|
@ -316,7 +317,7 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
|
|||
|
||||
#ifdef __WXDEBUG__
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ),
|
||||
wxLogTrace( traceGalProfile, wxT( "GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ),
|
||||
totalRealTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
}
|
||||
|
|
|
@ -124,21 +124,21 @@ void OPENGL_COMPOSITOR::Initialize()
|
|||
// We need framebuffer objects for drawing the screen contents
|
||||
// Generate framebuffer and a depth buffer
|
||||
glGenFramebuffersEXT( 1, &m_mainFbo );
|
||||
checkGlError( "generating framebuffer" );
|
||||
checkGlError( "generating framebuffer", __FILE__, __LINE__ );
|
||||
bindFb( m_mainFbo );
|
||||
|
||||
// Allocate memory for the depth buffer
|
||||
// Attach the depth buffer to the framebuffer
|
||||
glGenRenderbuffersEXT( 1, &m_depthBuffer );
|
||||
checkGlError( "generating renderbuffer" );
|
||||
checkGlError( "generating renderbuffer", __FILE__, __LINE__ );
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_depthBuffer );
|
||||
checkGlError( "binding renderbuffer" );
|
||||
checkGlError( "binding renderbuffer", __FILE__, __LINE__ );
|
||||
|
||||
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8, dims.x, dims.y );
|
||||
checkGlError( "creating renderbuffer storage" );
|
||||
checkGlError( "creating renderbuffer storage", __FILE__, __LINE__ );
|
||||
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER_EXT, m_depthBuffer );
|
||||
checkGlError( "attaching renderbuffer" );
|
||||
checkGlError( "attaching renderbuffer", __FILE__, __LINE__ );
|
||||
|
||||
// Unbind the framebuffer, so by default all the rendering goes directly to the display
|
||||
bindFb( DIRECT_RENDERING );
|
||||
|
@ -199,15 +199,15 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions )
|
|||
// Generate the texture for the pixel storage
|
||||
glActiveTexture( GL_TEXTURE0 );
|
||||
glGenTextures( 1, &textureTarget );
|
||||
checkGlError( "generating framebuffer texture target" );
|
||||
checkGlError( "generating framebuffer texture target", __FILE__, __LINE__ );
|
||||
glBindTexture( GL_TEXTURE_2D, textureTarget );
|
||||
checkGlError( "binding framebuffer texture target" );
|
||||
checkGlError( "binding framebuffer texture target", __FILE__, __LINE__ );
|
||||
|
||||
// Set texture parameters
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, aDimensions.x, aDimensions.y, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, NULL );
|
||||
checkGlError( "creating framebuffer texture" );
|
||||
checkGlError( "creating framebuffer texture", __FILE__, __LINE__ );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
|
||||
|
@ -300,7 +300,7 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
|||
{
|
||||
m_curBuffer = aBufferHandle - 1;
|
||||
glDrawBuffer( m_buffers[m_curBuffer].attachmentPoint );
|
||||
checkGlError( "setting draw buffer" );
|
||||
checkGlError( "setting draw buffer", __FILE__, __LINE__ );
|
||||
|
||||
glViewport( 0, 0, m_buffers[m_curBuffer].dimensions.x,
|
||||
m_buffers[m_curBuffer].dimensions.y );
|
||||
|
@ -400,7 +400,7 @@ void OPENGL_COMPOSITOR::bindFb( unsigned int aFb )
|
|||
if( m_curFbo != aFb )
|
||||
{
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER, aFb );
|
||||
checkGlError( "switching framebuffer" );
|
||||
checkGlError( "switching framebuffer", __FILE__, __LINE__ );
|
||||
m_curFbo = aFb;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <bitmap_base.h>
|
||||
#include <bezier_curves.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#include <wx/frame.h>
|
||||
|
||||
|
@ -504,7 +505,7 @@ void OPENGL_GAL::beginDrawing()
|
|||
GL_UNSIGNED_BYTE, font_image.pixels );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
checkGlError( "loading bitmap font" );
|
||||
checkGlError( "loading bitmap font", __FILE__, __LINE__ );
|
||||
|
||||
glActiveTexture( GL_TEXTURE0 );
|
||||
|
||||
|
@ -528,13 +529,14 @@ void OPENGL_GAL::beginDrawing()
|
|||
m_shader->SetParameter( ufm_fontTexture, (int) FONT_TEXTURE_UNIT );
|
||||
m_shader->SetParameter( ufm_fontTextureWidth, (int) font_image.width );
|
||||
m_shader->Deactivate();
|
||||
checkGlError( "setting bitmap font sampler as shader parameter" );
|
||||
checkGlError( "setting bitmap font sampler as shader parameter", __FILE__, __LINE__ );
|
||||
|
||||
m_isBitmapFontInitialized = true;
|
||||
}
|
||||
|
||||
m_shader->Use();
|
||||
m_shader->SetParameter( ufm_worldPixelSize, (float) ( getWorldPixelSize() / GetScaleFactor() ) );
|
||||
m_shader->SetParameter( ufm_worldPixelSize,
|
||||
(float) ( getWorldPixelSize() / GetScaleFactor() ) );
|
||||
m_shader->SetParameter( ufm_screenPixelSize, getScreenPixelSize() );
|
||||
double pixelSizeMultiplier = m_compositor->GetAntialiasSupersamplingFactor();
|
||||
m_shader->SetParameter( ufm_pixelSizeMultiplier, (float) pixelSizeMultiplier );
|
||||
|
@ -549,7 +551,7 @@ void OPENGL_GAL::beginDrawing()
|
|||
|
||||
#ifdef __WXDEBUG__
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", wxT( "OPENGL_GAL::beginDrawing(): %.1f ms" ),
|
||||
wxLogTrace( traceGalProfile, wxT( "OPENGL_GAL::beginDrawing(): %.1f ms" ),
|
||||
totalRealTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
}
|
||||
|
@ -590,7 +592,8 @@ void OPENGL_GAL::endDrawing()
|
|||
|
||||
#ifdef __WXDEBUG__
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", wxT( "OPENGL_GAL::endDrawing(): %.1f ms" ), totalRealTime.msecs() );
|
||||
wxLogTrace( traceGalProfile, wxT( "OPENGL_GAL::endDrawing(): %.1f ms" ),
|
||||
totalRealTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
}
|
||||
|
||||
|
@ -750,15 +753,15 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
|
|||
*/
|
||||
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 1.0, aRadius, m_lineWidth );
|
||||
m_currentManager->Vertex( aCenterPoint.x, // v0
|
||||
aCenterPoint.y, m_layerDepth );
|
||||
aCenterPoint.y, m_layerDepth );
|
||||
|
||||
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 2.0, aRadius, m_lineWidth );
|
||||
m_currentManager->Vertex( aCenterPoint.x, // v1
|
||||
aCenterPoint.y, m_layerDepth );
|
||||
aCenterPoint.y, m_layerDepth );
|
||||
|
||||
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 3.0, aRadius, m_lineWidth );
|
||||
m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, // v2
|
||||
m_layerDepth );
|
||||
m_layerDepth );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,9 +791,11 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
{
|
||||
m_currentManager->Reserve( 3 );
|
||||
m_currentManager->Vertex( 0.0, 0.0, m_layerDepth );
|
||||
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, m_layerDepth );
|
||||
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius,
|
||||
m_layerDepth );
|
||||
alpha += alphaIncrement;
|
||||
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, m_layerDepth );
|
||||
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius,
|
||||
m_layerDepth );
|
||||
}
|
||||
|
||||
// The last missing triangle
|
||||
|
@ -1256,7 +1261,9 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|||
|
||||
switch( GetHorizontalJustify() )
|
||||
{
|
||||
case GR_TEXT_HJUSTIFY_CENTER: Translate( VECTOR2D( -textSize.x / 2.0, 0 ) ); break;
|
||||
case GR_TEXT_HJUSTIFY_CENTER:
|
||||
Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
|
||||
break;
|
||||
|
||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||
//if( !IsTextMirrored() )
|
||||
|
@ -1281,7 +1288,8 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|||
overbarHeight = 0;
|
||||
break;
|
||||
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM: break;
|
||||
case GR_TEXT_VJUSTIFY_BOTTOM:
|
||||
break;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
@ -1688,7 +1696,6 @@ void OPENGL_GAL::ClearTarget( RENDER_TARGET aTarget )
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if( aTarget != TARGET_OVERLAY )
|
||||
m_compositor->ClearBuffer( m_clearColor );
|
||||
else if( m_overlayBuffer )
|
||||
|
@ -1778,7 +1785,8 @@ void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, d
|
|||
|
||||
if( m_isStrokeEnabled )
|
||||
{
|
||||
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a );
|
||||
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
||||
m_strokeColor.a );
|
||||
drawStrokedSemiCircle( aCenterPoint, aRadius, aAngle );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,17 @@
|
|||
#include <wx/log.h> // wxLogDebug
|
||||
|
||||
|
||||
int checkGlError( const std::string& aInfo, bool aThrow )
|
||||
/**
|
||||
* Flag to enable debug output of the GAL OpenGL error checking.
|
||||
*
|
||||
* Use "KICAD_GAL_OPENGL_ERROR" to enable GAL OpenGL error tracing.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
static const wxChar* const traceGalOpenGlError = wxT( "KICAD_GAL_OPENGL_ERROR" );
|
||||
|
||||
|
||||
int checkGlError( const std::string& aInfo, const char* aFile, int aLine, bool aThrow )
|
||||
{
|
||||
int result = glGetError();
|
||||
wxString errorMsg;
|
||||
|
@ -128,9 +138,20 @@ int checkGlError( const std::string& aInfo, bool aThrow )
|
|||
if( result != GL_NO_ERROR )
|
||||
{
|
||||
if( aThrow )
|
||||
{
|
||||
wxLogTrace( traceGalOpenGlError, wxT( "Throwing exection for glGetError() '%s' "
|
||||
"in file '%s' on line %d." ), errorMsg,
|
||||
aFile, aLine );
|
||||
throw std::runtime_error( (const char*) errorMsg.char_str() );
|
||||
}
|
||||
else
|
||||
DisplayErrorMessage( nullptr, "OpenGL error occurred", errorMsg );
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( wxT( "glGetError() '%s' in file '%s' on line %d." ),
|
||||
errorMsg, aFile, aLine );
|
||||
DisplayErrorMessage( nullptr, "OpenGL Error", errorMsg );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2018-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -49,6 +49,7 @@ const wxChar* const traceSymbolResolver = wxT( "KICAD_SYM_RESOLVE" );
|
|||
const wxChar* const traceDisplayLocation = wxT( "KICAD_DISPLAY_LOCATION" );
|
||||
const wxChar* const traceSchSheetPaths = wxT( "KICAD_SCH_SHEET_PATHS" );
|
||||
const wxChar* const traceEnvVars = wxT( "KICAD_ENV_VARS" );
|
||||
const wxChar* const traceGalProfile = wxT( "KICAD_GAL_PROFILE" );
|
||||
|
||||
|
||||
wxString dump( const wxArrayString& aArray )
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <eda_item.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
#include <view/view.h>
|
||||
#include <view/view_group.h>
|
||||
|
@ -1148,7 +1149,7 @@ void VIEW::Redraw()
|
|||
|
||||
#ifdef __WXDEBUG__
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
|
||||
wxLogTrace( traceGalProfile, "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
|
||||
#endif /* __WXDEBUG__ */
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016-2017 CERN
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -28,16 +29,21 @@
|
|||
#include <string>
|
||||
|
||||
/**
|
||||
* @brief Checks if one of recent OpenGL operations has failed. If so, it displays appropriate
|
||||
* message, starting with aInfo string to give more details.
|
||||
* Check if a recent OpenGL operation has failed. If so, display the appropriate message
|
||||
* starting with \a aInfo string to give more details.
|
||||
*
|
||||
* @param aInfo is the beginning of the error message.
|
||||
* @param aFile is the file where the error occurred defined by the C __FILE__ variable.
|
||||
* @param aLine is the line in \a aFile where the error occurred defined by the C __LINE__
|
||||
* variable.
|
||||
* @param aThrow an exception is thrown when true, otherwise only an error message is displayed.
|
||||
* @return GL_NO_ERROR in case of no errors or one of GL_ constants returned by glGetError().
|
||||
*/
|
||||
int checkGlError( const std::string& aInfo, bool aThrow = true );
|
||||
int checkGlError( const std::string& aInfo, const char* aFile, int aLine, bool aThrow = true );
|
||||
|
||||
/**
|
||||
* @brief Enables/disables OpenGL driver messages output.
|
||||
* Enable or disable OpenGL driver messages output.
|
||||
*
|
||||
* @param aEnable decides whether the message should be shown.
|
||||
*/
|
||||
void enableGlDebug( bool aEnable );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2018-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -178,10 +178,16 @@ extern const wxChar* const traceSchSheetPaths;
|
|||
* Flag to enable debug output of environment variable operations.
|
||||
*
|
||||
* Use "KICAD_ENV_VARS" to enable.
|
||||
*
|
||||
*/
|
||||
extern const wxChar* const traceEnvVars;
|
||||
|
||||
/**
|
||||
* Flag to enable debug output of GAL performance profiling.
|
||||
*
|
||||
* Use "KICAD_GAL_PROFILE" to enable.
|
||||
*/
|
||||
extern const wxChar* const traceGalProfile;
|
||||
|
||||
///@}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue