New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlxSprite.isSimpleRender() is nasty, causing implicit batch flushes! #78
Comments
For the record, I would expect an isXYZ() function to be simple ad side-effect-free, and more human readable, ala:
The compiler/JIT will almost certainly optimize the temporary booleans away. |
flush on EVERY call. Make the function simple and readable, and defer render state handling to where we already have it, in FlxSprite.draw(). Tested on my own games that uses rotating sprites and 1 shader. Blending and other fancyness not tested, but I think it will work. Fixes flixel-gdx#78
Attached a pull request with my suggested fix. It has been tested on 2 of my games. Using rotating sprites and one using 1 shader (Spider Water Up! to render the water). |
Does this bug still exist?To know if I need to look up into it or not. |
kamstrup fixed for his game, but the OpenGL ES 2.0 doesn't work as before with this PR. You're welcome to look into it. |
I noticed that EVERY FlxSprite caused an implicit flush of the SpriteBatch on every draw() entirely defeating batching at all. After much chasing I discovered that the seemingly innocent FlxSprite.isSimpleRender() is a wolf in sheep's clothes.
Not only is it a boolean check that has major unexpected side effects (changing the rendering configuration!), it also assumes that calling batch.setShader(null) is a no-op if the shader already is null. This is not true. It causes a flush() no matter if you "change" it from null to null. This could be considered an issue in libgdx, but we have to deal with it.
I looked a bit at a solution, but since there is no way to pry the active shader config from the SpriteBatch, we have no sane way to tell if we need to clear the shader... Pondering this a bit, but good ideas welcome!
The text was updated successfully, but these errors were encountered: