MAMEWorld >> EmuChat
View all threads Index   Flat Mode Flat  

Calamity
MAME Fan
Reged: 05/30/11
Posts: 56
Send PM
Re: MAME input "flickering"
07/23/15 11:35 AM


You may want to have a look at the multithreading implementation in GroovyMAME (only for the Windows OSD, I don't fully understand how baseline manages worker threads from the SDL side).

With GroovyMAME implementation, -triplebuffer enables background v-sync (e.g. run 55 Hz game on 60 Hz monitor at 100% with no tearing), while -syncrefresh forces the main and blitting threads to wait for each other.

Obviously the -triplebuffer idea (asynchronous blitting) requires being able to drop frames, which D3D9 doesn't allow natively (apparently D3D9ex does with the D3DPRESENT_FORCEIMMEDIATE flag). What we are doing is, in the window_update function, try to get the lock instead of acquiring it, and if it fails just exit without drawing. The rendering is done in a third thread separated from the window thread and the main thread. It's cumbersome but it's the only way I found to achieve this with D3D.

As it's currently implemented in baseline, you do the draw operations from the window thread, which is detached from the main thread. This is a bad idea, because the window thread also processes input, and if you v-sync you stall the thread so input gets seriously affected. It's even worse if the emulation and the screen are refreshing at different rates, because you may get weird no-input interference patterns, as it's probably the issue reported by OP.

Unfortunately the weakness of GM's implementation is that D3D still forces you to create the device from the window proc thread so the synchronization with the blitting thread is prone to dead-locks if you're not very careful. Besides you can't use this method with multiple windows.







Entire thread
Subject Posted by Posted on
* MAME input "flickering" Procyon 07/01/15 05:14 AM
. * Re: MAME input "flickering" Comboman  07/02/15 02:29 PM
. * Re: MAME input "flickering" R. Belmont  07/01/15 05:25 PM
. * Re: MAME input "flickering" Procyon  07/01/15 06:38 PM
. * Re: MAME input "flickering" R. Belmont  07/01/15 07:30 PM
. * Re: MAME input "flickering" Procyon  07/08/15 01:35 AM
. * Re: MAME input "flickering" R. Belmont  07/08/15 07:56 PM
. * Re: MAME input "flickering" Procyon  07/13/15 03:34 PM
. * Re: MAME input "flickering" R. Belmont  07/13/15 07:26 PM
. * Re: MAME input "flickering" Procyon  07/19/15 11:42 PM
. * Re: MAME input "flickering" R. Belmont  07/21/15 05:22 PM
. * Re: MAME input "flickering" couriersud  07/22/15 07:29 PM
. * Re: MAME input "flickering" R. Belmont  07/22/15 09:27 PM
. * Re: MAME input "flickering" couriersud  07/22/15 11:10 PM
. * Re: MAME input "flickering" Calamity  07/23/15 11:35 AM
. * Re: MAME input "flickering" couriersud  07/23/15 10:05 PM
. * Re: MAME input "flickering" B2K24  07/21/15 09:22 PM
. * Re: MAME input "flickering" TafoidAdministrator  07/19/15 11:45 PM
. * Re: MAME input "flickering" Procyon  07/02/15 04:24 AM

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 156 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2586