I haven't had much time to look at it, but it fails to load some pages when the page-cache is full for some reason, so it probably has to do with the code that kicks out unused pages when the cache is full.
That aside i'm having some problems with loading my pages from disk.
If I schedule pages to be loaded right when i discover i need them, and just keep adding them to the list, i end up with an ever increasing list if i move around fast enough, because the disk IO simply can't keep up.
So i tried a couple of things, one of them being counting how many times i have a reference to each page in my readback buffer, and giving the pages with the highest ammount of references the highest priority.
After all, the more visible it is, the more imporant it is to load!
That helped somewhat, but still caused a lot of pages to be loaded and uploaded which aren't visible, yet might actually kick out pages that would be more likely to be visible soon.
The next thing i tried was to remove all the pages from my scheduler that aren't visible in the current frame, but that caused pages to not get loaded at all while you move your camera.
A couple of things that i'm going to try:
- A CPU side disk cache, i only have one on the GPU at the moment.
- Compression, hoping that'll decrease all these problems simply because loading would be faster and the list wouldn't grow as quickly.
- Using adjacency information. By pre-calculating a bounding box of all the texel area in world-space, i can sort all the pages by how close they are to each other, and perhaps do some analysis on what is likely to be visible soon, and what would be unlikely to be visible soon.
- The source material I'm working with is pretty horrible because it has a lot of decal textures which take up extra pages on the screen, and there are simply too many different pages on the screen at the same time. Building my own CSG preprocessor would allow me to optimize this more easily, as apposed to trying to fix a relatively arbitrary list of triangles with all kinds of materials.
My good friend Volker suggested a couple of things i could try:
- If you know if a page is to be loaded for the current frame, it may be wise to put the higher and lower mip levels of that page in the queue too. (but only if there is nothing else)
- Kick out pages by random instead of last used or least frequently used caching schemes, apparently the worst case is better, so that's worth a shot.
(Obviously no pages should be kicked out that's visible in the current frame) - Using memory mapped IO.
Volker: "in my tests, mmap io made a difference from 10mb/s to 500mb/s. (using the disk cache)"
My biggest problem is latency though.
So does anyone out there have any good ideas on how to determine which pages should be loaded & which pages should be kicked out?
I'm going to see if I can upload a new video of my test level tonight.