Hi,
In my image-based renderer, I want to implement a cache that prefetches images from a neighbourhood for rapid retrieval.
I have a main render loop which has to run at 90FPS (VR), and another caching thread which is supposed to run in the background. However, when I change my position, new images are loaded by the cache thread and it often spikes cpu usage to the point where my render thread suffers. This happens even though my render loop is not synchronised with the caching thread. If an image is not in cache and it is supposed to be rendered, it just returns an empty one for the current frame. Nonetheless, I can still observe stuttering when this happens. When I move slowly it is fine however.
When I put a sleep(100) inside my caching thread, the stuttering does not occur, but ofcourse the caching is also a lot slower.
Any ideas why this happens and how I can solve this? My main theory now is that the caching thread performs a lot of memory accesses to load the images. As RAM only has one address line, other threads also suffer. But how can I ever get around this?
↧