1 /******************************************************************************
2 * Arachnoid Graphics Plugin for Mupen64Plus
3 * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/
5 * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *****************************************************************************/
22 #ifndef TEXTURE_CACHE_H_
23 #define TEXTURE_CACHE_H_
25 #include "CachedTexture.h"
26 #include "CRCCalculator2.h"
27 #include "ImageFormatSelector.h"
30 //Forward declarations
35 //*****************************************************************************
37 //! Class used to activate textures and store used textures for reuse.
38 //! @details Nintendo64 has a texture cache of 4 KiB
39 //*****************************************************************************
44 //Constructor / Destructor
49 bool initialize(RSP* rsp, RDP* rdp, Memory* memory, unsigned int textureBitDepth, unsigned int cacheSize=(32 * 1048576));
50 void update(unsigned int tile);
53 void setMipmap( int value ) { m_mipmap = value; }
56 CachedTexture* addTop();
58 void remove( CachedTexture *texture );
61 void moveToTop( CachedTexture *newtop );
64 CachedTexture* getCurrentTexture(int index) { return m_currentTextures[index]; }
68 void _loadTexture(CachedTexture* texture);
69 void _calculateTextureSize(unsigned int tile, CachedTexture* out, unsigned int& maskWidth, unsigned int& maskHeight);
70 void _activateTexture( unsigned int t, CachedTexture *texture );
71 unsigned int _calculateCRC(unsigned int t, unsigned int width, unsigned int height);
76 RSP* m_rsp; //!< Pointer to Reality Signal Processor
77 RDP* m_rdp; //!< Pointer to Reality Drawing Processor
78 Memory* m_memory; //!< Pointer to Memory manager (handles RDRAM, Texture Memory...)
80 ImageFormatSelector m_formatSelector; //!< Image Format Selector used when decoding textures
81 CRCCalculator2 m_crcCalculator; //!< Hash value calculator for textures
83 unsigned int m_maxBytes; //!< Maximum number of bytes this cache have
84 unsigned int m_cachedBytes; //!< Current number of bytes in cache
85 unsigned int m_bitDepth; //!<
89 typedef std::list<CachedTexture*> TextureList;
90 TextureList m_cachedTextures; //!< List of cached textures
92 //Pointers to current textures
93 CachedTexture* m_currentTextures[2]; //!< Two textures for multi-texturing.