Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX TextureArraySpriteBatch needs testers!  (Read 389 times)
0 Members and 1 Guest are viewing this topic.
Offline VaTTeRGeR
« Posted 2020-02-08 13:40:09 »

This is geared towards all the LibGDX users with the need for more performance!


I made an optimized version of the good old SpriteBatch, called TextureArraySpriteBatch.

It allows you to draw Sprites with different Textures within a single draw call. The old SpriteBatch issues a new draw call per Texture change which can lead to a large performance decrease on mobile.

It is a drop-in alternative with the same interface as SpriteBatch, no extra work needed if you want to use it!.

It should work on all platforms, but IOS and WebGL are untested right now.


Why do you need this?

The old SpriteBatch issues a new draw call every time you switch Texture, forcing you to use large Atlases and/or to sort by Texture unless you want your game to be bottlenecked by the amount of draw calls generated!

The new TextureArraySpriteBatch on the other hand uses a ... drum roll ... Texture Array to bind multiple Textures at once. This means that if you draw Texture A, then Texture B, then Texture C, it will bind 3 textures and then issue a single draw call (instead of 3). If you repeat this process 1000 times it will still only bind the 3 Textures once and then issue a single draw call! This gives a significant performance boost when using many textures, especially on mobile!

Most modern Desktop-GPUs offer at least 32 Texture slots, most mobile and integrated GPUs offer 8 Texture slots. The TextureArraySpriteBatch tries to use as many Texture slots as possible and will preferably swap out Textures that haven't been used for the longest time if the number of slots isn't enough, this is known as the Least Recently Used (LRU) strategy which is used very often in caches.


You can try this new SpriteBatch right friggin now:



I would be very grateful if you could give me some feedback! Does it work for you? Is it faster or slower in your use case?
Doesn't matter if you're using Desktop/Android/iOS or WebGL, all feedback is welcome!

I also opened an Issue on Github, check it out if you want to get some background info. I would like to have this integrated into LibGDX, so a bit of bug searching is always good.
Offline SteveSmith
« Reply #1 - Posted 2020-02-08 22:33:26 »

I just quickly implemented it in an existing 3D game of mine that uses SpriteBatch, and it seemed to work for me without any problems.  I haven't checked for any fps improvements yet though.  It was only after I added it that I realised I should really have tried using it in one of my 2D games.  I'll probably do that soon.

Java Multiplayer FPS Engine - https://github.com/SteveSmith16384/SteveTech1
Offline SugarBlood
« Reply #2 - Posted 2020-02-11 18:27:04 »

That's cool, I hope I'll try it soon Cool
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (438 views)
2019-09-04 15:33:17

hadezbladez (5292 views)
2018-11-16 13:46:03

hadezbladez (2212 views)
2018-11-16 13:41:33

hadezbladez (5561 views)
2018-11-16 13:35:35

hadezbladez (1156 views)
2018-11-16 13:32:03

EgonOlsen (4592 views)
2018-06-10 19:43:48

EgonOlsen (5467 views)
2018-06-10 19:43:44

EgonOlsen (3127 views)
2018-06-10 19:43:20

DesertCoockie (4023 views)
2018-05-13 18:23:11

nelsongames (4739 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!