Fix GET_PREFERRED_HW_RENDER handling and fallback

Core now properly falls back to software renderer when requested
hardware context is not Vulkan/OpenGL instead of defaulting to Vulkan
for every context other than OpenGL. Core now also checks each hardware
renderer instead of only Vulkan for frontends that do not support
RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER.
This commit is contained in:
ggdrt 2019-12-03 16:42:02 -08:00
parent 93a187f699
commit 748d4f80e3

View File

@ -3721,17 +3721,26 @@ bool rsx_intf_open(bool is_pal, bool force_software)
software_selected = true;
}
else
{
/* If 'BEETLE_OPT(renderer)' option is not found, then
* we are running in software mode */
software_selected = true;
}
if (!software_selected)
{
unsigned preferred; // This will be set to a const value if GET_PREFERRED_HW_RENDER is not supported by frontend
if (!environ_cb(RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER, &preferred)) preferred = 0xFFFFFFFF;
unsigned preferred = 0; // This will be set to RETRO_HW_CONTEXT_DUMMY if GET_PREFERRED_HW_RENDER is not supported by frontend
if (!environ_cb(RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER, &preferred))
{
preferred = RETRO_HW_CONTEXT_DUMMY;
}
/* If GET_PREFERRED_HW_RENDER is not supported by frontend, then we just go
* down the list attempting to open a hardware renderer until we get one */
#if defined(HAVE_VULKAN)
if ((preferred == 0xFFFFFFFF || (preferred != RETRO_HW_CONTEXT_OPENGL_CORE && preferred != RETRO_HW_CONTEXT_OPENGL)) && rsx_vulkan_open(is_pal))
if ((preferred == RETRO_HW_CONTEXT_DUMMY ||
preferred == RETRO_HW_CONTEXT_VULKAN)
&& rsx_vulkan_open(is_pal))
{
rsx_type = RSX_VULKAN;
vk_initialized = true;
@ -3740,20 +3749,29 @@ bool rsx_intf_open(bool is_pal, bool force_software)
#endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
if (rsx_gl_open(is_pal))
if ((preferred == RETRO_HW_CONTEXT_DUMMY ||
preferred == RETRO_HW_CONTEXT_OPENGL ||
preferred == RETRO_HW_CONTEXT_OPENGL_CORE)
&& rsx_gl_open(is_pal))
{
rsx_type = RSX_OPENGL;
gl_initialized = true;
goto end;
}
#endif
if (preferred == RETRO_HW_CONTEXT_DUMMY)
MDFN_DispMessage("No hardware renderers could be opened. Falling back to software renderer.");
else
MDFN_DispMessage("Unable to find or open hardware renderer for frontend preferred hardware context. Falling back to software renderer.");
}
// rsx_soft_open(is_pal) always returns true
if (rsx_soft_open(is_pal))
{
rsx_type = RSX_SOFTWARE;
goto end;
rsx_type = RSX_SOFTWARE;
return rsx_intf_open(is_pal, force_software);
}
end:
#if defined(RSX_DUMP)