Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / FPS - major speed up on slow devices! Also fault in Sync rates

Author
Message
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 01:50
I have been exploring ways for my current game to work well on non-dedicated GPU pcs (laptops and low spec PC).

I put several configurable items in so that it could be playable but it wasn't getting much better. (Also see this thread for other issues on low spec PCs).

I had even started to look at other engines again as this issue seemed to be too deep; too much at the core of AGK.

As a final experiment (I had run out of all optimisation ideas - tried everything) I wanted to see where the bottleneck was (if any) as it shouldn't be so slow on an i3 machine, even with a basic graphics adapter.

I opened up the frame rate to see how fast the GPU could accept the refresh, using SetSyncRate(0,1). I expected to see the same FPS bottleneck I was seeing at 60fps, whereby I would get drops to ~50fps for no reason and ~30fps on busy spots... but no.. I got ~200-270fps even on the busy parts... what's this then? If the bottleneck isn't at the GPU or CPU, where is it?

So, I tried setting SetSyncRate(60,1) (forget setvsync() as this didn't behave reliably) and although I got a rock steady FPS, it was... 70FPS ?!?

OK.. I'll set it to SetSyncRate(50,1). Now I get 50FPS. Duh.. OK.. if I want a rock steady 60fps, I have to do SetSyncRate(59.9,1)

So to summarise:

SetVSync() works fine on my "big" machine, but fails to maintain 60fps on my I3 Intel HD graphics Acer laptop. Add to that woeful drops to 30fps when a few extra sprites are on screen.

SetSyncRate(60,1) holds a steady 70fps on the laptop and I have to cheat with 59.9 to get a proper 60fps or it will jump up 10!

My main concern is that I found a solution in the 11th hour, but I've been fiddling and changing things for days. Many areas have been totally rewritten.

This is 108 beta 8 btw.

nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 01:55
Oh yea, this vsync() thing needs to be fixed as my solution doesn't stop screen tear. With 59.9 it creeps slowly up the screen, so not really a solution at all

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 19th Jun 2013 02:01
What about 59.99

Just kidding, that is realy weird, I had some major screen tear in my old project which I am now remaking in Tier 2. Turning off the FPS cap seems to have fixed it, however I am getting ~1000 FPS right now so that may be part of the solution.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 02:06
I'm trying that now. Also trying to persuade vsync() to work with SetSyncRate(). VSync() should only be cancelled out at <>60 which isn't able to be set!!!

How can you avoid screen tear without vsync() ?

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 19th Jun 2013 03:25
I've had this same problem. Even setting it to 66 fps (which I do by default) makes it run at ~50 or worse on some machines, yet when the cap is removed, they'll hit 3000. Logically this means I would simply not use the cap as that fixes the issue, but uncapped FPSs cause AppGameKit clients to freeze and crash for me I get a considerable stutter and blurryness even when running at 60+. It isn't till at least 100 FPS that my apps appear smooth

swis
Joined: Tue Dec 16th 2008
Interstellar
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Jun 2013 04:45
I would highly recommend updating your AppGameKit version. There have been quite a few additions and many fixes between v1088 and v10813.

You just might find that your performance is better with the newer version.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 05:48
It may do AL, but I haven't seen any specific fixes to sync in any of the release notes.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Jun 2013 15:46
If your issue appears when sprites are added to the display (trying to extract the main symptom from your first post), it is not impossible that the fixes for various things will have an impact in that area.

Are you mixing 3D and 2D at all?

Using older versions that have known issues (and I can't point out the particular ones at the moment) may be handicapping you in areas you aren't aware of.

It doesn't take much to install another version (in a different directory) and try it.

I have 10 version installed on my development machine. And I can access the same projects, regardless of directory, in all of the versions by just opening the correct IDE. Apparently the information stored about where and which projects are loaded is not in the actual IDE paths, so they all 'know' the same things. I just have to recompile to test in the different versions. I usually manually delete the files generated by the ID (<projdir>/<project>.exe, <projdir>/media/bytecode.byc) to make sure tests are using the version I want.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 19:51
I was running 1076 and 1088 side by side with no issues.
Am trying 10813 now to see if anything changes.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Jun 2013 19:59
I like keeping multiple installations. It helps me figure out which version an issue got inserted in.

Good luck with v10813.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 20:08
OK, no difference with 10813.

However, I have found out the issue which is messing up the FPS.

If I change the Windows 7 screen theme (switch off aero, use "windows basic" theme), then it happens - AppGameKit apps run at 70fps - even a simple loop showing FPS.

You must be in full screen mode.

Switch back to normal windows 7 theme and it's back to 60 fps again.

XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 19th Jun 2013 21:13
Maybe the issue could be resolved by manually calling drawing/physics routines to update instead of relying on Sync to make those calls. It may help with older systems. Also if you need physics you may need to come up with sudo physics as the cpu may not be able to handle box2d physics. Lastly check you logic and make sure you don't have any loops that could be screwing up your FPS. I've had to rewrite stuff to keep stuff running smoothly.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Jun 2013 21:38
There isn't any physics involved.
I can even make this happen with a simple few lines just printing screen FPS - not 1 sprite in sight.

The CPU is an i3 quad core.. it's a modern laptop but only has a 128mb video chip and uses shared memory like many laptops do.

VSync() should be the answer. However, it drops to unacceptable levels. It can't be the throughput to the video because I can get several hundred fps if I remove the cap.

If I force the sync and even if I used timer based updates, you can't dispose of screen tear without a VSync()

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 19th Jun 2013 22:16
Rubbish video chip, unfortunately. Laptops are not great this stuff.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Jun 2013 00:07
Indeed, but it is capable of taking >200fps on my game without vsync().
The issue still remains as to why vsync() is bottlenecking.

SetSyncRate(60,1) doesn't drop FPS.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Jun 2013 00:21
If I interpret the VSync() command correctly, it will only synch the display when the monitor does a refresh. This then sort of causes the app to ignore the SetSyncRate.

I just checked my PC display bits. In the native resolution (1920x1080) (which is also the max), it only allows a 60Hz refresh rate (60 times a second). So, no matter what I set my SetSyncRate to, if I use SetVSync(1), the best I can get is 60FPS.

If I crank the resolution way down, I might be allowed to set my refresh rate at 70Hz or 75Hz.

So, the OTHER thing to check when you are testing is what is the actual refresh rate on the displays you are working with. How you do that is dependent upon your setup. (And I am not a general guru on that particular topic, I just happen to have a control panel tied to my display adapter, which is supporting two monitors).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Jun 2013 01:03
Yes, SetVSync(1) locking into the monitor refresh is what essentially prevents screen tear.

This laptop only has 60Hz as an option regardless of resolution (besides, it's the monitor which dictates the refresh, not the GPU).

Also, I beleive VSync() is enabled in fullscreen mode automatically (I could be wrong) but setting/not setting it doesn't change anything.

I even tried messing with sync settings inside the main loop, but no joy either.

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 20th Jun 2013 01:36
When I've had these problems it's still been present in 10813, but I do mix 2D and 3D. Physics commands are also used I've found VSync to always be undesirable on PCs, but on mobile phones it is a must, as for whatever reason none of my aps are smooth when running around 60 FPS (still above of course) and lacking vsync. Vsync fixes it all up, even if it isn't running quite at 60 FPS.

swis
Joined: Tue Dec 16th 2008
Interstellar
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Jun 2013 02:16
Strange. For me, no vsync, no game.
This really applies especially to scrolling games - maybe static screen based games don't show up the issue or it's not that noticable.

VSync is almost certainly forced on mobile devices anyway, so the choice is out of your hands... surely you meant vSync to be desirable on PCs ?

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 20th Jun 2013 02:23
Quote: "VSync is almost certainly forced on mobile devices anyway, so the choice is out of your hands... surely you meant vSync to be desirable on PCs ?"

Nope. On mobile devices if I don't set it up to run vsync it's horrible, and on PCs vsync is so bad I never use it

swis
Joined: Tue Dec 16th 2008
Interstellar
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Jun 2013 03:50
How do you avoid screen tear then on PC?

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 20th Jun 2013 04:53
Quote: "How do you avoid screen tear then on PC?"

Frame rates > 100 do if for me or in my case about 3000 does it haha

swis
Joined: Tue Dec 16th 2008
Interstellar
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Jun 2013 05:49
In conjunction with timer based movement?

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 20th Jun 2013 06:43
yes of course

swis
Joined: Tue Dec 16th 2008
Interstellar
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 20th Jun 2013 16:04 Edited at: 20th Jun 2013 16:13
Try this around your main loop.

Set your sync rate to 0 at the start of your program. It's a pretty basic routine, but should give you the fps you are looking for, if your machine can run it ok.

Edit - although it probably won't help with screen tear. Vsync(1) works fine for me though, and seems to run fairly nicely, but I'm not using a laptop.

nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Jun 2013 19:53
Yea, I tried something similar to this already and you are right - screen tear is bad.

nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 21st Jun 2013 05:17
Swissolo: I implemented timer based movement.
Although I'm having to change about 5000 bits of code, I'm doing it in such a way the user can select vsync mode or timer based mode.

Interestingly, in timer based mode, I get roughly 160fps on the crappy laptop and it's 99% smooth with no tear. I might look at refining it but I doubt I can do it any better without a high precision timer.

The draw time - GetDrawingTime() - is now ludicrously low compared to when any capped sync was used, so I think this will work.

Be even better if I can work out a way to reliably detect which mode to use.

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 21st Jun 2013 23:28
Quote: "Swissolo: I implemented timer based movement.
Although I'm having to change about 5000 bits of code, I'm doing it in such a way the user can select vsync mode or timer based mode.

Interestingly, in timer based mode, I get roughly 160fps on the crappy laptop and it's 99% smooth with no tear. I might look at refining it but I doubt I can do it any better without a high precision timer.

The draw time - GetDrawingTime() - is now ludicrously low compared to when any capped sync was used, so I think this will work.

Be even better if I can work out a way to reliably detect which mode to use."

Oh good Everything in my code is always timer based regardless of a FPS cap, not sure if that's what you were saying, but I'm glad it worked out Now if only my network clients didn't crash when I did that

swis
Joined: Tue Dec 16th 2008
Interstellar
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 29th Aug 2013 19:12 Edited at: 29th Aug 2013 19:20
Hi,

Apologies for resurrecting such an old thread --
I'm back from a long summer vacation and just
catching up with my unread forum posts.

Anyway, I have a few notes to make about these
frame rate and vsync issues in AGK.

Basically, you'll find answers to all of the
questions posted on this thread, just by searching
the forum (and doing some investigative reading).

Below is a summary of my findings, with only the
significant parts of the result threads quoted.

THREAD:
http://forum.thegamecreators.com/?m=forum_view&t=204786&b=41&msg=2448870#m2448870

Paul Johnston wrote 15th Apr 2013 18:50:
Quote: " We use a new method of frame rate limiting on Windows Vista
and above that uses what's called the Desktop Window Manager to
sync the refresh rate to the screen. Using SetSyncRate(60,0) or
SetVSyncOn(1) turns this on so if you wanted to force it off
you could use SetSyncRate(59,0)
"


Ian Rees wrote 15th Apr 2013 19:09:
Quote: " Great - that has sorted it. Is there a downside to using that
though? Should you check if the FPS drops down to say 40 on
Windows and then call that command?
"


Paul Johnston wrote 15th Apr 2013 20:13:
Quote: " Only downside may be some screen tearing when VSync is forced
off, if the screen is only refreshing at 30 fps you might want
to keep that and use timer based movement where possible.
"


THREAD:
http://forum.thegamecreators.com/?m=forum_view&t=202929&b=41&msg=2434895#m2434895

Paul Johnston wrote 14th Feb 2013 19:48:
Quote: " SetSyncRate and SetVSync are mutually exclusive, they will
overwrite the settings of the other. The following applies to
108 and beyond."

"Using SetSyncRate with a value of a value other than 60 will
turn VSync off and use your chosen value, using a value of 60
will turn VSync on as it should be a smoother method of
achieving 60 fps."

"Using SetVSync with a value of 1 will let the system handle
the frame rate (usually 60fps) and set a manual sync rate of
70 as a backup, just in case the system does not support
VSync.
"


THREAD:
http://forum.thegamecreators.com/?m=forum_view&t=204374&b=41&msg=2443259#m2443259

Paul Johnston wrote 23rd Mar 2013 23:37:
Quote: " SetSyncRate(60,0) is now a special case on Windows that
attempts to use VSync instead of the normal AppGameKit timing as this
results in a smoother experience, but I don't know why it would
be using up CPU. A quick test on Windows 7 has low CPU usage
with SetSyncRate(60,0).
"


The above are some pretty useful tidbits of information.

Nz0 wrote:
Quote: " Be even better if I can work out a way to reliably detect
which mode to use.
"


Agreed. We need some way to get information about the currently
selected vsync mode; eg. does the hardware support vsync, is
vsync handled by the DWM or not, are we in 70Mhz fallback mode
or using explicit frame rate, and is vsync currently ON or OFF.

Cheers,
AgentSam
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 1st Sep 2013 08:33
I actually just started a thread on this. I tried using setsyncrate(60,0) (i always have been) and windowed my app on PC is fine. Fullscreen, tearing city (although it is faster and sits at 60fps). If I use setvsyc(1) it makes absolutely no difference. Nor does setsyncrate(59.9,0) or any other combination of the two - in full screen the tearing is utterly terrible.

So, quick pop into the nVidia controll panel, and if I change the setting under vsync specific to the app to on, adaptive or anything else, it works fine. However if I leave it set to "let the 3d application decide" then the tearing comes back no matter what other settings I use. I also noted that if I globally override the vsync setting the tearing still appears in my AppGameKit app.

So, be it the fault of AppGameKit or nVidia, it would appear the only way at all that I can get around the tearing on full screen with anything AppGameKit produces is to manually add the app the list of installed apps and then tell it specifically to use vsync for that app. Not overly practical. I actually think the PC side of AppGameKit is easily the weakest, oddly enough considering I'm a huge DBPro fan. Lol.

nz0, have you tried playing around with whatever version of the hardware specifics your onboard graphics supports, or does it have none?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 1st Sep 2013 13:55
I have used the (e.g.) nvidia control panel before, but only for testing similar to you.
Obviously its not possible to expect end users to have to play with their specific graphics card.

Anyway, this seems to be avoided by using timer based movement, although that does introduce it's own problems...

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 1st Sep 2013 14:19
There is a huge amount of discussion of this on the OpenGL forums and other pages. Switching VSync on can cause more problems than it solves, because the GPU may cause the CPU to queue updates, and the real frame rate (of updated frames) will steadily drop.

The best solution appears to be triple-buffering. But certainly the buffer flip should not happen until the render buffer is complete.

Different drivers do different things at different times and with different permissions. Only Paul can say how AppGameKit handles the OGL contexts, so I don't think there's any fiddling that can be done to improve this. Must say I have never seen screen tearing even on a laptop.

-- Jim - When is there going to be a release?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 17th Sep 2013 01:25
Back from my expedition to Norway
Be nice if this got updated - I see there's some "tearing fix" on the latest beta, but would be nice to know what has been changed at a lower level.

Login to post a reply

Server time is: 2024-05-09 06:02:53
Your offset time is: 2024-05-09 06:02:53