MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Pages: 1

Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Mame lags 3 frames in BGFX
#361629 - 12/23/16 06:03 AM


Does anyone know why Mame lags so much when using BGFX renderer? I've recorded a high speed video in 1200fps of thunderx's service screen which has no sprite buffer and I could count 3 frames of lag before the values on the screen changed.



MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 2261
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361645 - 12/23/16 02:46 PM


> Does anyone know why Mame lags so much when using BGFX renderer? I've recorded a high
> speed video in 1200fps of thunderx's service screen which has no sprite buffer and I
> could count 3 frames of lag before the values on the screen changed.

This sounds like a question more for the author of the BGFX library than the authors of MAME: https://github.com/bkaradzic/bgfx

If you get a response from him as to anything we can do on our end to reduce the MAME-to-photon latency, I'd be happy to implement them.



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: MooglyGuy]
#361648 - 12/23/16 02:54 PM


I've already asked him that question. Tried what he advised. Disabling multithreaded renderer in compiler and setting some flags in the preset/reset call, but it made no difference.



MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 2261
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361651 - 12/23/16 03:33 PM


> I've already asked him that question. Tried what he advised. Disabling multithreaded
> renderer in compiler and setting some flags in the preset/reset call, but it made no
> difference.

Not sure what to tell you, then, either.

How does the lag with the BGFX backend compare to the other render backends, e.g. -video d3d9 or -video gdi on Windows?



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: MooglyGuy]
#361652 - 12/23/16 03:54 PM


2 more frames compared to d3d9. 3,5 more frames compared to GroovyMAME d3d9ex. That's a huge difference almost 60ms. It's a pitty as I like the filters in bgfx very much, but cannot use it with such a huge lag. I've spent few nights digging through the sources and trying to solve that mystery, but I ran out of ideas.



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361653 - 12/23/16 03:59 PM


> 2 more frames compared to d3d9. 3,5 more frames compared to GroovyMAME d3d9ex. That's
> a huge difference almost 60ms. It's a pitty as I like the filters in bgfx very much,
> but cannot use it with such a huge lag. I've spent few nights digging through the
> sources and trying to solve that mystery, but I ran out of ideas.

Does bgfx still use the 'borderless full-screen window' appreoach rather than a proper fullscreen mode?

I've always noticed more lag in applications that do that, although I thought it used a proper fullscreen mode now.



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Haze]
#361654 - 12/23/16 04:06 PM


> Does bgfx still use the 'borderless full-screen window' appreoach rather than a
> proper fullscreen mode?
>
> I've always noticed more lag in applications that do that, although I thought it used
> a proper fullscreen mode now.

I think it still uses a fullscreen borderless window. I hope it doesn't lose that feature when it gets fullscreen exclusive capability, because borderless window performs a shitload better than fullscreen exclusive on Quadros.



Envisaged0ne
MAME Fan
Reged: 08/29/06
Posts: 543
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361655 - 12/23/16 06:15 PM


I use bgfx for a few games & can run it, with any of the filters with no lag at all. I'm currently using bgfx mostly with gauntlet legends & gauntlet dark legacy which are pretty demanding games. If you're using any artwork, you might want to try disabling them as that can improve performance



Windows 11 64 bit OS
Intel Core i7-10700
Nvidia GeForce RTX 2060 6GB
32GB DDR4 RAM



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361659 - 12/23/16 09:09 PM


> 2 more frames compared to d3d9. 3,5 more frames compared to GroovyMAME d3d9ex. That's
> a huge difference almost 60ms. It's a pitty as I like the filters in bgfx very much,
> but cannot use it with such a huge lag. I've spent few nights digging through the
> sources and trying to solve that mystery, but I ran out of ideas.

Was vsync enabled for those other modes? Compare with other modes with vsync enabled. I suspect what the problem is. ALSO toggle triple buffering.

Edited by anikom15 (12/23/16 09:17 PM)



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: anikom15]
#361661 - 12/23/16 09:49 PM


I use -syncrefresh -vsync -nothrottle. Why would I want to enable triplebuffering and add an additional one frame to the queue



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Envisaged0ne]
#361662 - 12/23/16 09:54 PM


> I use bgfx for a few games & can run it, with any of the filters with no lag at all.
> I'm currently using bgfx mostly with gauntlet legends & gauntlet dark legacy which
> are pretty demanding games. If you're using any artwork, you might want to try
> disabling them as that can improve performance

