Replies: 2 comments 2 replies
-
|
This is useful to get (almost) full control for memory managements in some environments with very limited available memory. I know there is at least one actual usage, but this is not public so I cannot show this as an example. |
Beta Was this translation helpful? Give feedback.
-
|
For me the main usage is not memory limited environments, but making complex drawing chains viable. https://github.com/erparts/go-shapes is a public package that makes plenty of use of unmanaged images, and it necessarily needs to do so (mainly due to automatic memory management limitations):
The second case is similar but more oriented to pure optimization: using DrawTriangles over a set of images. For example, if you are doing text rendering or dynamic atlas generation of many small images, the ideal way to cache that is to put everything into the same atlas and use DrawTriangles for minimal overhead... and with a limited set of images you can do and you do that. You can technically do this without unmanaged images, but for large images intended to be used as atlases, automatic memory management has no advantages and risks significantly hurting performance in some specific cases. This also comes up for particle systems, to give another example. But in the really hard case where you don't know how many images you will have you can't even do that. A complete solution needs to consider what happens when you can't put everything into the same atlas anymore. In those cases, you need multiple atlases and manual swaps to deal with overfilling of the cache texture. Which is ideally done with multiple unmanaged images. In fact, this is very important and I really want to make a package to expose multiple unmanaged images for draw optimization with DrawTriangles and atlas reuse for complex draw chains and specific caches. You can do DrawTriangles without an unmanaged image, and Zyko has https://github.com/Zyko0/Ebiary/tree/main/atlas which offers the option (both managed and unmanaged), but what I mentioned earlier: for big images, managed can be risky (ebitengine will almost always have to switch atlas anyway, and you risk the automatic texture management trying to move that around reusing tiny bits of space left on the underlying atlas); and unmanaged images also have other pros in terms of flexibility and reuse control. But yeah, Zyko's atlas is not even considering all the hardest cases. So, imo unmanaged images are super important for a large number of advanced use-cases. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I usually stumble across this comment:
ebiten/image.go
Line 1427 in 2eddff9
And I wonder: this feature had some rationale behind it, right?
Someone knew what can be done with it, which performance benefits can be gained and what use cases can need an unmanaged image for better performance.
So if we can discuss it here and get extra information, maybe it can be added to that option's comment?
If not, then at the very least there will be this ticket for anyone wondering in the future (I still think having a short info in the source code or a link to this or some other internet resource for extra info is useful for discoverability).
Beta Was this translation helpful? Give feedback.
All reactions