Skip to content
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

internal/atlas: GPU memory optimization by deallocating automatically #3023

Closed
11 tasks
hajimehoshi opened this issue Jun 16, 2024 · 3 comments
Closed
11 tasks

Comments

@hajimehoshi
Copy link
Owner

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

In order to reduce GPU memory, deallocate GPU memory for an image that is unused as a source for a while. We can put the memory back to GPU memory whenever necessary. This optimization works only for a source image that has all the pixel information. (e.g. an image just after NewImageFromImage), and not for an image for offscreen.

From our experience (Odencat), if an image is not used as a source for one second, the image's GPU memory can be freed.

Why is this needed?

In order to reduce crashes due to short of GPU memory. We have confirmed this happens on mobiles, and also could happen on Windows.

@hajimehoshi hajimehoshi added this to the v2.8.0 milestone Jun 16, 2024
@hajimehoshi
Copy link
Owner Author

hajimehoshi commented Jun 16, 2024

By this optimization, write-pixels will be increased. In the worst case, each new write-pixels will be interleaved into draw-triangles. This would degrade performance. In order to avoid this, we would have to reorder draw calls by accumulating write-pixels first.

EDIT: This optimization has been already implemented!

@hajimehoshi
Copy link
Owner Author

Tricky things are:

  • Now a backend doesn't know what images are on. So it is not possible to iterate them.
  • WriteImage can be called for a part of an image. How should we hold pixels cache?

@hajimehoshi hajimehoshi modified the milestones: v2.8.0, v2.9.0 Aug 27, 2024
@hajimehoshi
Copy link
Owner Author

#3100 would solve this issue.

@hajimehoshi hajimehoshi closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
@hajimehoshi hajimehoshi removed this from the v2.9.0 milestone Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant