# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CAsyncTextureManager Class Reference

Async Loader of textures and Texture Load Balancer. More...

#include <async_texture_manager.h>

List of all members.

Public Methods

 CAsyncTextureManager ()
 Constructor. More...

 ~CAsyncTextureManager ()
void setupLod (uint baseLevel, uint maxLevel)
 setup the mipMap levels. More...

void setupMaxUploadPerFrame (uint maxup)
 Setup max texture upload in driver per update() call (in bytes). Default to 64K. More...

void setupMaxHLSColoringPerFrame (uint maxCol)
 Setup max texture HLS Coloring per update() call (in bytes). Default to 20K. More...

void setupMaxTotalTextureSize (uint maxText)
 Setup max total texture size allowed. Default is 10Mo. More...

uint addTextureRef (const std::string &textName, CMeshBaseInstance *instance)
 Add a reference to a texture owned by an instance. More...

void releaseTexture (uint id, CMeshBaseInstance *instance)
 release a texture-instance tuple. the texture is released if no more instance use it. More...

bool isTextureUpLoaded (uint id) const
 tells if a texture is loaded in the driver (ie ready to use). More...

const NLMISC::CBitmapgetCoarseBitmap (uint id) const
 get the RAM LowDef version of a texture. More...

void update (IDriver *pDriver)
 update the manager. More...

uint getTotalTextureSizeAsked () const
 get the async texture Size asked (ie maybe bigger than MaxTotalTextureSize). More...

uint getLastTextureSizeGot () const
 get what the system really allows. More...


Public Attributes

CHLSTextureManager HLSManager
 User is free to add bank to this manager. Other methods are used by the async manager. More...


Private Types

typedef std::map< std::string,
uint
TTextureEntryMap
typedef TTextureEntryMap::iterator ItTextureEntryMap

Private Methods

void deleteTexture (uint id)
void getNextTextureToUpLoad (uint &nTotalColored, IDriver *pDriver)
bool uploadTexturePart (ITexture *pText, IDriver *pDriver, uint &nTotalUpload)
void updateTextureLodSystem (IDriver *pDriver)

Static Private Methods

bool validDXTCMipMap (ITexture *pText)

Private Attributes

uint _BaseLodLevel
uint _MaxLodLevel
uint _MaxUploadPerFrame
uint _MaxHLSColoringPerFrame
uint _MaxTotalTextureSize
uint _TotalTextureSizeAsked
uint _LastTextureSizeGot
std::vector< CTextureEntry * > _TextureEntries
std::vector< uint_FreeTextureIds
TTextureEntryMap _TextureEntryMap
std::vector< uint_WaitingTextures
CTextureBase_CurrentUploadTexture
uint _CurrentUploadTextureMipMap
uint _CurrentUploadTextureLine
CTextureLod_CurrentTextureLodLoaded


Detailed Description

Async Loader of textures and Texture Load Balancer.

Additionaly, store in RAM for each texture load a very low, DXTC1 compressed version of the texture. Used for some Lod systems.

Author:
Lionel Berenguier , Nevrax France
Date:
2002

Definition at line 53 of file async_texture_manager.h.


Member Typedef Documentation

typedef TTextureEntryMap::iterator NL3D::CAsyncTextureManager::ItTextureEntryMap [private]
 

Definition at line 122 of file async_texture_manager.h.

typedef std::map<std::string, uint> NL3D::CAsyncTextureManager::TTextureEntryMap [private]
 

Definition at line 121 of file async_texture_manager.h.


Constructor & Destructor Documentation

NL3D::CAsyncTextureManager::CAsyncTextureManager  
 

Constructor.

Definition at line 104 of file async_texture_manager.cpp.

References _BaseLodLevel, _CurrentTextureLodLoaded, _CurrentUploadTexture, _LastTextureSizeGot, _MaxHLSColoringPerFrame, _MaxLodLevel, _MaxTotalTextureSize, _MaxUploadPerFrame, and _TotalTextureSizeAsked.

NL3D::CAsyncTextureManager::~CAsyncTextureManager  
 

Definition at line 89 of file async_texture_manager.cpp.

References _CurrentTextureLodLoaded, _CurrentUploadTexture, _TextureEntries, _TextureEntryMap, _WaitingTextures, deleteTexture, and nlassert.


Member Function Documentation

uint NL3D::CAsyncTextureManager::addTextureRef const std::string &    textName,
CMeshBaseInstance   instance
 

Add a reference to a texture owned by an instance.

If the texture still exist, only the refcount is incremented Else If texture is found in the HLSTextureManager, it is builded (async) from it, else Begin Async loading

ThereFore, only CTextureFile are possible. Note also that the texture is uploaded with mipmap by default, and UpLoadFormat is also default (say ITexture::Auto)

If the texture file is not a DDS with mipmap, this is an error. But the system doens't fail and the file is entirely loaded and uploaded. The problem is that upload is not cut according to maxUpLoadPerFrame, so some freeze may occur.

void NL3D::CAsyncTextureManager::deleteTexture uint    id [private]
 

Definition at line 232 of file async_texture_manager.cpp.

References _CurrentTextureLodLoaded, _CurrentUploadTexture, _FreeTextureIds, _TextureEntries, _TextureEntryMap, _TotalTextureSizeAsked, _WaitingTextures, and id.

Referenced by releaseTexture, and ~CAsyncTextureManager.

const NLMISC::CBitmap * NL3D::CAsyncTextureManager::getCoarseBitmap uint    id const
 

get the RAM LowDef version of a texture.

Used For CLodCharacters return NULL if bad Id or if the texture is still not loaded. The bitmap returned has no mipmaps and should be in DXTC1 (not guaranteed).

Definition at line 343 of file async_texture_manager.cpp.

References _TextureEntries, and id.

uint NL3D::CAsyncTextureManager::getLastTextureSizeGot   const [inline]
 

get what the system really allows.

Definition at line 115 of file async_texture_manager.h.

References _LastTextureSizeGot.

void NL3D::CAsyncTextureManager::getNextTextureToUpLoad uint   nTotalColored,
IDriver   pDriver
[private]
 

Definition at line 552 of file async_texture_manager.cpp.

References _CurrentTextureLodLoaded, _CurrentUploadTexture, _CurrentUploadTextureLine, _CurrentUploadTextureMipMap, _MaxHLSColoringPerFrame, _TextureEntries, _WaitingTextures, HLSManager, NL3D::CAsyncTextureManager::CTextureLod::Loaded, nlverify, and updateTextureLodSystem.

Referenced by update.

uint NL3D::CAsyncTextureManager::getTotalTextureSizeAsked   const [inline]
 

get the async texture Size asked (ie maybe bigger than MaxTotalTextureSize).

Definition at line 113 of file async_texture_manager.h.

References _TotalTextureSizeAsked.

bool NL3D::CAsyncTextureManager::isTextureUpLoaded uint    id const
 

tells if a texture is loaded in the driver (ie ready to use).

Definition at line 334 of file async_texture_manager.cpp.

References _TextureEntries, id, and nlassert.

void NL3D::CAsyncTextureManager::releaseTexture uint    id,
CMeshBaseInstance   instance
 

release a texture-instance tuple. the texture is released if no more instance use it.

Definition at line 302 of file async_texture_manager.cpp.

References _TextureEntries, deleteTexture, id, and nlassert.

void NL3D::CAsyncTextureManager::setupLod uint    baseLevel,
uint    maxLevel
 

setup the mipMap levels.

\baseLevel When the texture is first added, it is loaded skipping the baseLevel first mipmap \maxLevel During time, furhter mipmap are loaded, according to instance position etc... maxLevel tells where to stop. If 0, the texture will finally be entirely uploaded. Default is 3,1.

Definition at line 121 of file async_texture_manager.cpp.

References _BaseLodLevel, _MaxLodLevel, and nlassert.

void NL3D::CAsyncTextureManager::setupMaxHLSColoringPerFrame uint    maxCol
 

Setup max texture HLS Coloring per update() call (in bytes). Default to 20K.

Definition at line 137 of file async_texture_manager.cpp.

References _MaxHLSColoringPerFrame.

void NL3D::CAsyncTextureManager::setupMaxTotalTextureSize uint    maxText
 

Setup max total texture size allowed. Default is 10Mo.

Definition at line 144 of file async_texture_manager.cpp.

References _MaxTotalTextureSize.

void NL3D::CAsyncTextureManager::setupMaxUploadPerFrame uint    maxup
 

Setup max texture upload in driver per update() call (in bytes). Default to 64K.

Definition at line 130 of file async_texture_manager.cpp.

References _MaxUploadPerFrame.

void NL3D::CAsyncTextureManager::update IDriver   pDriver
 

update the manager.

New loaded texture are uploaded. Instances are updated to know if all their pending textures have been uploaded.

Definition at line 361 of file async_texture_manager.cpp.

References _BaseLodLevel, _CurrentTextureLodLoaded, _CurrentUploadTexture, _MaxLodLevel, _TotalTextureSizeAsked, getNextTextureToUpLoad, NL3D::CAsyncTextureManager::CTextureBase::isTextureEntry, NL3D::CAsyncTextureManager::CTextureBase::Texture, uploadTexturePart, and validDXTCMipMap.

void NL3D::CAsyncTextureManager::updateTextureLodSystem IDriver   pDriver [private]
 

Definition at line 629 of file async_texture_manager.cpp.

References _CurrentTextureLodLoaded, _LastTextureSizeGot, _MaxTotalTextureSize, _TextureEntries, min, NL3D_ATM_MIN_DISTANCE, and nlassert.

Referenced by getNextTextureToUpLoad.

bool NL3D::CAsyncTextureManager::uploadTexturePart ITexture   pText,
IDriver   pDriver,
uint   nTotalUpload
[private]
 

Definition at line 451 of file async_texture_manager.cpp.

References _CurrentUploadTextureLine, _CurrentUploadTextureMipMap, _MaxUploadPerFrame, min, and validDXTCMipMap.

Referenced by update.

bool NL3D::CAsyncTextureManager::validDXTCMipMap ITexture   pText [static, private]
 

Definition at line 618 of file async_texture_manager.cpp.

Referenced by update, and uploadTexturePart.


Member Data Documentation

uint NL3D::CAsyncTextureManager::_BaseLodLevel [private]
 

Definition at line 212 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, setupLod, and update.

CTextureLod* NL3D::CAsyncTextureManager::_CurrentTextureLodLoaded [private]
 

Definition at line 231 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, deleteTexture, getNextTextureToUpLoad, update, updateTextureLodSystem, and ~CAsyncTextureManager.

CTextureBase* NL3D::CAsyncTextureManager::_CurrentUploadTexture [private]
 

Definition at line 226 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, deleteTexture, getNextTextureToUpLoad, update, and ~CAsyncTextureManager.

uint NL3D::CAsyncTextureManager::_CurrentUploadTextureLine [private]
 

Definition at line 228 of file async_texture_manager.h.

Referenced by getNextTextureToUpLoad, and uploadTexturePart.

uint NL3D::CAsyncTextureManager::_CurrentUploadTextureMipMap [private]
 

Definition at line 227 of file async_texture_manager.h.

Referenced by getNextTextureToUpLoad, and uploadTexturePart.

std::vector<uint> NL3D::CAsyncTextureManager::_FreeTextureIds [private]
 

Definition at line 221 of file async_texture_manager.h.

Referenced by deleteTexture.

uint NL3D::CAsyncTextureManager::_LastTextureSizeGot [private]
 

Definition at line 217 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, getLastTextureSizeGot, and updateTextureLodSystem.

uint NL3D::CAsyncTextureManager::_MaxHLSColoringPerFrame [private]
 

Definition at line 214 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, getNextTextureToUpLoad, and setupMaxHLSColoringPerFrame.

uint NL3D::CAsyncTextureManager::_MaxLodLevel [private]
 

Definition at line 212 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, setupLod, and update.

uint NL3D::CAsyncTextureManager::_MaxTotalTextureSize [private]
 

Definition at line 215 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, setupMaxTotalTextureSize, and updateTextureLodSystem.

uint NL3D::CAsyncTextureManager::_MaxUploadPerFrame [private]
 

Definition at line 213 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, setupMaxUploadPerFrame, and uploadTexturePart.

std::vector<CTextureEntry*> NL3D::CAsyncTextureManager::_TextureEntries [private]
 

Definition at line 220 of file async_texture_manager.h.

Referenced by deleteTexture, getCoarseBitmap, getNextTextureToUpLoad, isTextureUpLoaded, releaseTexture, updateTextureLodSystem, and ~CAsyncTextureManager.

TTextureEntryMap NL3D::CAsyncTextureManager::_TextureEntryMap [private]
 

Definition at line 222 of file async_texture_manager.h.

Referenced by deleteTexture, and ~CAsyncTextureManager.

uint NL3D::CAsyncTextureManager::_TotalTextureSizeAsked [private]
 

Definition at line 216 of file async_texture_manager.h.

Referenced by CAsyncTextureManager, deleteTexture, getTotalTextureSizeAsked, and update.

std::vector<uint> NL3D::CAsyncTextureManager::_WaitingTextures [private]
 

Definition at line 223 of file async_texture_manager.h.

Referenced by deleteTexture, getNextTextureToUpLoad, and ~CAsyncTextureManager.

CHLSTextureManager NL3D::CAsyncTextureManager::HLSManager
 

User is free to add bank to this manager. Other methods are used by the async manager.

Definition at line 57 of file async_texture_manager.h.

Referenced by getNextTextureToUpLoad.


The documentation for this class was generated from the following files: