Jump to content
  • Advertisement
Sign in to follow this  
bobjones9190234324

OpenGL Texture streaming questions

This topic is 2942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!