I do not use an artwork, the lag is there, believe me, maybe you just got used to it. Test it with a high speed camera and an led. I use canon v1 in 1200fps and an arduino board which pushes keyboard events with just a 1ms latency. I can measure the lag with 1ms accuracy, so I know what I'm talking about.



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361663 - 12/23/16 09:56 PM


> > I use bgfx for a few games & can run it, with any of the filters with no lag at
> all.
> > I'm currently using bgfx mostly with gauntlet legends & gauntlet dark legacy which
> > are pretty demanding games. If you're using any artwork, you might want to try
> > disabling them as that can improve performance
>
> I do not use an artwork, the lag is there, believe me, maybe you just got used to it.
> Test it with a high speed camera and an led. I use canon v1 in 1200fps and an arduino
> board which pushes keyboard events with just a 1ms latency. I can measure the lag
> with 1ms accuracy, so I know what I'm talking about.

nobody is saying it isn't.

the most likely reason is it using the 'borderless full-screen window' instead of an exclusive full-screen mode.

in those modes you seem to get additional lag from Windows *forcing* vsync, and some background window composition stuff.

a lot of games seem to be using that mode now tho unfortunately, wouldn't be surprised if the true full-screen modes end up being phased out by Microsoft which will certainly be a problem.



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Haze]
#361665 - 12/23/16 11:15 PM


I've done some more measurements on Windows 7 to exclude any issues Win10 might have caused. I'm giving you the amount of vblanks the crt passes between the keyboard event and the screen update.

MAME 180 syncrefresh vsync nothrottle notriplebuffer
D3D 5 VBlanks
BGFX 6 VBlanks

GroovyMAME 180 syncrefresh vsync throttle notriplebuffer frame_delay 5
D3D 1-2 VBlanks
BGFX 3-4 VBlanks

The reason of having throttle enabled in GM is that the frame_delay relies on it, but it still does sync the game to the refresh rate. MAME needs to have it disabled otherwise it stutters. GM also incorporates the input polling patch which fixing another 1 frame of latency added by mame after recent input routine changes.

So in original mame the difference is 1 frame between d3d and bgfx. I was comparing Mame BGFx to GroovyMAME BGFX (which is unchanged) in my previous tests.

Anyway the lag is horendous, 6 vblanks is 100ms. When you play on GM for a while with 1 frame of latency and then switch to Mame, it's unplayable.



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361676 - 12/24/16 12:20 AM


> I use -syncrefresh -vsync -nothrottle. Why would I want to enable triplebuffering and
> add an additional one frame to the queue

So you use that with fullscreen in D3D and BGFX still has more lag?

If you are concerned about lag you shouldn't be using vsync at all.



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361678 - 12/24/16 12:32 AM


What games are you experiencing this with, and are you sure you have enough horse under the hood?



Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



Envisaged0ne
MAME Fan
Reged: 08/29/06
Posts: 543
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361685 - 12/24/16 01:58 AM


Trust me, it's not just that I got used to it. I've been using MAME for 19 years and just recently started using bgfx on some games, so I would have noticed. As said by others, it's probably either an option you're using that's helping cause the lag, or your computer isn't powerful enough. BGFX is the most demanding over the others



Windows 11 64 bit OS
Intel Core i7-10700
Nvidia GeForce RTX 2060 6GB
32GB DDR4 RAM



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: anikom15]
#361688 - 12/24/16 03:57 AM


> > I use -syncrefresh -vsync -nothrottle. Why would I want to enable triplebuffering
> and
> > add an additional one frame to the queue
>
> So you use that with fullscreen in D3D and BGFX still has more lag?
>
> If you are concerned about lag you shouldn't be using vsync at all.

I'm sorry, but I'm not a type of person who enjoys tearing. You can achieve a sub 1 frame latencies with vsync on. Calamity did that in his GroovyMame using d3dx9ex functions and adding a frame delay. If you haven't tried that i encourage you to do so.
Mind you when you run mame in bgfx it's not actually an exlusive fulscreen, but a borderless window. Go to the bgfx website and check in the api docs.

Edited by Oomek (12/24/16 04:01 AM)



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Traso]
#361689 - 12/24/16 04:00 AM


> What games are you experiencing this with, and are you sure you have enough horse
> under the hood?

Are you serious by asking that question?
I use a service test screen of thunderx which runs at 600% unthrottled not vsynced, I believe I mentioned that already.



Oomek
MAME Fan
Reged: 05/07/12
Posts: 11
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361690 - 12/24/16 04:08 AM


Nvm, This is the only place I found I could submit some bug reports. I thought I could talk to some ppl here involved in the developement to have a chat and discuss the topic in more technical terms and try to help eliminating the issue. Instead I'm reading advices to upgrade my PC



asasega
MAME Fan
Reged: 02/08/09
Posts: 56
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361964 - 12/29/16 10:43 PM


> Nvm, This is the only place I found I could submit some bug reports. I thought I
> could talk to some ppl here involved in the developement to have a chat and discuss
> the topic in more technical terms and try to help eliminating the issue. Instead I'm
> reading advices to upgrade my PC

Thing is that people confuse the term lag. Some are using the term when there are slowdown in games.
I always just use -syncrefresh and -nothrottle, and don't have tearing, or at least on the 3 different PC that I have acces to



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361966 - 12/29/16 10:50 PM


If you are using vsync and triple buffering with Direct3D in exclusive fullscreen than it is equivalent to running in a borderless window. There must be some of other source for the lag.



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Oomek]
#361967 - 12/29/16 10:52 PM


If you feel like there is a bug you can submit to MAMETesters or the GitHub. I think GitHub would be more appropriate since it doesn't involve anything with the emulators.



uman
MAME Fan
Reged: 04/15/12
Posts: 455
Send PM


Re: Mame lags 3 frames in BGFX new [Re: asasega]
#362037 - 12/31/16 03:57 PM


> Thing is that people confuse the term lag. Some are using the term when there are
> slowdown in games.
> I always just use -syncrefresh and -nothrottle, and don't have tearing, or at least
> on the 3 different PC that I have acces to

We are talking about input-lag here and the thing is, if people never experienced a "more" input-lag free MAME distro like GroovyMAME for example or even better a original PCB, they will never know or feel, what this topic is all about. Thats because people get used to the input-lag and so they think, everything is fine.

Once you start playing with a MAME distro with less input-lag and ideally with a CRT setup, you will notice the difference, mostly with sounds or music and if you are really good in fast paced games like shmups, obviously also with the input strokes.



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


Re: Mame lags 3 frames in BGFX new [Re: uman]
#362099 - 01/01/17 07:04 AM


> > Thing is that people confuse the term lag. Some are using the term when there are
> > slowdown in games.
> > I always just use -syncrefresh and -nothrottle, and don't have tearing, or at least
> > on the 3 different PC that I have acces to
>
> We are talking about input-lag here and the thing is, if people never experienced a
> "more" input-lag free MAME distro like GroovyMAME for example or even better a
> original PCB, they will never know or feel, what this topic is all about. Thats
> because people get used to the input-lag and so they think, everything is fine.
>
> Once you start playing with a MAME distro with less input-lag and ideally with a CRT
> setup, you will notice the difference, mostly with sounds or music and if you are
> really good in fast paced games like shmups, obviously also with the input strokes.

You either pick minimum input lag or no tearing (outside of those Gsync things that I don't wholly understand), I don't think it's possible to have both.



Calamity
MAME Fan
Reged: 05/30/11
Posts: 56
Send PM


Re: Mame lags 3 frames in BGFX new [Re: anikom15]
#362106 - 01/01/17 01:24 PM


> You either pick minimum input lag or no tearing (outside of those Gsync things that I don't wholly understand), I don't think it's possible to have both.

https://www.youtube.com/watch?v=SF6r9nMj0y0&t=43s



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Vas Crabb]
#362111 - 01/01/17 04:13 PM


> I think it still uses a fullscreen borderless window. I hope it doesn't lose that
> feature when it gets fullscreen exclusive capability, because borderless window
> performs a shitload better than fullscreen exclusive on Quadros.

Yup, we support borderless at work because certain card/driver combos perform better there than in exclusive.



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


Re: Mame lags 3 frames in BGFX new [Re: Calamity]
#362130 - 01/02/17 12:29 AM


I'm not going to watch some guy's shitty video without some explanation from your part.



Traso
MAME Fan
Reged: 01/15/13
Posts: 2687
Send PM


Looks like they're in sync, that's his point I think (nt) new [Re: anikom15]
#362174 - 01/03/17 02:12 AM





Scifi frauds. SF illuminates.
_________________

Culture General Contact Unit (Eccentric)



anikom15
Instigator/Local CRT Guru
Reged: 04/11/16
Posts: 287
Send PM


You can't tell if it's in sync with a ——ty camcorder.... (nt) new [Re: Traso]
#362175 - 01/03/17 02:19 AM




Edited by anikom15 (01/03/17 02:19 AM)


Pages: 1

MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

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