Texture Management

Started by
5 comments, last by Armadon 18 years, 1 month ago
I am currently working on a 3D engine that is using DirectX 9. I've run into a design problem for texture management. The dilemma is: Do we need a generic texture class that loads and manages the textures or can D3DX handle the texture loading and texture management for us? Problem is that we have a 3D editor with a real-time material preview. Some level designers will have over 1000 textures. I'm not sure if it's a wise decision to load 1000 textures and have hardware manage them. We may run out of texture memory. Does anyone know of a better way to manage textures?
Anthony Rufrano
RealityFactory 2 Programmer
Advertisement
If you create your textures in the managed pool Direct3D will do all the memory management for you. I mean using system ram as cache and things like set.

But I recommend building a small wrapper class around the Direct3D texture interfaces. This makes it easier to add custom file formats, converting and reporting functions.

You need to keep track of the texture objects that you have created. Naturally you can use a reference count system to check whether the texture should be kept in memory or not. 1000 textures might be much if they are of large size, so that kind of management might be useful. Most of the time the artist is just previewing the texture so only thing you do with that texture is show it when needed and then dump away. Somekind of thumbnail system might be good too for an editor.
Thank you for your answers. Looks like I will be needing middle management for textures.
Anthony Rufrano
RealityFactory 2 Programmer
For each resource I have a class that handles the resource as such and then a resource manager class that handles the allocation/loading and rendering of those resources. This has it's advantages such as being able to hook events from your resource manager that will handle the resources when your device is lost and also not having resource duplicates. This saves memory and the other things that go with it.

I hope this helps.
Take care.
Armadon, did you write the loader code yourself or are you using D3DX to load your textures?
Anthony Rufrano
RealityFactory 2 Programmer
I use the D3DX library. It's easy to use and well it works for me ;).
Just to add to my previous post. I suggest looking at some kind of streaming (Loading on demand) type setup for you.
You might also want to look into some kind of LOD scheme and low res textures to accompany them. So let's say it's an open landscape you could check the LOD and appropriately match the low res textures. This will ease up on memory and improve performance.

I hope this helps.
Take care.

This topic is closed to new replies.

Advertisement