-
Notifications
You must be signed in to change notification settings - Fork 427
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
FlxDrawQuadsItem and FlxDrawTrianglesItem are unoptimized, causing sprite draws to be expensive #3005
Comments
So, I optimized all of the classes of |
Here it is: https://drive.google.com/drive/folders/1qodl5Q5eYiz6hn7Z4ZrMHNbxEWhObWgL?usp=sharing |
If you want to propose changes to these classes do so by creating a fork of flixel, making a feature branch with the changes and creating a PR. If youre new to git and github then check out this contribution guide |
I'd love to see what changes you made as well in a pull request. Thanks for contributing! |
thats pretty cool, i just checked it out, and the files are all watermarked with "@author Zaphod". i cant find any association from you with that name, even from the gmail account the files were uploaded by. who is zaphod? |
I'd also love to see:
before and after the changes. I tried FlxBunnyMark (target: hxcpp on windows) and I measured a worse performance: I have some things to point out about the code you posted. I found these changes: alphas.splice(0, alphas.length);
if (colorMultipliers != null)
colorMultipliers.splice(0, colorMultipliers.length);
if (colorOffsets != null)
colorOffsets.splice(0, colorOffsets.length); that you changed as: alphas = colorMultipliers = colorOffsets = []; this will break many things, as arrays are stored as reference so they become the same array (as you can see here: https://try.haxe.org/#1201922d). Also you are creating a new array each time, this could be impactful on C++ targets. This: return Std.int(position / elementsPerTile); became: return Std.int(position * Math.pow(elementsPerTile, -1)); While I'm sure This: colorMultipliers.push(1);
colorMultipliers.push(1);
colorMultipliers.push(1); became: while (colorMultipliers.length < 3) colorMultipliers.push(1); Also in this case, I would like to see the data that supports the change: the original code is an unrolled loop, and this is usually faster for smaller code: even compilers automatically try to unroll smaller loops. This code: drawCalls++; became: drawCalls += 1; This does really nothing, as the Haxe code is transpiled to several different languages and then optimized for the target: for example in JS in both cases it's transpiled to the same code, as you can see here: https://try.haxe.org/#cb126443 I couldn't find any other significant change, so idk, maybe I forgot to include some files? Or am I seeing a draft version and you have already changed/fixed it? |
The original author of HaxeFlixel. |
@SomeGuyWhoLovesCoding, I'm closing this now as it seems to be dead, I welcome you to try this again, but when/if you do, please remember to be clear about what problems you are trying to solve, how you observed these problems, and how you intend to solve these problems. Please use the contribution guide so that we can properly analyze and discuss each change. You my reopen this issue or create another, when that time comes, but if you want to submit changes it must be in a pull request |
(No code snippet)
Observed behavior:
When I draw about 2000 FlxSprite's with a width amd height of 112, it lags the game, which results to it being slower than
openfl.display.Sprite
.Expected behavior:
What I want is for FlxSprite to not have expensive draw behaviors.
The text was updated successfully, but these errors were encountered: