-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Added pooling for Texture2D.PlatformGetData #8384
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
base: develop
Are you sure you want to change the base?
Added pooling for Texture2D.PlatformGetData #8384
Conversation
Can you address the remaining review comments @Nebulaxin , as this looks good to merge with those changes |
Not sure if you saw @mrhelmut's comment about |
From a personal perspective and coding style, I don't think that we need a pool and that a static byte array that we grow if needed is likely enough. |
Just a few thoughts:
In terms of graphics planning, I believe one of the aims stated was to implement multithreaded graphics API support (such as drawing on one thread while using creating/set/get on others). A static byte array could do this by implementing thread safe methods around it. Looking at the So using For future consideration, I wonder if there would be any performance & memory allocation improvements if a single static |
MonoGame isn't designed for that and currently uses graphics backends that are not friendly with that (especially OpenGL in this PR). Also, MonoGame already has thread-safety on those operations through ArrayPool doesn't add much here beside using modern API. Even if we were using it, it wouldn't resolve the non-thread-friendliness of OpenGL. I'm pretty sure that a single scratch buffer can be used across all kind of texture and surface types. |
Thanks for the reply. Just to make it clearer, the first 3 numbered points relate to this PR while the rest relates to ArrayPool usage "in terms of graphics planning" considerations in general. I do understand that MonoGame isn't currently designed for this at all and that Threading.BlockOnUIThread still performs the backend graphics calls from a single thread at the moment. In terms of graphics planning "for future consideration" though (so not this PR or OpenGL), I was suggesting ArrayPool might still be worth considering for multithreading benefits. These might be realized when accelerating load/build times by loading graphics resources across multiple threads and when any future async methods might increase the number of temporary buffers that concurrently exist. |
This should fix #8304