71static unsigned unused_texture_id;
74static unsigned TexturesAppliedPerFrame;
95 texture_id(unused_texture_id++),
108 TextureLoadTask(
NULL),
109 ThumbnailLoadTask(
NULL),
121 delete TextureLoadTask;
122 TextureLoadTask=
NULL;
123 delete ThumbnailLoadTask;
124 ThumbnailLoadTask=
NULL;
128 D3DTexture->Release();
150 TexturesAppliedPerFrame=0;
165 if (invalidation_time_override)
167 if (age>invalidation_time_override)
196 if (TextureLoadTask) {
199 if (ThumbnailLoadTask) {
210 D3DTexture->Release();
274 if (D3DTexture !=
NULL) {
275 D3DTexture->Release();
278 if (D3DTexture !=
NULL) {
279 D3DTexture->AddRef();
290 WWPROFILE((
"TextureClass::Load_Locked_Surface()"));
291 if (D3DTexture) D3DTexture->Release();
307 if (D3DTexture == missing_texture)
312 missing_texture->Release();
344 return D3DTexture->GetPriority();
364 return D3DTexture->SetPriority(priority);
423 int total_locked_surface_size=0;
436 return total_locked_surface_size;
445 int total_texture_size=0;
455 return total_texture_size;
467 int total_texture_size=0;
480 return total_texture_size;
490 int total_texture_size=0;
503 return total_texture_size;
521 return texture_count;
545 return texture_count;
566 return texture_count;
590 return texture_count;
606:
TextureBaseClass(width, height, mip_level_count, pool, rendertarget,allow_reduction),
626 D3DPOOL d3dpool=(D3DPOOL)0;
671 const char *full_path,
674 bool allow_compression,
716 WWASSERT_PRINT(name && name[0],
"TextureClass CTor: NULL or empty texture name\n");
717 int len=strlen(name);
718 for (
int i=0;i<len;++i)
785 case WW3D_FORMAT_DXT1:
786 case WW3D_FORMAT_DXT2:
787 case WW3D_FORMAT_DXT3:
788 case WW3D_FORMAT_DXT4:
789 case WW3D_FORMAT_DXT5:
790 IsCompressionAllowed=true;
821 IDirect3DSurface8* surface;
823 D3DSURFACE_DESC d3d_desc;
824 ::ZeroMemory(&d3d_desc,
sizeof(D3DSURFACE_DESC));
826 Width=d3d_desc.Width;
896 IDirect3DBaseTexture8* d3d_texture,
898 bool disable_auto_invalidation
903 if (d3d_tex) d3d_tex->Release();
906 d3d_texture->AddRef();
912 IDirect3DSurface8* surface;
914 D3DSURFACE_DESC d3d_desc;
915 ::ZeroMemory(&d3d_desc,
sizeof(D3DSURFACE_DESC));
920 Width=d3d_desc.Width;
994 IDirect3DSurface8 *d3d_surface =
NULL;
997 d3d_surface->Release();
1023 WWASSERT_PRINT(0,
"Get_D3D_Surface_Level: D3DTexture is NULL!\n");
1027 IDirect3DSurface8 *d3d_surface =
NULL;
1042 D3DSURFACE_DESC desc;
1061 bool hastexinfo =
false;
1186 const char * filename;
1188 memset(&texinfo,0,
sizeof(texinfo));
1195 csave.
Write(filename,strlen(filename)+1);
1200 csave.
Write(&texinfo,
sizeof(texinfo));
1218 DepthStencilTextureFormat(zformat)
1220 D3DPOOL d3dpool=(D3DPOOL)0;
1277 IDirect3DBaseTexture8* d3d_texture,
1279 bool disable_auto_invalidation
1284 if (d3d_tex) d3d_tex->Release();
1287 d3d_texture->AddRef();
1293 IDirect3DSurface8* surface;
1295 D3DSURFACE_DESC d3d_desc;
1296 ::ZeroMemory(&d3d_desc,
sizeof(D3DSURFACE_DESC));
1301 Width=d3d_desc.Width;
1315 WWASSERT_PRINT(0,
"Get_D3D_Surface_Level: D3DTexture is NULL!\n");
1319 IDirect3DSurface8 *d3d_surface =
NULL;
1334 D3DSURFACE_DESC desc;
1354 bool allow_reduction
1356:
TextureClass(width, height, format, mip_level_count, pool, rendertarget)
1374 D3DPOOL d3dpool=(D3DPOOL)0;
1419 const char *full_path,
1422 bool allow_compression,
1423 bool allow_reduction
1461 WWASSERT_PRINT(name && name[0],
"TextureClass CTor: NULL or empty texture name\n");
1462 int len=strlen(name);
1463 for (
int i=0;i<len;++i)
1518:
TextureClass(0,0,mip_level_count, POOL_MANAGED,
false, surface->Get_Surface_Format())
1530 case WW3D_FORMAT_DXT1:
1531 case WW3D_FORMAT_DXT2:
1532 case WW3D_FORMAT_DXT3:
1533 case WW3D_FORMAT_DXT4:
1534 case WW3D_FORMAT_DXT5:
1535 IsCompressionAllowed=true;
1565 Peek_Texture()->AddRef();
1566 IDirect3DSurface8* surface;
1568 D3DSURFACE_DESC d3d_desc;
1569 ::ZeroMemory(&d3d_desc,
sizeof(D3DSURFACE_DESC));
1571 Width=d3d_desc.Width;
1596 IDirect3DBaseTexture8* d3d_texture,
1598 bool disable_auto_invalidation
1603 if (d3d_tex) d3d_tex->Release();
1606 d3d_texture->AddRef();
1612 D3DSURFACE_DESC d3d_desc;
1613 ::ZeroMemory(&d3d_desc,
sizeof(D3DSURFACE_DESC));
1619 Width=d3d_desc.Width;
1637 bool allow_reduction
1639:
TextureClass(width, height, format, mip_level_count, pool, rendertarget),
1658 D3DPOOL d3dpool=(D3DPOOL)0;
1703 const char *full_path,
1706 bool allow_compression,
1707 bool allow_reduction
1746 WWASSERT_PRINT(name && name[0],
"TextureClass CTor: NULL or empty texture name\n");
1747 int len=strlen(name);
1748 for (
int i=0;i<len;++i)
1803:
TextureClass(0,0,mip_level_count, POOL_MANAGED,
false, surface->Get_Surface_Format())
1815 case WW3D_FORMAT_DXT1:
1816 case WW3D_FORMAT_DXT2:
1817 case WW3D_FORMAT_DXT3:
1818 case WW3D_FORMAT_DXT4:
1819 case WW3D_FORMAT_DXT5:
1820 IsCompressionAllowed=true;
1850 Peek_Texture()->AddRef();
1851 IDirect3DSurface8* surface;
1853 D3DSURFACE_DESC d3d_desc;
1854 ::ZeroMemory(&d3d_desc,
sizeof(D3DSURFACE_DESC));
1856 Width=d3d_desc.Width;
1884 IDirect3DBaseTexture8* d3d_texture,
1886 bool disable_auto_invalidation
1891 if (d3d_tex) d3d_tex->Release();
1894 d3d_texture->AddRef();
1900 D3DVOLUME_DESC d3d_desc;
1901 ::ZeroMemory(&d3d_desc,
sizeof(D3DVOLUME_DESC));
1908 Width=d3d_desc.Width;
1910 Depth=d3d_desc.Depth;
#define DX8_RECORD_TEXTURE(t)
#define W3DTEXTURE_CLAMP_U
#define W3DTEXTURE_MIP_LEVELS_MASK
#define W3DTEXTURE_MIP_LEVELS_ALL
#define W3DTEXTURE_MIP_LEVELS_3
#define W3DTEXTURE_MIP_LEVELS_2
#define W3DTEXTURE_CLAMP_V
#define W3DTEXTURE_TYPE_BUMPMAP
#define W3DTEXTURE_MIP_LEVELS_4
#define W3DTEXTURE_NO_LOD
#define W3DTEXTURE_TYPE_MASK
#define W3DTEXTURE_TYPE_COLORMAP
uint32 Cur_Chunk_Length()
uint32 Read(void *buf, uint32 nbytes)
uint32 Write(const void *buf, uint32 nbytes)
bool Begin_Chunk(uint32 id)
virtual void Apply_New_Surface(IDirect3DBaseTexture8 *tex, bool initialized, bool disable_auto_invalidation=false)
Apply new surface to texture.
CubeTextureClass(unsigned width, unsigned height, WW3DFormat format, MipCountType mip_level_count=MIP_LEVELS_ALL, PoolType pool=POOL_MANAGED, bool rendertarget=false, bool allow_reduction=true)
static void Remove(TextureBaseClass *tex)
static void Add(TextureTrackerClass *track)
static bool Is_Initted(void)
static IDirect3DTexture8 * _Create_DX8_Texture(unsigned int width, unsigned int height, WW3DFormat format, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED, bool rendertarget=false)
static const DX8Caps * Get_Current_Caps()
static IDirect3DCubeTexture8 * _Create_DX8_Cube_Texture(unsigned int width, unsigned int height, WW3DFormat format, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED, bool rendertarget=false)
static void Set_DX8_Texture(unsigned int stage, IDirect3DBaseTexture8 *texture)
static IDirect3DTexture8 * _Create_DX8_ZTexture(unsigned int width, unsigned int height, WW3DZFormat zformat, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED)
static IDirect3DVolumeTexture8 * _Create_DX8_Volume_Texture(unsigned int width, unsigned int height, unsigned int depth, WW3DFormat format, MipCountType mip_level_count, D3DPOOL pool=D3DPOOL_MANAGED)
static IDirect3DTexture8 * _Get_Missing_Texture()
void Get_Description(SurfaceDescription &surface_desc)
IDirect3DSurface8 * Peek_D3D_Surface(void)
bool Is_Missing_Texture()
Is missing texture.
unsigned Get_Reduction() const
Get reduction mip levels.
static int _Get_Total_Procedural_Texture_Count()
Get total procedural texture count.
IDirect3DTexture8 * Peek_D3D_Texture() const
friend class DX8TextureTrackerClass
bool Is_Procedural() const
static int _Get_Total_Procedural_Texture_Size()
Get total procedural texture size.
static int _Get_Total_Texture_Size()
Get total texture size.
MipCountType MipLevelCount
unsigned int Get_Priority(void)
Get priority.
IDirect3DVolumeTexture8 * Peek_D3D_VolumeTexture() const
unsigned int Set_Priority(unsigned int priority)
Set priority.
static void Apply_Null(unsigned int stage)
Apply NULL texture state.
IDirect3DBaseTexture8 * Peek_D3D_Base_Texture() const
Returns a pointer to the d3d texture.
void Set_D3D_Base_Texture(IDirect3DBaseTexture8 *tex)
Set the d3d texture pointer. Handles ref counts properly.
static void Invalidate_Old_Unused_Textures(unsigned inactive_time_override)
Invalidate old unused textures.
const StringClass & Get_Full_Path(void) const
void Set_HSV_Shift(const Vector3 &hsv_shift)
void Invalidate()
Invalidate this texture.
void Set_Full_Path(const char *path)
static int _Get_Total_Lightmap_Texture_Size()
Get total lightmap texture size.
static int _Get_Total_Texture_Count()
Get total texture count.
virtual ~TextureBaseClass()
Base texture class destructor.
void Set_Texture_Name(const char *name)
Set texture name.
unsigned LastInactivationSyncTime
bool IsCompressionAllowed
void Poke_Texture(IDirect3DBaseTexture8 *tex)
static int _Get_Total_Lightmap_Texture_Count()
Get total light map texture count.
unsigned InactivationTime
TextureBaseClass(unsigned width, unsigned height, MipCountType mip_level_count=MIP_LEVELS_ALL, PoolType pool=POOL_MANAGED, bool rendertarget=false, bool reducible=true)
friend class DX8ZTextureTrackerClass
virtual unsigned Get_Texture_Memory_Usage() const =0
void Load_Locked_Surface()
Load locked surface.
static int _Get_Total_Locked_Surface_Size()
Get total locked surface size.
static int _Get_Total_Locked_Surface_Count()
Get total locked surface count.
IDirect3DCubeTexture8 * Peek_D3D_CubeTexture() const
unsigned ExtendedInactivationTime
TextureFilterClass Filter
IDirect3DSurface8 * Get_D3D_Surface_Level(unsigned int level=0)
Get D3D surface from mip level.
virtual unsigned Get_Texture_Memory_Usage() const
Get texture memory usage.
void Get_Level_Description(SurfaceClass::SurfaceDescription &desc, unsigned int level=0)
Get surface description for a mip level.
SurfaceClass * Get_Surface_Level(unsigned int level=0)
Get surface from mip level.
TextureClass(unsigned width, unsigned height, WW3DFormat format, MipCountType mip_level_count=MIP_LEVELS_ALL, PoolType pool=POOL_MANAGED, bool rendertarget=false, bool allow_reduction=true)
virtual void Init()
Initialise the texture.
TextureFilterClass & Get_Filter()
virtual void Apply(unsigned int stage)
Apply texture states.
virtual void Apply_New_Surface(IDirect3DBaseTexture8 *tex, bool initialized, bool disable_auto_invalidation=false)
Apply new surface to texture.
void Set_Mip_Mapping(FilterType mipmap)
Set mip mapping filter (legacy)
FilterType Get_Mip_Mapping(void) const
TxtAddrMode Get_U_Addr_Mode(void) const
void Set_V_Addr_Mode(TxtAddrMode mode)
TxtAddrMode Get_V_Addr_Mode(void) const
void Set_U_Addr_Mode(TxtAddrMode mode)
static void Request_Background_Loading(TextureBaseClass *tc)
static void Request_Thumbnail(TextureBaseClass *tc)
static bool Is_DX8_Thread(void)
static void Request_Foreground_Loading(TextureBaseClass *tc)
unsigned Get_Original_Texture_Mip_Level_Count() const
unsigned Get_Original_Texture_Height() const
unsigned Get_Original_Texture_Width() const
static ThumbnailClass * Peek_Thumbnail_Instance_From_Any_Manager(const StringClass &name)
VolumeTextureClass(unsigned width, unsigned height, unsigned depth, WW3DFormat format, MipCountType mip_level_count=MIP_LEVELS_ALL, PoolType pool=POOL_MANAGED, bool rendertarget=false, bool allow_reduction=true)
virtual void Apply_New_Surface(IDirect3DBaseTexture8 *tex, bool initialized, bool disable_auto_invalidation=false)
Apply new surface to texture.
virtual TextureClass * Get_Texture(const char *filename, MipCountType mip_level_count=MIP_LEVELS_ALL, WW3DFormat texture_format=WW3D_FORMAT_UNKNOWN, bool allow_compression=true, TextureBaseClass::TexAssetType type=TextureBaseClass::TEX_REGULAR, bool allow_reduction=true)
static WW3DAssetManager * Get_Instance(void)
static unsigned int Get_Sync_Time(void)
static int Get_Texture_Reduction(void)
static bool Is_Texturing_Enabled()
static bool Is_Large_Texture_Extra_Reduction_Enabled(void)
static bool Get_Thumbnail_Enabled()
virtual void Apply_New_Surface(IDirect3DBaseTexture8 *tex, bool initialized, bool disable_auto_invalidation=false)
Apply new surface to texture.
virtual unsigned Get_Texture_Memory_Usage() const
Get texture memory usage.
IDirect3DSurface8 * Get_D3D_Surface_Level(unsigned int level=0)
Get D3D surface from mip level.
virtual void Apply(unsigned int stage)
Apply depth stencil texture.
ZTextureClass(unsigned width, unsigned height, WW3DZFormat zformat, MipCountType mip_level_count=MIP_LEVELS_ALL, PoolType pool=POOL_MANAGED)
WWINLINE void DX8_ErrorCode(unsigned res)
#define REF_PTR_RELEASE(x)
TextureClass * Load_Texture(ChunkLoadClass &cload)
const unsigned MAX_TEXTURES_APPLIED_PER_FRAME
const unsigned DEFAULT_INACTIVATION_TIME
void Save_Texture(TextureClass *texture, ChunkSaveClass &csave)
void setup_texture_attributes(TextureClass *tex, W3dTextureInfoStruct *texinfo)
#define WWASSERT_PRINT(expr, string)