How to reduce GPU usage?

A few days ago I posted a topic asking for help on optimization. Folks in the forum really helped me a lot. However, today I found the issue which I believe causes most of the lagging problems, that is the GPU usage. I compared my game with Skul: The Hero Slayer, and I found that Skul is using much more of the RAM than my game, but the game barely lags. I also found that Skul is only using around 20% of the GPU while mine is using around 80% of he GPU. Is there a way to reduce the GPU usage?

This is my game.

This is Skul: The Hero Slayer.

Also, yesterday I tried to solve the lagging issue by decreasing the number of colors my images are using but that didn’t do much. Even though the size of my game decreased by half it still lags.

Performance issues can be caused by a lot of things below the level of what gdevelop exposes, and it isn’t a good idea to immediately jump to ‘gpu use is the problem’.

Given that GD is built on a web platform, my immediate suspicion would be the javascript garbage collector, which you could evaluate using the JavaScript profiler in chrome (press f12).

With regards to GPU use I can’t offer much advice without knowing more about what you are doing, as well as how gdevelop internally handles draw calls. Either you are doing a lot of draw calls every frame, or your texture size is excessively large, or you are filling gpu memory and and causing it to swap, or the shaders being generated are compute intensive.

Generally you want to use instanced rendering, or merge geometry to reduce draw calls. However that would be a matter of how GD works internally as it does not expose any way to do low level optimisation like that.

1 Like

image

I’m using different animations of few same objects to make the decorations. There are around 400+ objects in one scene like that(it was fine in my previous scenes), however, in my latest two scenes the game lags a lot with decorations. The average size of the decoration sprites is about 600*600, of course the visible part of each sprite is smaller than that. Could this be a problem of excessive textures?

If each of those 400 objects are using distinct textures and are 32 bit RGBA, thats (8 X 4 X (600 X 600)) X 400 bytes,

or 4608000000 bytes,

or about 4.6 gigabytes of data, assuming gdevelop is storing them uncompressed in memory.

Depending on your GPU, it woukd not supprise me if that isn’t causing GPU memory swapping.

WebGL itself has a minimum support of 8 textures per draw call which i assume PIXI.JS (what GD uses to interface webgl) would have been written to respect.

  • if objects are being batched into draw calls, thats still about 50 draw calls per frame.

  • if there is no draw call batching, you would have 400 draw calls per frame.

assuming all objects are in the viewport, given gd does use offscreen culling.

1 Like