HaxeFlixel / HaxeFlixel/flixel
Transparent camera causes unnecessary draw calls
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 2.2k
- Forks
- 522
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
In #3459, FlxCamera.fill() was changed to always fill the camera, even if the alpha is 0. As a result, even though this fill rect is entirely invisible, it still gets pushed and drawn by OpenGL, which we can see by using an OpenGL debugger like RenderDoc:
Here's a replay of the draw process, in video form to better illustrate my point. Notice how the first glDrawElements() call doesn't change anything visually (because it's entirely transparent).
https://github.com/user-attachments/assets/777e392a-9e63-4008-8abf-baccd3352d11
The alpha check was added back in 2013 in https://github.com/HaxeFlixel/flixel/commit/5dde99f83558a679e11e1d756a26305046f0318e with the intention of solving performance related issues mentioned in https://github.com/HaxeFlixel/flixel/issues/502. I believe we should re-add the check, and the memory leak from #3459 should be investigated further.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at FlxCamera.fill() and review the change from #3459 alongside commit 5dde99f83558a679e11e1d756a26305046f0318e. Verify that an alpha-zero fill no longer produces a draw call, then investigate whether the memory leak from #3459 is addressed or requires separate follow-up.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100