GFXTextureManager Class Reference

#include <gfxTextureManager.h>

Inheritance diagram for GFXTextureManager:

Inheritance graph
[legend]
List of all members.

Public Types

 AA_MATCH_BACKBUFFER = -1
enum  { AA_MATCH_BACKBUFFER = -1 }

Public Member Functions

 GFXTextureManager ()
virtual ~GFXTextureManager ()
U32 getTotalVideoMemory ()
virtual bool validateTextureQuality (GFXTextureProfile *profile, U32 &width, U32 &height)
 Update width and height based on available resources.
U32 getBitmapScalePower (GFXTextureProfile *profile)
virtual GFXTextureObjectcreateTexture (GBitmap *bmp, const String &resourceName, GFXTextureProfile *profile, bool deleteBmp)
virtual GFXTextureObjectcreateTexture (DDSFile *dds, GFXTextureProfile *profile, bool deleteDDS)
virtual GFXTextureObjectcreateTexture (const Torque::Path &path, GFXTextureProfile *profile)
virtual GFXTextureObjectcreateTexture (U32 width, U32 height, void *pixels, GFXFormat format, GFXTextureProfile *profile)
virtual GFXTextureObjectcreateTexture (U32 width, U32 height, U32 depth, void *pixels, GFXFormat format, GFXTextureProfile *profile)
virtual GFXTextureObjectcreateTexture (U32 width, U32 height, GFXFormat format, GFXTextureProfile *profile, U32 numMipLevels, S32 antialiasLevel)
void deleteTexture (GFXTextureObject *texture)
void reloadTexture (GFXTextureObject *texture)
void reloadTextureResource (const char *filename)
Texture Necromancy
Texture necromancy in three easy steps:
  • If you want to destroy the texture manager, call kill().
  • If you want to switch resolutions, or otherwise reset the device, call zombify().
  • When you want to bring the manager back from zombie state, call resurrect().


void kill ()
void zombify ()
void resurrect ()
void registerTexCallback (GFXTexEventCallback, void *userData, S32 &handle)
void unregisterTexCallback (S32 handle)

Static Public Member Functions

static void init ()
 Set up some global script interface stuff.

Protected Types

 Living
 Zombie
 Dead
enum  TextureManagerState {
  Living,
  Zombie,
  Dead
}

Protected Member Functions

GFXTextureObjecthashFind (const String &name)
void hashInsert (GFXTextureObject *object)
void hashRemove (GFXTextureObject *object)
virtual void freeTexture (GFXTextureObject *texture, bool zombify=false)
 Frees the API handles to the texture, for D3D this is a release call.
virtual void refreshTexture (GFXTextureObject *texture)
void _validateTextureMemory ()
void _linkTexture (GFXTextureObject *obj)
void _validateTexParams (const U32 width, const U32 height, const GFXTextureProfile *profile, U32 &inOutNumMips, GFXFormat &inOutFormat)
GFXTextureObject_lookupTexture (const char *filename, const GFXTextureProfile *profile)
GFXTextureObject_lookupTexture (const DDSFile *ddsFile, const GFXTextureProfile *profile)
virtual GFXTextureObject_createTexture (U32 height, U32 width, U32 depth, GFXFormat format, GFXTextureProfile *profile, U32 numMipLevels, bool forceMips=false, S32 antialiasLevel=0)=0
 Allocate a texture with the internal API.
virtual bool _loadTexture (GFXTextureObject *texture, DDSFile *dds)=0
 Load a texture from a proper DDSFile instance.
virtual bool _loadTexture (GFXTextureObject *texture, GBitmap *bmp)=0
 Load data into a texture from a GBitmap using the internal API.
virtual bool _loadTexture (GFXTextureObject *texture, void *raw)=0
 Load data into a texture from a raw buffer using the internal API.
virtual bool _refreshTexture (GFXTextureObject *texture)=0
 Refresh a texture using the internal API.
virtual bool _freeTexture (GFXTextureObject *texture, bool zombify=false)=0
 Free a texture (but do not delete the GFXTextureObject) using the internal API.
virtual U32 _getTotalVideoMemory ()=0
 Returns available VRAM in bytes.

Protected Attributes

bool mAboveTextureThreshold
bool mValidTextureQualityInfo
GFXTextureObjectmListHead
GFXTextureObjectmListTail
GFXTextureObject ** mHashTable
U32 mHashCount
enum GFXTextureManager::TextureManagerState mTextureManagerState

Private Member Functions

void _resourceFileChanged (ResourceBase::Signature sig, ResourceBase &base, const Torque::Path &path)

Private Attributes

U32 mHandleCount
Vector< CallbackDatamEventCallbackList

Classes

struct  CallbackData

Member Enumeration Documentation

anonymous enum

Enumerator:
AA_MATCH_BACKBUFFER 

Enumerator:
Living 
Zombie 
Dead 


Constructor & Destructor Documentation

GFXTextureManager::GFXTextureManager (  ) 

virtual GFXTextureManager::~GFXTextureManager (  )  [virtual]


Member Function Documentation

static void GFXTextureManager::init (  )  [static]

Set up some global script interface stuff.

U32 GFXTextureManager::getTotalVideoMemory (  )  [inline]

virtual bool GFXTextureManager::validateTextureQuality ( GFXTextureProfile profile,
U32 width,
U32 height 
) [virtual]

Update width and height based on available resources.

We provide a simple interface for managing texture memory usage. Specifically, if the total video memory is below a certain threshold, we scale all texture resolutions down by a specific factor (you can specify different scale factors for different types of textures).

Note:
The base GFXTextureManager class provides all the logic to do this scaling. Subclasses need only implement getTotalVideoMemory().
Parameters:
type Type of the requested texture. This is used to determine scaling factors.
width Requested width - is changed to the actual width that should be used.
height Requested height - is changed to the actual height that should be used.
Returns:
True if the texture request should be granted, false otherwise.

U32 GFXTextureManager::getBitmapScalePower ( GFXTextureProfile profile  ) 

virtual GFXTextureObject* GFXTextureManager::createTexture ( GBitmap bmp,
const String resourceName,
GFXTextureProfile profile,
bool  deleteBmp 
) [virtual]

virtual GFXTextureObject* GFXTextureManager::createTexture ( DDSFile dds,
GFXTextureProfile profile,
bool  deleteDDS 
) [virtual]

virtual GFXTextureObject* GFXTextureManager::createTexture ( const Torque::Path path,
GFXTextureProfile profile 
) [virtual]

virtual GFXTextureObject* GFXTextureManager::createTexture ( U32  width,
U32  height,
void pixels,
GFXFormat  format,
GFXTextureProfile profile 
) [virtual]

virtual GFXTextureObject* GFXTextureManager::createTexture ( U32  width,
U32  height,
U32  depth,
void pixels,
GFXFormat  format,
GFXTextureProfile profile 
) [virtual]

virtual GFXTextureObject* GFXTextureManager::createTexture ( U32  width,
U32  height,
GFXFormat  format,
GFXTextureProfile profile,
U32  numMipLevels,
S32  antialiasLevel 
) [virtual]

void GFXTextureManager::deleteTexture ( GFXTextureObject texture  )  [inline]

void GFXTextureManager::reloadTexture ( GFXTextureObject texture  )  [inline]

void GFXTextureManager::reloadTextureResource ( const char *  filename  ) 

void GFXTextureManager::kill (  ) 

void GFXTextureManager::zombify (  ) 

void GFXTextureManager::resurrect (  ) 

void GFXTextureManager::registerTexCallback ( GFXTexEventCallback  ,
void userData,
S32 handle 
)

void GFXTextureManager::unregisterTexCallback ( S32  handle  ) 

GFXTextureObject* GFXTextureManager::hashFind ( const String name  )  [protected]

void GFXTextureManager::hashInsert ( GFXTextureObject object  )  [protected]

void GFXTextureManager::hashRemove ( GFXTextureObject object  )  [protected]

virtual void GFXTextureManager::freeTexture ( GFXTextureObject texture,
bool  zombify = false 
) [protected, virtual]

Frees the API handles to the texture, for D3D this is a release call.

Note:
freeTexture MUST NOT DELETE THE TEXTURE OBJECT

virtual void GFXTextureManager::refreshTexture ( GFXTextureObject texture  )  [protected, virtual]

virtual GFXTextureObject* GFXTextureManager::_createTexture ( U32  height,
U32  width,
U32  depth,
GFXFormat  format,
GFXTextureProfile profile,
U32  numMipLevels,
bool  forceMips = false,
S32  antialiasLevel = 0 
) [protected, pure virtual]

Allocate a texture with the internal API.

Parameters:
height Height of the texture.
width Width of the texture.
depth Depth of the texture. (Will normally be 1 unless we are doing a cubemap or volumetexture.)
format Pixel format of the texture.
profile Profile for the texture.
numMipLevels If not-NULL, then use that many mips. If NULL create the full mip chain
antialiasLevel,Use GFXTextureManager::AA_MATCH_BACKBUFFER to match the backbuffer settings (for render targets that want to share the backbuffer z buffer. 0 for no antialiasing, > 0 for levels that match the GFXVideoMode struct.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

virtual bool GFXTextureManager::_loadTexture ( GFXTextureObject texture,
DDSFile dds 
) [protected, pure virtual]

Load a texture from a proper DDSFile instance.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

virtual bool GFXTextureManager::_loadTexture ( GFXTextureObject texture,
GBitmap bmp 
) [protected, pure virtual]

Load data into a texture from a GBitmap using the internal API.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

virtual bool GFXTextureManager::_loadTexture ( GFXTextureObject texture,
void raw 
) [protected, pure virtual]

Load data into a texture from a raw buffer using the internal API.

Note that the size of the buffer is assumed from the parameters used for this GFXTextureObject's _createTexture call.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

virtual bool GFXTextureManager::_refreshTexture ( GFXTextureObject texture  )  [protected, pure virtual]

Refresh a texture using the internal API.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

virtual bool GFXTextureManager::_freeTexture ( GFXTextureObject texture,
bool  zombify = false 
) [protected, pure virtual]

Free a texture (but do not delete the GFXTextureObject) using the internal API.

This is only called during zombification for textures which need it, so you don't need to do any internal safety checks.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

virtual U32 GFXTextureManager::_getTotalVideoMemory (  )  [protected, pure virtual]

Returns available VRAM in bytes.

Implemented in GFXD3D8TextureManager, GFXD3D9TextureManager, and GFXGLTextureManager.

void GFXTextureManager::_validateTextureMemory (  )  [protected]

void GFXTextureManager::_linkTexture ( GFXTextureObject obj  )  [protected]

void GFXTextureManager::_validateTexParams ( const U32  width,
const U32  height,
const GFXTextureProfile profile,
U32 inOutNumMips,
GFXFormat inOutFormat 
) [protected]

GFXTextureObject* GFXTextureManager::_lookupTexture ( const char *  filename,
const GFXTextureProfile profile 
) [protected]

GFXTextureObject* GFXTextureManager::_lookupTexture ( const DDSFile ddsFile,
const GFXTextureProfile profile 
) [protected]

void GFXTextureManager::_resourceFileChanged ( ResourceBase::Signature  sig,
ResourceBase base,
const Torque::Path path 
) [private]


Member Data Documentation