Jump to content
  • Advertisement
Sign in to follow this  
yadango

Texture Reloading for Caching System

This topic is 4860 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

Hi, I am trying to build a texture caching system. All my textures are of the same dimensions, but I can't load all of them at once. My problem is after initally using D3DXCreateTextureFromFile to create and load the initial textures into the cache, there is no 'D3DXLoadTextureFromFile' or 'D3DXReadTextureFromFile' function to read a texture from a file into an already created texture. Do I have to create my own load routine for efficient texture caching? This is for a sprite-based windowed program. What's the best way to do texture caching? I was looking at the surface utility functions, as they same to have a load function, but CreateOffscreenPlainSurface is giving me a big headache right now. Thanks, Yadango

Share this post


Link to post
Share on other sites
Advertisement
Hi,

This is something I never tried, but you can use D3DXCreateTextureFromFile to load the new textures using D3DPOOL_SYSTEMMEM and then upload it using the IDirect3DDevice9::UpdateTexture() method (as long as the destination texture was created in D3DPOOL_DEFAULT).

On a side note, are you sure you want to do that texture management yourself. Direct3D offers a D3DPOOL_MANAGED for resources that will do all that caching and upload to local video memory when necessary by keeping a copy in system memory. It also allows the driver to put resources in the best location, such as storing some of them in AGP accessible memory.

Share this post


Link to post
Share on other sites
you can also try to implement some kind of lru list. You make a fixed number of slots for your textures. Each time you use a texture,you move it to the end of the list. when you need a new texture,you just take the first slot,unload the existing texture,load the new texture and bind it to that slot.

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!