0

I am working on an application where I would like to display a large # of images from which the user can select from to view in full-res. A subset of the images will be visible to the user at any point of time, the number of which is user-controlled using a control which will increase or reduce the thumbnail sizes.

Currently if too many images are loaded, the application will naturally run out of GPU memory.

I am thinking of several possible approaches, but I am not sure which way is the best:

  1. Load the full image into memory, resize the image into a thumbnail using the CPU then send it to the GPU
  2. Load the full image into memory, send it to the GPU and resize it on the GPU into thumbnail size using vkCmdBlitImage
  3. Load a thumbnail (?) from file which should be embedded into the jpegs? (not sure how to get the thumbnails)

What is the best way to approach this?

aCuria
  • 6,935
  • 14
  • 53
  • 89

1 Answers1

0

The resizing method is sort of independent of running out of memory. On nearly any device, you should have plenty of memory to store the framebuffer and a few screenfuls worth of images. So you'll only run out of memory if you're trying to keep many, many screenfuls worth of bitmaps (full-res or thumbnail) in memory. If you want to support arbitrarily many images, you're going to need to come up with a scheme where you only keep bitmaps in memory for the currently visible thumbnails, plus some additional "previous" and "next" ones for smooth scrolling. You'll want to fetch new ones from storage as the user scrolls, replacing ones that are in the opposite direction of the scroll.

If you have the ability to keep thumbnails in storage along with the full-res images, then you should just load those until you need the full-res version. That will make it much easier to keep up with scrolling (and use less bandwidth if "storage" == "cloud", or power if on a battery-powered device, etc.).

Otherwise, if you really can only load full-res images from storage, then resizing on GPU is probably faster, but will use more transient memory. You can try to use VK_EXT_external_memory_host to avoid one of the copies when doing GPU resizing. Using more transient memory shouldn't be a problem if you're only keeping visible and near-visible images in memory.

Jesse Hall
  • 6,441
  • 23
  • 29