Add a method to force KiCad to software rendering

There are enough cases of problematic OpenGL implementations to need a
way to avoid calling OpenGL in the first place.  This provides a
temporary method for people experiencing crashing KiCad or starting
KiCad over a remote terminal to temporarily enforce software rendering
This commit is contained in:
Seth Hillbrand 2025-07-27 17:22:02 -07:00
parent a191d4e6e5
commit 0271047b26
2 changed files with 28 additions and 0 deletions

View File

@ -944,6 +944,19 @@ EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::loadCanvasTypeSetting( APP_SETTING
if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
wxString envCanvasType;
if( wxGetEnv( "KICAD_SOFTWARE_RENDERING", &envCanvasType ) )
{
if( envCanvasType.CmpNoCase( "1" ) == 0
|| envCanvasType.CmpNoCase( "true" ) == 0
|| envCanvasType.CmpNoCase( "yes" ) == 0 )
{
// Force software rendering if the environment variable is set
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
}
}
return canvasType;
}
@ -964,6 +977,12 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
if( !alg::contains( s_allowedFrames, m_ident ) )
return false;
if( wxGetEnv( "KICAD_SOFTWARE_RENDERING", nullptr ) )
{
// If the environment variable is set, don't save the canvas type.
return false;
}
if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
|| aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
{

View File

@ -104,6 +104,10 @@ bool PGM_KICAD::OnPgmInit()
{ wxCMD_LINE_OPTION, "f", "frame", "Frame to load", wxCMD_LINE_VAL_STRING, 0 },
{ wxCMD_LINE_SWITCH, "n", "new", "New instance of KiCad, does not attempt to load previously open files",
wxCMD_LINE_VAL_NONE, 0 },
#ifndef __WXOSX__
{ wxCMD_LINE_SWITCH, nullptr, "software-rendering", "Use software rendering instead of OpenGL",
wxCMD_LINE_VAL_NONE, 0 },
#endif
{ wxCMD_LINE_PARAM, nullptr, nullptr, "File to load", wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 }
@ -158,6 +162,11 @@ bool PGM_KICAD::OnPgmInit()
Kiway.SetCtlBits( KFCTL_STANDALONE );
}
if( parser.Found( "software-rendering" ) )
{
wxSetEnv( "KICAD_SOFTWARE_RENDERING", "1" );
}
bool skipPythonInit = false;
if( appType == FRAME_BM2CMP || appType == FRAME_PL_EDITOR || appType == FRAME_GERBER