2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#ifndef _TEXTUREMNGR_H_
|
|
|
|
#define _TEXTUREMNGR_H_
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
2008-12-26 12:24:15 +00:00
|
|
|
#include "VideoCommon.h"
|
2009-01-30 07:35:47 +00:00
|
|
|
#include "GLUtil.h"
|
2009-06-22 09:31:30 +00:00
|
|
|
#include "BPStructs.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
class TextureMngr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct TCacheEntry
|
|
|
|
{
|
2009-09-15 21:05:31 +00:00
|
|
|
TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0), w(0), h(0), scaleX(1.0f), scaleY(1.0f), isRenderTarget(false), isRectangle(true), bHaveMipMaps(false) { mode.hex = 0xFCFCFCFC; }
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
GLuint texture;
|
|
|
|
u32 addr;
|
2009-03-08 19:19:51 +00:00
|
|
|
u32 size_in_bytes;
|
2008-12-08 04:46:09 +00:00
|
|
|
u32 hash;
|
|
|
|
u32 paletteHash;
|
|
|
|
u32 oldpixel; // used for simple cleanup
|
|
|
|
TexMode0 mode; // current filter and clamp modes that texture is set to
|
|
|
|
|
|
|
|
int frameCount;
|
2009-03-08 19:19:51 +00:00
|
|
|
int w, h, fmt;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-05-07 07:43:56 +00:00
|
|
|
float scaleX, scaleY; // Hires texutres need this
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
bool isRenderTarget; // if render texture, then rendertex is filled with the direct copy of the render target
|
|
|
|
// later conversions would have to convert properly from rendertexfmt to texfmt
|
2009-07-19 08:17:41 +00:00
|
|
|
bool isRectangle; // if nonpow2, use GL_TEXTURE_2D, else GL_TEXTURE_RECTANGLE_NV
|
2008-12-08 04:46:09 +00:00
|
|
|
bool bHaveMipMaps;
|
|
|
|
|
|
|
|
void SetTextureParameters(TexMode0& newmode);
|
2009-02-22 20:21:56 +00:00
|
|
|
void Destroy(bool shutdown);
|
2008-12-08 04:46:09 +00:00
|
|
|
void ConvertFromRenderTarget(u32 taddr, int twidth, int theight, int tformat, int tlutaddr, int tlutfmt);
|
2009-03-08 19:19:51 +00:00
|
|
|
bool IntersectsMemoryRange(u32 range_address, u32 range_size);
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2009-02-22 20:21:56 +00:00
|
|
|
typedef std::map<u32, TCacheEntry> TexCache;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
static u8 *temp;
|
|
|
|
static TexCache textures;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void Init();
|
2009-02-22 20:21:56 +00:00
|
|
|
static void ProgressiveCleanup();
|
2008-12-08 04:46:09 +00:00
|
|
|
static void Shutdown();
|
2009-02-22 20:21:56 +00:00
|
|
|
static void Invalidate(bool shutdown);
|
2009-03-08 19:19:51 +00:00
|
|
|
static void InvalidateRange(u32 start_address, u32 size);
|
|
|
|
|
2009-08-11 20:36:13 +00:00
|
|
|
static TCacheEntry* Load(int texstage, u32 address, int width, int height, u32 format, int tlutaddr, int tlutfmt);
|
2009-09-04 06:09:21 +00:00
|
|
|
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
static void DisableStage(int stage); // sets active texture
|
2009-01-11 22:25:57 +00:00
|
|
|
|
|
|
|
static void ClearRenderTargets(); // sets render target value of all textures to false
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2008-12-26 12:24:15 +00:00
|
|
|
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#endif // _TEXTUREMNGR_H_
|