-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Defrag the sprite batcher before every flush #275
base: master
Are you sure you want to change the base?
Defrag the sprite batcher before every flush #275
Conversation
This seems to work but I think it should be a dirty flag instead? Like:
|
This branch brings my memory usage in the demo to normal values (650MB) which I think is fine (it always seems to be more on macOS). The CPU is on ~100% though. |
If you turn on vsync ( Also, I suspect that calling defrag so often is suboptimal. |
16 threads.... Yeah, it's probably your driver. |
I don't think the thread count is an issue. But again, I think this change works. |
Defrag is designed to be called per frame. Internally it won’t do work until needed, and the work is almost always worth doing. |
So calling it before every flush is fine? |
Yes. There was an issue with imgui though, needing to defrag/flush after drawing, but there's an if-statement and dirty-flag for this already. The delay was needed to avoid invalidating texture handles for ImGui to draw CF sprites, this let CF inject it's sprites for rendering within Dear ImGui. |
How to approach this though? Can the handles in dearimgui be "virtualized" or indirectly looked up somehow? Because as I understand it, if defrag is delayed before flush it leads to this problem. Alternatively, dearimgui can be treated as "debug tool" and its rendering is delayed in the case of a flush ... somehow and its entire command queue just get discarded. |
Did you test with imgui? |
Only the samples but none of them render images |
This ensures that the atlas is defragged before every flush.
Both RAM and VRAM usage are reduced significantly.
No change to the cycling flag is needed.
However, I have no idea how this affects performance since there is another per-frame defrag.