Classes | |
struct | CachedTexture |
struct | ExternalTexture |
struct | TextureMetaData |
Public Types | |
enum | TexturePass { PASS_DIFFUSE, PASS_LIGHT, PASS_DETAIL, PASS_FOG, PASS_MACRO, PASS_BUMP, PASS_HEIGHT, DUMMY_NUM_TEXTURE_PASSES } |
enum | ExternalTextures { EXTRA_TEX_DETAIL, EXTRA_TEX_BUMP, EXTRA_TEX_HEIGHT, DUMMY_NUM_EXTERNAL_TEXTURES } |
Public Member Functions | |
Texture cache | |
TextureCache (ID3D10Device *device) | |
ID3D10Texture2D * | createTexture (const D3D10_TEXTURE2D_DESC &desc, const D3D10_SUBRESOURCE_DATA &data) const |
void | updateMip (DWORD64 id, int mipNum, const D3D10_SUBRESOURCE_DATA &data) const |
bool | loadFileTexture (wchar_t *fileName, ID3D10Texture2D **tex, D3DX10_IMAGE_LOAD_INFO *loadInfo) const |
void | cacheTexture (DWORD64 id, const TextureMetaData &metadata, ID3D10Texture2D *tex, int extraIndex=-1) |
bool | textureIsCached (DWORD64 id) const |
const TextureMetaData & | getTextureMetaData (DWORD64 id) const |
const TextureMetaData * | setTexture (const Shader_Unreal *shader, TexturePass pass, DWORD64 id, int extraIndex=-1) |
void | deleteTexture (DWORD64 id) |
void | flush () |
Static Public Attributes | |
static const ExternalTexture | externalTextures [DUMMY_NUM_EXTERNAL_TEXTURES] = {{L".detail",1},{L".bump",0},{L".height",0}} |
Private Attributes | |
struct { | |
DWORD64 boundTextureID [DUMMY_NUM_TEXTURE_PASSES] | |
} | texturePasses |
stdext::hash_map< unsigned __int64, CachedTexture > | textureCache |
ID3D10Device * | device |
External textures: textures that don't replace another texture, but are extra bumpmaps, detail textures etc.
List of texture passes that can be bound.
ID3D10Texture2D * TextureCache::createTexture | ( | const D3D10_TEXTURE2D_DESC & | desc, | |
const D3D10_SUBRESOURCE_DATA & | data | |||
) | const |
Create a texture from a descriptor and data to fill it with.
desc | Direct3D texture description. | |
data | Data to fill the texture with. |
void TextureCache::deleteTexture | ( | DWORD64 | id | ) |
Delete a texture (so it can be overwritten with an updated one).
void TextureCache::flush | ( | ) |
Clear texture cache.
const TextureCache::TextureMetaData & TextureCache::getTextureMetaData | ( | DWORD64 | id | ) | const |
Returns texture metadata.
id | CacheID for texture. |
bool TextureCache::loadFileTexture | ( | wchar_t * | fileName, | |
ID3D10Texture2D ** | tex, | |||
D3DX10_IMAGE_LOAD_INFO * | loadInfo | |||
) | const |
Load a texture from a .dds file
const TextureCache::TextureMetaData * TextureCache::setTexture | ( | const Shader_Unreal * | shader, | |
TexturePass | pass, | |||
DWORD64 | id, | |||
int | extraIndex = -1 | |||
) |
Set the texture for a texture pass (diffuse, lightmap, etc). Texture is only set if it's not already the current one for that pass. Cached polygons (using the previous set of textures) are drawn before the switch is made.
id | CacheID for texture. NULL sets no texture for the pass (by disabling it using a shader constant). | |
extraIndex | Index of the extra external texture slot to use (optional), -1 for none. |
bool TextureCache::textureIsCached | ( | DWORD64 | id | ) | const |
Returns true if texture is in cache.
id | CacheID for texture. |
void TextureCache::updateMip | ( | DWORD64 | id, | |
int | mipNum, | |||
const D3D10_SUBRESOURCE_DATA & | data | |||
) | const |
Update a single texture mip using a copy operation.
id | CacheID to insert texture with. | |
mipNum | Mip level to update. | |
data | Data to write to the mip. |
DWORD64 TextureCache::boundTextureID[DUMMY_NUM_TEXTURE_PASSES] |
CPU side bound texture IDs for the various passes as defined in the shader
const TextureCache::ExternalTexture TextureCache::externalTextures = {{L".detail",1},{L".bump",0},{L".height",0}} [static] |
Cache for game textures; also handles the external extra textures.
stdext::hash_map<unsigned __int64, CachedTexture> TextureCache::textureCache [private] |
The actual cache
struct { ... } TextureCache::texturePasses [private] |
Texture cache variables