Texture streaming questions

Started by
5 comments, last by Krypt0n 13 years, 7 months ago
Hey guys I just read about texture streaming and had some questions about how I would about doing it. So if I am understanding this correctly I want to load the highest mip level only when the camera gets close to it and unload it when we get further away. So now onto the questions

1. Should I store the entire image data in memory and then just load / unload it from the graphics card? Or should I constantly be loading from files.

2. Do I need to set the max mip level so opengl does not try and draw the highest mip which isnt loaded?

3. How do I unload individual mips in opengl.

Advertisement
Keep the smallest mip in memory, and load the full mipchain of the texture when it comes into view (from the disk), upload to the video card, then remove from system RAM. When the texture has been out of view for a predetermined amount of time, remove it from the graphics card (but keep the low detail mip).

If you want more fine grained mip level control you will be wanting to use something like sparse virtual texturing (megatexture).
[size="1"]
Quote:Original post by narpas
1. Should I store the entire image data in memory and then just load / unload it from the graphics card? Or should I constantly be loading from files.

it sounds like you want to use streaming for the sake of using it. otherwise you wouldn't ask this question.
So the answer is: if it fits to your graphic card, keep it all there all the time.
if it doesn't fit, but you have enough main memory, keep it at least in main memory. and finally, if you don't have enough video memory, nor main memory left, then reload your textures from disk.

Quote:
2. Do I need to set the max mip level so opengl does not try and draw the highest mip which isnt loaded?

why would you use a texture that has all mipmaps up to the highest resolution, but not filling/using all of it? that would be kinda contradictory to the whole idea of texture streaming.


Quote:
3. How do I unload individual mips in opengl.

just like you upload textures, but set 0 as ptr to your data.
or delete the handle you generate with opengl.
Thanks Krypt0n that makes more sense.

What I meant by this "2. Do I need to set the max mip level so opengl does not try and draw the highest mip which isnt loaded?"

Was that if I erase the top mip with by uploading 0 do I need to set the max mip so it does not try and use that or will it take care of itself?
Create a group of slots, for different texture sizes - 128..2048 for example, keep all mips from 1..64 in the VRAM.
Then decide what mip exactly is needed for every single texture in the view. Sort. Textures that move up in the size, just get reloaded from disk.
Textures that got downsized, can be just copied (higher mips get lost).
Remember to put some heuristic, that will keep textures stable if there is no "pressure" from some other texture for using their slot (your texture needs less resolution, but nobody needs its resolution right now), etc.

Such texture streamer can really help to some extend, but if you try to fit entire world textures into 10x less memory, you will fail.

I.e. creating all your art in 2k maps, then trying to stream them into 50mb will be huuuge disappointment :)
@Zemedelec
Yeah that's not what I was expecting I was thinking more like 1.5x more to fit in some 256x256 specular maps.
Quote:Original post by narpas
Thanks Krypt0n that makes more sense.

What I meant by this "2. Do I need to set the max mip level so opengl does not try and draw the highest mip which isnt loaded?"

Was that if I erase the top mip with by uploading 0 do I need to set the max mip so it does not try and use that or will it take care of itself?


unfortunatelly you cannot just erease one mipmap level, the driver will probably keep that memory reserved. sadly! (if that would work, it would make our life easier, but the only hardware that I know that has the possibility to do that is the PSP).

like Zemedelec said, to copy textures is the only way.

This topic is closed to new replies.

Advertisement