Skip to content

Conversation

@Tom-Ski
Copy link
Member

@Tom-Ski Tom-Ski commented Oct 26, 2024

Regression in gwt due to VertexArray/IndexArray not being implemented the same on all platforms.
Should fix #7480

After tests, I havent seen an issue in just moving from client side buffers (VA), to VBOs as the new default.

For all other buffer types we can still pre-upload indices, and save us some nice time during rendering.

Test results for lwjgl, lwjlg3, android, ios and gwt below.

Times here are all just relative to each other. Lower the better

android gl2
0.195 vertex array 
0.159 vbo

android gl3
0.171 vao
0.168 vbo

===============

lwjgl2 gl2
0.105 vertex array
0.88 vbo

lwjgl2 gl3
0.09 vao

===============

lwjgl3 gl2
0.105 vertex array
0.09 vbo

lwjgl3 gl3
0.08 vao

===============

gwt gl2
1.427 vertex array
1.309 vbo

gwt gl3
1.309 vbo
0.921 vao

===============

ios gl2
0.274 vertex array
0.137 vbo

ios gl3
0.140 vao
0.145 vbo

#7480
bfe255a

Tom-Ski and others added 2 commits October 26, 2024 17:38
…t fallback for gl2. Use VBO instead.

Expose index object from mesh so we can pre-upload indices once for SpriteBatch

Changes to SpriteBatchPerformanceTest to be able to easily test each vertex data type
@BoBIsHere86
Copy link
Contributor

Since I'm the jerk who submitted the issue. I pulled down the PR, built it locally, deployed and tested it out. Fixes the issue as initially reported.
Awesome work!
fixTest

/** Used to completely override the vertex type used by SpriteBatch. This is useful for picking a specific vertex data type on
* construction of the sprite batch. Recommended to reset this back to defaultVertexDataType Once the batch has been created
* with this flag */
@Deprecated public static VertexDataType overrideVertexType = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, another Deprecated field; I can sorta see why this exists now. Is there a plan to eventually remove these public deprecated fields?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just for warnings mostly, as you should not touch these without understanding the consequences. There is no safe handling of what is compatible, no errors etc.

Probably would be better to have extra SpriteBatch constructors to create with specific VertexDataTypes, and then handle all incompatibilities there and give sensible warnings and exceptions when someone tries to create with something invalid.

Something that can be addressed in a separate PR as wanted this to be as noninvasive as possible.

Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally clear on how this is acting differently (and better than before) on GWT than it does on other platforms, but I'm glad it does. I would eventually like to know what the plan is for deprecation in libGDX in general -- do we intend to ever remove these deprecated fields?

@Tom-Ski
Copy link
Member Author

Tom-Ski commented Oct 26, 2024

These deprecated fields can be removed with something like described in comments. Mostly they are used everywhere as warnings of not to use things. Its not often someone will be checking the javadocs for every method/field to see if its experimental or potentially a bit dangerous, but deprecated annotations make these very obvious.

As for the difference, Gwts implementation of VertexArray wasn't the same as other platforms. Which is why that bug cropped up. Its not actually a client side vertex array. But should be working better now, because it no longer uses 'vertex arrays', and uses the vbo by default on gl2. With benefits from previous commits to optimize not updating indices, and in general a bit more of a performant approach by having these buffers mostly gpu side, we get a little boost too.

@obigu obigu added this to the 1.13.1 milestone Nov 12, 2024
Copy link
Contributor

@obigu obigu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on real projects on Android and iOS looks good. Also have run the SpriteBatchPerformanceTest on an Android 8 gl2 and results are Vertex Array 1.2s and VBO 0.65s

@obigu obigu merged commit be482fa into master Nov 13, 2024
@obigu obigu deleted the spritebatch-opti branch November 13, 2024 14:56
obigu pushed a commit to melvilpf/libgdx that referenced this pull request Nov 21, 2024
crykn added a commit that referenced this pull request Jan 8, 2025
@crykn crykn mentioned this pull request Jan 8, 2025
crykn added a commit that referenced this pull request Jan 8, 2025
wheelergames pushed a commit to wheelergames/libgdx that referenced this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Texfield Bug on GWT build with 1.13.0 release

6 participants