diff options
Diffstat (limited to 'src/osd/windows')
-rw-r--r-- | src/osd/windows/input.cpp | 39 | ||||
-rw-r--r-- | src/osd/windows/output.cpp | 4 | ||||
-rw-r--r-- | src/osd/windows/video.cpp | 7 | ||||
-rw-r--r-- | src/osd/windows/video.h | 6 | ||||
-rw-r--r-- | src/osd/windows/window.cpp | 62 | ||||
-rw-r--r-- | src/osd/windows/window.h | 3 | ||||
-rw-r--r-- | src/osd/windows/winmain.cpp | 3 | ||||
-rw-r--r-- | src/osd/windows/winmain.h | 6 |
8 files changed, 75 insertions, 55 deletions
diff --git a/src/osd/windows/input.cpp b/src/osd/windows/input.cpp index 6a9d534a2f6..0165e4820f0 100644 --- a/src/osd/windows/input.cpp +++ b/src/osd/windows/input.cpp @@ -39,7 +39,6 @@ #include "config.h" #include "winutil.h" -#include <mutex> //============================================================ // PARAMETERS @@ -167,7 +166,7 @@ typedef /*WINUSERAPI*/ BOOL (WINAPI *register_rawinput_devices_ptr)(IN PCRAWINPU // global states static bool input_enabled; -static std::mutex input_lock; +static osd_lock * input_lock; static bool input_paused; static DWORD last_poll; @@ -470,6 +469,10 @@ static inline INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawma bool windows_osd_interface::input_init() { + // allocate a lock for input synchronizations, since messages sometimes come from another thread + input_lock = osd_lock_alloc(); + assert_always(input_lock != NULL, "Failed to allocate input_lock"); + // decode the options lightgun_shared_axis_mode = downcast<windows_options &>(machine().options()).dual_lightgun(); @@ -509,8 +512,15 @@ void windows_osd_interface::input_resume() void windows_osd_interface::input_exit() { // acquire the lock and turn off input (this ensures everyone is done) - std::lock_guard<std::mutex> lock(input_lock); - input_enabled = false; + if (input_lock != NULL) + { + osd_lock_acquire(input_lock); + input_enabled = false; + osd_lock_release(input_lock); + + // free the lock + osd_lock_free(input_lock); + } } @@ -603,7 +613,7 @@ BOOL wininput_handle_mouse_button(int button, int down, int x, int y) } // take the lock - std::lock_guard<std::mutex> lock(input_lock); + osd_lock_acquire(input_lock); // set the button state devinfo->mouse.state.rgbButtons[button] = down ? 0x80 : 0x00; @@ -622,6 +632,9 @@ BOOL wininput_handle_mouse_button(int button, int down, int x, int y) devinfo->mouse.state.lX = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right); devinfo->mouse.state.lY = normalize_absolute_axis(mousepos.y, client_rect.top, client_rect.bottom); } + + // release the lock + osd_lock_release(input_lock); return TRUE; } @@ -648,7 +661,7 @@ BOOL wininput_handle_raw(HANDLE device) // if necessary, allocate a temporary buffer and fetch the data if (size > sizeof(small_buffer)) { - data = global_alloc_array_nothrow(BYTE, size); + data = global_alloc_array(BYTE, size); if (data == NULL) return result; } @@ -662,16 +675,18 @@ BOOL wininput_handle_raw(HANDLE device) // handle keyboard input if (input->header.dwType == RIM_TYPEKEYBOARD) { - std::lock_guard<std::mutex> lock(input_lock); + osd_lock_acquire(input_lock); rawinput_keyboard_update(input->header.hDevice, &input->data.keyboard); + osd_lock_release(input_lock); result = TRUE; } // handle mouse input else if (input->header.dwType == RIM_TYPEMOUSE) { - std::lock_guard<std::mutex> lock(input_lock); + osd_lock_acquire(input_lock); rawinput_mouse_update(input->header.hDevice, &input->data.mouse); + osd_lock_release(input_lock); result = TRUE; } } @@ -789,11 +804,6 @@ void windows_osd_interface::customize_input_type_list(simple_list<input_type_ent entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT); break; - // add a NOT-lalt to write timecode file - case IPT_UI_TIMECODE: // emu/input.c: input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) - entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT); - break; - // lctrl-lalt-F5 to toggle post-processing case IPT_OSD_4: entry->configure_osd("POST_PROCESS", "Toggle Post-Processing"); @@ -2191,13 +2201,14 @@ static void rawinput_mouse_poll(device_info *devinfo) poll_if_necessary(devinfo->machine()); // copy the accumulated raw state to the actual state - std::lock_guard<std::mutex> lock(input_lock); + osd_lock_acquire(input_lock); devinfo->mouse.state.lX = devinfo->mouse.raw_x; devinfo->mouse.state.lY = devinfo->mouse.raw_y; devinfo->mouse.state.lZ = devinfo->mouse.raw_z; devinfo->mouse.raw_x = 0; devinfo->mouse.raw_y = 0; devinfo->mouse.raw_z = 0; + osd_lock_release(input_lock); } diff --git a/src/osd/windows/output.cpp b/src/osd/windows/output.cpp index ef3c563e3ac..3b390b1f3a1 100644 --- a/src/osd/windows/output.cpp +++ b/src/osd/windows/output.cpp @@ -313,8 +313,8 @@ static void notifier_callback(const char *outname, INT32 value, void *param) // loop over clients and notify them for (client = clientlist; client != nullptr; client = client->next) { - if (param == nullptr || param == client->machine) { + printf("there are clients\n"); + if (param == nullptr || param == client) PostMessage(client->hwnd, om_mame_update_state, client->machine->output().name_to_id(outname), value); - } } } diff --git a/src/osd/windows/video.cpp b/src/osd/windows/video.cpp index b441121f1ca..b4f665a2135 100644 --- a/src/osd/windows/video.cpp +++ b/src/osd/windows/video.cpp @@ -373,10 +373,14 @@ void windows_osd_interface::extract_video_config() video_config.mode = VIDEO_MODE_D3D; else if (strcmp(stemp, "auto") == 0) video_config.mode = VIDEO_MODE_D3D; + else if (strcmp(stemp, "ddraw") == 0) + video_config.mode = VIDEO_MODE_DDRAW; else if (strcmp(stemp, "gdi") == 0) video_config.mode = VIDEO_MODE_GDI; +#if defined (USE_BGFX) else if (strcmp(stemp, "bgfx") == 0) video_config.mode = VIDEO_MODE_BGFX; +#endif else if (strcmp(stemp, "none") == 0) { video_config.mode = VIDEO_MODE_NONE; @@ -397,6 +401,9 @@ void windows_osd_interface::extract_video_config() video_config.triplebuf = options().triple_buffer(); video_config.switchres = options().switch_res(); + // ddraw options: extract the data + video_config.hwstretch = options().hwstretch(); + if (video_config.prescale < 1 || video_config.prescale > 3) { osd_printf_warning("Invalid prescale option, reverting to '1'\n"); diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index 87612fb51fe..9215dc189bf 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -21,7 +21,10 @@ enum { VIDEO_MODE_NONE, VIDEO_MODE_GDI, + VIDEO_MODE_DDRAW, +#if defined (USE_BGFX) VIDEO_MODE_BGFX, +#endif #if (USE_OPENGL) VIDEO_MODE_OPENGL, #endif @@ -177,6 +180,9 @@ struct osd_video_config int fullstretch; // FXIME: implement in windows! + // ddraw options + int hwstretch; // stretch using the hardware + // d3d, accel, opengl int filter; // enable filtering //int filter; // enable filtering, disabled if glsl_filter>0 diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 0fbfae9c481..6111859a255 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -36,8 +36,11 @@ extern int drawnone_init(running_machine &machine, osd_draw_callbacks *callbacks); extern int drawgdi_init(running_machine &machine, osd_draw_callbacks *callbacks); +extern int drawdd_init(running_machine &machine, osd_draw_callbacks *callbacks); extern int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks); +#if defined(USE_BGFX) extern int drawbgfx_init(running_machine &machine, osd_draw_callbacks *callbacks); +#endif #if (USE_OPENGL) extern int drawogl_init(running_machine &machine, osd_draw_callbacks *callbacks); #endif @@ -130,11 +133,11 @@ struct mtlog }; static mtlog mtlog[100000]; -static volatile INT32 mtlogindex; +static volatile LONG mtlogindex; void mtlog_add(const char *event) { - int index = atomic_increment32((INT32 *) &mtlogindex) - 1; + int index = atomic_increment32((LONG *) &mtlogindex) - 1; if (index < ARRAY_LENGTH(mtlog)) { mtlog[index].timestamp = osd_ticks(); @@ -218,10 +221,17 @@ bool windows_osd_interface::window_init() if (drawd3d_init(machine(), &draw)) video_config.mode = VIDEO_MODE_GDI; } + if (video_config.mode == VIDEO_MODE_DDRAW) + { + if (drawdd_init(machine(), &draw)) + video_config.mode = VIDEO_MODE_GDI; + } if (video_config.mode == VIDEO_MODE_GDI) drawgdi_init(machine(), &draw); +#if defined(USE_BGFX) if (video_config.mode == VIDEO_MODE_BGFX) drawbgfx_init(machine(), &draw); +#endif if (video_config.mode == VIDEO_MODE_NONE) drawnone_init(machine(), &draw); #if (USE_OPENGL) @@ -252,6 +262,7 @@ void windows_osd_interface::window_exit() win_window_list = temp->m_next; temp->destroy(); global_free(temp); + } // kill the drawers @@ -289,6 +300,7 @@ win_window_info::win_window_info(running_machine &machine) m_fullscreen(0), m_fullscreen_safe(0), m_aspect(0), + m_render_lock(NULL), m_target(NULL), m_targetview(0), m_targetorient(0), @@ -649,20 +661,7 @@ void win_window_info::create(running_machine &machine, int index, osd_monitor_in window->m_win_config = *config; window->m_monitor = monitor; window->m_fullscreen = !video_config.windowed; - window->m_index = index; - // set main window - if (index > 0) - { - for (auto w = win_window_list; w != NULL; w = w->m_next) - { - if (w->m_index == 0) - { - window->m_main = w; - break; - } - } - } // see if we are safe for fullscreen window->m_fullscreen_safe = TRUE; for (win = win_window_list; win != NULL; win = win->m_next) @@ -673,6 +672,9 @@ void win_window_info::create(running_machine &machine, int index, osd_monitor_in *last_window_ptr = window; last_window_ptr = &window->m_next; + // create a lock that we can use to skip blitting + window->m_render_lock = osd_lock_alloc(); + // load the layout window->m_target = machine.render().target_alloc(); @@ -744,6 +746,11 @@ void win_window_info::destroy() // free the render target machine().render().target_free(m_target); + + // FIXME: move to destructor + // free the lock + osd_lock_free(m_render_lock); + } @@ -785,15 +792,15 @@ void win_window_info::update() // if we're visible and running and not in the middle of a resize, draw if (m_hwnd != NULL && m_target != NULL && m_renderer != NULL) { - bool got_lock = true; + int got_lock = TRUE; mtlog_add("winwindow_video_window_update: try lock"); // only block if we're throttled if (machine().video().throttled() || timeGetTime() - last_update_time > 250) - m_render_lock.lock(); + osd_lock_acquire(m_render_lock); else - got_lock = m_render_lock.try_lock(); + got_lock = osd_lock_try(m_render_lock); // only render if we were able to get the lock if (got_lock) @@ -803,7 +810,7 @@ void win_window_info::update() mtlog_add("winwindow_video_window_update: got lock"); // don't hold the lock; we just used it to see if rendering was still happening - m_render_lock.unlock(); + osd_lock_release(m_render_lock); // ensure the target bounds are up-to-date, and then get the primitives primlist = m_renderer->get_primitives(); @@ -1322,14 +1329,6 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR window->machine().ui_input().push_char_event(window->m_target, (unicode_char) wparam); break; - case WM_MOUSEWHEEL: - { - UINT ucNumLines = 3; // default - SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0); - window->machine().ui_input().push_mouse_wheel_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), GET_WHEEL_DELTA_WPARAM(wparam), ucNumLines); - break; - } - // pause the system when we start a menu or resize case WM_ENTERSIZEMOVE: window->m_resize_state = RESIZE_STATE_RESIZING; @@ -1412,9 +1411,9 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR case WM_DESTROY: if (!(window->m_renderer == NULL)) { - window->m_renderer->destroy(); - global_free(window->m_renderer); - window->m_renderer = NULL; + window->m_renderer->destroy(); + global_free(window->m_renderer); + window->m_renderer = NULL; } window->m_hwnd = NULL; return DefWindowProc(wnd, message, wparam, lparam); @@ -1493,7 +1492,7 @@ void win_window_info::draw_video_contents(HDC dc, int update) mtlog_add("draw_video_contents: begin"); mtlog_add("draw_video_contents: render lock acquire"); - std::lock_guard<std::mutex> lock(m_render_lock); + osd_lock_acquire(m_render_lock); mtlog_add("draw_video_contents: render lock acquired"); // if we're iconic, don't bother @@ -1517,6 +1516,7 @@ void win_window_info::draw_video_contents(HDC dc, int update) } } + osd_lock_release(m_render_lock); mtlog_add("draw_video_contents: render lock released"); mtlog_add("draw_video_contents: end"); diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index 6a925494f93..62d4f57db55 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -9,7 +9,6 @@ #ifndef __WIN_WINDOW__ #define __WIN_WINDOW__ -#include <mutex> #include "video.h" #include "render.h" @@ -93,7 +92,7 @@ public: float m_aspect; // rendering info - std::mutex m_render_lock; + osd_lock * m_render_lock; render_target * m_target; int m_targetview; int m_targetorient; diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index cfa0a4fb0b7..08c988e2311 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -283,8 +283,6 @@ const options_entry windows_options::s_option_entries[] = { NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" }, { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" }, { WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" }, - { WINOPTION_HLSL_PRESCALE_X, "0", OPTION_INTEGER, "HLSL pre-scale override factor for X (0 for auto)" }, - { WINOPTION_HLSL_PRESCALE_Y, "0", OPTION_INTEGER, "HLSL pre-scale override factor for Y (0 for auto)" }, { WINOPTION_HLSL_WRITE, NULL, OPTION_STRING, "enables HLSL AVI writing (huge disk bandwidth suggested)" }, { WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" }, { WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" }, @@ -526,6 +524,7 @@ windows_osd_interface::~windows_osd_interface() void windows_osd_interface::video_register() { video_options_add("gdi", NULL); + video_options_add("ddraw", NULL); video_options_add("d3d", NULL); video_options_add("bgfx", NULL); //video_options_add("auto", NULL); // making d3d video default one diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 260919961f5..63dd907d3b3 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -31,8 +31,6 @@ // core post-processing options #define WINOPTION_HLSL_ENABLE "hlsl_enable" #define WINOPTION_HLSLPATH "hlslpath" -#define WINOPTION_HLSL_PRESCALE_X "hlsl_prescale_x" -#define WINOPTION_HLSL_PRESCALE_Y "hlsl_prescale_y" #define WINOPTION_HLSL_WRITE "hlsl_write" #define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width" #define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height" @@ -112,6 +110,8 @@ #define WINOPTION_GLOBAL_INPUTS "global_inputs" #define WINOPTION_DUAL_LIGHTGUN "dual_lightgun" + + //============================================================ // TYPE DEFINITIONS //============================================================ @@ -136,8 +136,6 @@ public: const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); } bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); } const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); } - int d3d_hlsl_prescale_x() const { return int_value(WINOPTION_HLSL_PRESCALE_X); } - int d3d_hlsl_prescale_y() const { return int_value(WINOPTION_HLSL_PRESCALE_Y); } int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); } int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); } int screen_shadow_mask_tile_mode() const { return int_value(WINOPTION_SHADOW_MASK_TILE_MODE); } |