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 / Benchmarking AGK Sprite Draws

Author
Message
Grizzlius_Maximus
7
Years of Service
User Offline
Joined: 16th Oct 2017
Location:
Posted: 30th Apr 2020 07:04
I want to remake this game (from gms 1.4) using AGK. The game allows you to spawn infinite amount of bears (It's called Beartopia and it's free on Itch if you are curious).

Everything was going fine until I started drawing a ton of these bears. I noticed the performance on AppGameKit was signifcantly worse than on GMS.

Here are the results : (Note that the sprite is 16x18 pixels )
AGK:
- 4000 Sprites rendered, 45 fps.
- 1 Sprite drawn 4000 times, 30 fps.
GMS 1.4
- 4000 Objects rendered, 200 fps.
- 4000 Sprite draws, 450 fps.

I did the same test but this time, using a bigger image of 400x200 pixels.
AGK:
- 1000 Sprites rendered, 3 fps.
- 1 Sprite drawn 1000 times, 17 fps.
GMS 1.4
- 1000 Objects rendered, 15 fps.
- 1000 Sprite draws, 15 fps.

As you can see, drawing 1000 big images in both engines gives more or less the same fps but when drawing 4000 smaller images, gms out-speeds agk by more than 10 times. I have a feeling the process of setting the parameters (vertex positions, shaders, etc..) fed to the gpu in AppGameKit is heavier than that of GMS. I might be wrong. I do not really understand whats happening under the hood.

To the AppGameKit community that reads this, please help me overcome this problem. I really want to use AppGameKit so badly but these fps is a such a letdown. Is there a way I could achieve higher fps when drawing 1000+ sprites?


...btw, I am using a pretty dated Acer laptop with Intel Pentium@2.0GHz (2 Cores) , Intel HD Graphics (yes, my laptop sucks but at least it gets the job done)
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 30th Apr 2020 15:59
It's hard to say without seeing any code. How are your sprites being created in AppGameKit?
Grizzlius_Maximus
7
Years of Service
User Offline
Joined: 16th Oct 2017
Location:
Posted: 30th Apr 2020 16:54

Here is the code for creating 1000 sprites at begin. Sprites get rendered using Sync()


The other test, 1 sprite drawn 1000 times, has this code at begin:


and this in the main loop:


I'm using Tier 2 if you haven't noticed.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 30th Apr 2020 17:06 Edited at: 30th Apr 2020 17:07
Using DrawSprite() in AppGameKit will create 1 draw call per sprite, which is likely the cause of the slow down. Using agk::Sync() will batch all the sprites into just a few draw calls, assuming they share images and shaders, which will be much faster. I guess GMS is taking the DrawSprite command as a signal that you want it to be drawn at some point in the future so it batches them up as it goes along, whereas AppGameKit takes DrawSprite as a signal to draw the sprite right now.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Apr 2020 18:34 Edited at: 30th Apr 2020 18:39
paul, in their Fiery Catacombs thread, Metamorpho was experiencing similar.

my response was similar to what you just offered.

meta came back with some test code, which i modified to:


the results changed my mind, leaving me to believe DrawSprite was (much/55-65%) quicker.

so, now i'm confused again.

of note? my system is dated, as well. and, has a laptop mobo with integrated graphics (didn't know it was a laptop in a tower when i bought it)... maybe this has something to do with it?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 30th Apr 2020 23:58
In that example most of the sprites are off screen, so the overhead of sorting and batching the sprites loses out to drawing them one at a time when most of them are rejected. Changing the positions so all the sprites are on screen reverses the results so DrawSprite is slower, but I guess that wouldn't be an accurate test for the game in that thread.

The batch routine in AppGameKit Classic wasn't very efficient so it got rewritten for Studio, which produces the same frame rate for both the batch and DrawSprite methods when most of the sprites are off screen. However it also revealed that when most of the sprites are on screen then DrawSprite absolutely kills the new renderer (both OpenGL and Vulkan).

So it seems to be that in Classic use batching if most of the sprites are on screen, and DrawSprite otherwise. But in Studio always use batching.

Login to post a reply

Server time is: 2024-11-22 05:33:07
Your offset time is: 2024-11-22 05:33:07