I have following situation:
- I have number of medium size images. Total size of them is a lot greater than size of expected GPU memory.
- Only part of them will be used at given time. Set of used images will change gradually - images can go in or out by 1-2.
- Average blitting speed is very important, images are opaque, or 1-bit transparent
- It is acceptable that once per some time there will be small hiccup, as long as for the rest of time speed is acceptable
I’m considering following scenario. On application install, I take images distributed with it and convert to native format (specific for given system/color configuration) and write them to disk. I then memmap all images to memory as readonly and let OS manage them, paging them in and out of memory as needed.
Question is, is there a way to do it automagically ? I can think about managing number of VolatileImages and recreating them from disk when needed - but to recreate them, I would need to create a normal image first ? Is there a way to directly circuit raw buffer from disk to VolatileImage (best case) or to some other image (I could accept one level of manual control, recreating VolatileImages if needed).
For me, it would be best to just do (pseudocode)
VolatileImage vi = Something.createVolatileImageWithBackstore(“path/to/file.raw”);
and then
graphics.drawImage(vi,0,0);
It would be easiest if GPU could directly get data from disk buffer - no need to engage CPU here. I’m afraid it is not possible in java, but what is the way to do it in least number of hops and use OS disk buffer/page code instead of managing image memory myself ?