BGFX: fix crash when bgfx effect folder is not present or incomplete

BGFX renderer requires some effects also when post-processing is disabled. If they are not available, MAME complains about missing effect files, but then goes on and crashes soon after printing the backtrace. This fix just exits gracefully when effect files are incomplete and falls back to a different renderer if the bgfx folder is missing at all, warning the user in advance.
This commit is contained in:
Giuseppe Gorgoglione 2016-07-15 13:32:36 +02:00
parent 1b60ff15bb
commit 14f5329fd4
3 changed files with 22 additions and 2 deletions

View File

@ -235,6 +235,12 @@ int renderer_bgfx::create()
m_screen_effect[2] = m_effects->effect("screen_multiply");
m_screen_effect[3] = m_effects->effect("screen_add");
if ( m_gui_effect[0] == nullptr || m_gui_effect[1] == nullptr || m_gui_effect[2] == nullptr || m_gui_effect[3] == nullptr ||
m_screen_effect[0] == nullptr || m_screen_effect[1] == nullptr || m_screen_effect[2] == nullptr || m_screen_effect[3] == nullptr)
{
fatalerror("BGFX: Unable to load required shaders. Please check and reinstall the %s folder\n", m_options.bgfx_path());
}
m_chains = new chain_manager(win->machine(), m_options, *m_textures, *m_targets, *m_effects, win->m_index, *this);
m_sliders_dirty = true;
@ -283,6 +289,20 @@ void renderer_bgfx::record()
}
}
bool renderer_bgfx::init(running_machine &machine)
{
const char *bgfx_path = downcast<osd_options &>(machine.options()).bgfx_path();
osd::directory::ptr directory = osd::directory::open(bgfx_path);
if (directory == nullptr)
{
osd_printf_verbose("Unable to find the %s folder. Please reinstall it to use the BGFX renderer\n", bgfx_path);
return true;
}
return false;
}
void renderer_bgfx::exit()
{
imguiDestroy();

View File

@ -36,7 +36,7 @@ public:
renderer_bgfx(std::shared_ptr<osd_window> w);
virtual ~renderer_bgfx();
static void init(running_machine &machine) { }
static bool init(running_machine &machine);
static void exit();
virtual int create() override;

View File

@ -172,7 +172,7 @@ bool windows_osd_interface::window_init()
error = renderer_gdi::init(machine());
break;
case VIDEO_MODE_BGFX:
renderer_bgfx::init(machine());
error = renderer_bgfx::init(machine());
break;
#if (USE_OPENGL)
case VIDEO_MODE_OPENGL: