2009-04-03 14:35:49 +00:00
|
|
|
// Copyright (C) 2003-2009 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"
|
2008-12-08 04:46:09 +00:00
|
|
|
#include "BPStructs.h"
|
|
|
|
|
|
|
|
class TextureMngr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct TCacheEntry
|
|
|
|
{
|
2009-03-08 19:19:51 +00:00
|
|
|
TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0), w(0), h(0), isRenderTarget(false), isUpsideDown(false), isNonPow2(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 hashoffset;
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
bool isUpsideDown;
|
|
|
|
bool isNonPow2; // if nonpow2, use GL_TEXTURE_2D, else GL_TEXTURE_RECTANGLE_NV
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
struct DEPTHTARGET
|
|
|
|
{
|
|
|
|
DEPTHTARGET() : targ(0), framecount(0) {}
|
|
|
|
GLuint targ;
|
|
|
|
int framecount;
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
static std::map<u32, DEPTHTARGET> mapDepthTargets;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
static TCacheEntry* Load(int texstage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt);
|
2009-03-05 23:11:13 +00:00
|
|
|
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, bool bScaleByHalf, const TRectangle &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_
|