summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-09-29 01:56:51 +1000
committer Vas Crabb <vas@vastheman.com>2023-09-29 01:56:51 +1000
commitd71c72ba746503934102788e5dcbb487c6134396 (patch)
treeed63fa00eb24d7f608a68e77c4c517888e4c873b /src/osd
parent117c384d4ac65c06481f7a0631051c8ba273c0b5 (diff)
Miscellaneous change roll-up:
render/drawbgfx.cpp: Return an error if Wayland EGL surface can't be created for additional windows. emu/emucore.h: Added explicitly defaulted copy and move constructors for emu_fatalerror. Fixed apparent misunderstanding of const. Returning const value types and casting to const value types is pointless outside very narrow use cases. Putting const value type parameters in interfaces just makes trouble. cpu/adsp2100: Use count_leading_ones_32 where it's simple rather than inverting and counting leading zeroes. util/multibyte.h: Don't pollute global namespace, constexpr implies inline, make narrowing casts explicit. imagedev/simh_tape_image.h: inline is implied for member functions with bodies supplied at declaration. Tidied up some ugly casts in various places.
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/drawbgfx.cpp58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index 19da01898e1..36758914961 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -532,37 +532,40 @@ uint32_t renderer_bgfx::s_height[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//============================================================
#ifdef OSD_SDL
-static void *sdlNativeWindowHandle(SDL_Window *window)
+static std::pair<void *, bool> sdlNativeWindowHandle(SDL_Window *window)
{
SDL_SysWMinfo wmi;
SDL_VERSION(&wmi.version);
if (!SDL_GetWindowWMInfo(window, &wmi))
- return nullptr;
+ return std::make_pair(nullptr, false);
switch (wmi.subsystem)
{
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
case SDL_SYSWM_WINDOWS:
- return wmi.info.win.window;
+ return std::make_pair(wmi.info.win.window, true);
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
case SDL_SYSWM_X11:
- return (void *)uintptr_t(wmi.info.x11.window);
+ return std::make_pair((void *)uintptr_t(wmi.info.x11.window), true);
#endif
#if defined(SDL_VIDEO_DRIVER_COCOA)
case SDL_SYSWM_COCOA:
- return wmi.info.cocoa.window;
+ return std::make_pair(wmi.info.cocoa.window, true);
#endif
#if defined(SDL_VIDEO_DRIVER_WAYLAND) && SDL_VERSION_ATLEAST(2, 0, 16) && defined(SDLMAME_USE_WAYLAND)
case SDL_SYSWM_WAYLAND:
- return osd::create_wl_egl_window(window, wmi.info.wl.surface);
+ {
+ void *const platform_window = osd::create_wl_egl_window(window, wmi.info.wl.surface);
+ return std::make_pair(platform_window, platform_window != nullptr);
+ }
#endif
#if defined(SDL_VIDEO_DRIVER_ANDROID)
case SDL_SYSWM_ANDROID:
- return wmi.info.android.window;
+ return std::make_pair(wmi.info.android.window, true);
#endif
default:
- return nullptr;
+ return std::make_pair(nullptr, false);
}
}
#endif // OSD_SDL
@@ -654,20 +657,6 @@ int renderer_bgfx::create()
m_textures = std::make_unique<texture_manager>();
m_targets = std::make_unique<target_manager>(*m_textures);
- m_shaders = std::make_unique<shader_manager>();
- m_effects = std::make_unique<effect_manager>(*m_shaders);
-
- // Create program from shaders.
- m_gui_effect[0] = m_effects->get_or_load_effect(m_module().options(), "gui_opaque");
- m_gui_effect[1] = m_effects->get_or_load_effect(m_module().options(), "gui_blend");
- m_gui_effect[2] = m_effects->get_or_load_effect(m_module().options(), "gui_multiply");
- m_gui_effect[3] = m_effects->get_or_load_effect(m_module().options(), "gui_add");
-
- m_screen_effect[0] = m_effects->get_or_load_effect(m_module().options(), "screen_opaque");
- m_screen_effect[1] = m_effects->get_or_load_effect(m_module().options(), "screen_blend");
- m_screen_effect[2] = m_effects->get_or_load_effect(m_module().options(), "screen_multiply");
- m_screen_effect[3] = m_effects->get_or_load_effect(m_module().options(), "screen_add");
-
if (window().index() != 0)
{
#ifdef OSD_WINDOWS
@@ -675,7 +664,14 @@ int renderer_bgfx::create()
#elif defined(OSD_MAC)
m_framebuffer = m_targets->create_backbuffer(GetOSWindow(dynamic_cast<mac_window_info &>(window()).platform_window()), s_width[window().index()], s_height[window().index()]);
#else
- m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(dynamic_cast<sdl_window_info &>(window()).platform_window()), s_width[window().index()], s_height[window().index()]);
+ auto const [winhdl, success] = sdlNativeWindowHandle(dynamic_cast<sdl_window_info &>(window()).platform_window());
+ if (!success)
+ {
+ m_targets.reset();
+ m_textures.reset();
+ return -1;
+ }
+ m_framebuffer = m_targets->create_backbuffer(winhdl, s_width[window().index()], s_height[window().index()]);
#endif
bgfx::touch(window().index());
@@ -683,6 +679,20 @@ int renderer_bgfx::create()
m_ortho_view->set_backbuffer(m_framebuffer);
}
+ m_shaders = std::make_unique<shader_manager>();
+ m_effects = std::make_unique<effect_manager>(*m_shaders);
+
+ // Create program from shaders.
+ m_gui_effect[0] = m_effects->get_or_load_effect(m_module().options(), "gui_opaque");
+ m_gui_effect[1] = m_effects->get_or_load_effect(m_module().options(), "gui_blend");
+ m_gui_effect[2] = m_effects->get_or_load_effect(m_module().options(), "gui_multiply");
+ m_gui_effect[3] = m_effects->get_or_load_effect(m_module().options(), "gui_add");
+
+ m_screen_effect[0] = m_effects->get_or_load_effect(m_module().options(), "screen_opaque");
+ m_screen_effect[1] = m_effects->get_or_load_effect(m_module().options(), "screen_blend");
+ m_screen_effect[2] = m_effects->get_or_load_effect(m_module().options(), "screen_multiply");
+ m_screen_effect[3] = m_effects->get_or_load_effect(m_module().options(), "screen_add");
+
const uint32_t max_prescale_size = std::min(2u * std::max(wdim.width(), wdim.height()), m_module().max_texture_size());
m_chains = std::make_unique<chain_manager>(
window().machine(),
@@ -1355,7 +1365,7 @@ bool renderer_bgfx::update_dimensions()
#elif defined(OSD_MAC)
m_framebuffer = m_targets->create_backbuffer(GetOSWindow(dynamic_cast<mac_window_info &>(window()).platform_window()), width, height);
#else
- m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(dynamic_cast<sdl_window_info &>(window()).platform_window()), width, height);
+ m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(dynamic_cast<sdl_window_info &>(window()).platform_window()).first, width, height);
#endif
if (m_ortho_view)
{