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/
|
|
|
|
|
|
|
|
#ifndef _TEXTURECACHE_H
|
|
|
|
#define _TEXTURECACHE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "D3DBase.h"
|
2009-09-03 21:56:08 +00:00
|
|
|
#include "VideoCommon.h"
|
2009-06-22 09:31:30 +00:00
|
|
|
#include "BPMemory.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
class TextureCache
|
|
|
|
{
|
2009-03-07 18:05:29 +00:00
|
|
|
public:
|
2008-12-08 04:46:09 +00:00
|
|
|
struct TCacheEntry
|
|
|
|
{
|
|
|
|
LPDIRECT3DTEXTURE9 texture;
|
2009-09-15 21:05:31 +00:00
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
u32 addr;
|
2009-09-15 21:05:31 +00:00
|
|
|
u32 size_in_bytes;
|
2010-02-03 03:52:50 +00:00
|
|
|
u64 hash;
|
2008-12-08 04:46:09 +00:00
|
|
|
u32 paletteHash;
|
|
|
|
u32 oldpixel;
|
2009-09-15 21:05:31 +00:00
|
|
|
|
|
|
|
int frameCount;
|
2010-06-05 00:01:18 +00:00
|
|
|
int w, h, fmt,MipLevels;
|
2009-12-15 01:40:54 +00:00
|
|
|
int Scaledw, Scaledh;
|
2009-12-07 18:48:31 +00:00
|
|
|
|
|
|
|
float scaleX, scaleY; // Hires texutres need this
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
bool isRenderTarget;
|
2010-07-18 00:18:31 +00:00
|
|
|
bool isDynamic;// mofified from cpu
|
2008-12-08 04:46:09 +00:00
|
|
|
bool isNonPow2;
|
2009-09-15 21:05:31 +00:00
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
TCacheEntry()
|
|
|
|
{
|
2009-09-15 21:05:31 +00:00
|
|
|
texture = 0;
|
|
|
|
isRenderTarget = 0;
|
|
|
|
hash = 0;
|
|
|
|
paletteHash = 0;
|
|
|
|
oldpixel = 0;
|
2009-12-07 18:48:31 +00:00
|
|
|
addr = 0;
|
|
|
|
size_in_bytes = 0;
|
|
|
|
frameCount = 0;
|
|
|
|
scaleX = 1.0f;
|
|
|
|
scaleY = 1.0f;
|
|
|
|
isNonPow2 = true;
|
2009-12-15 01:40:54 +00:00
|
|
|
w = 0;
|
|
|
|
h = 0;
|
|
|
|
Scaledw = 0;
|
|
|
|
Scaledh = 0;
|
2008-12-08 04:46:09 +00:00
|
|
|
}
|
2009-03-06 16:47:04 +00:00
|
|
|
void Destroy(bool shutdown);
|
ok, here goes a really experimental commit:
replace efb to ram implementation by a hybrid approach.
explanation:
when copying from efb to texture, instead of make a copy to a texture or to the ram, copy the data to both, in hi quality to the texture and in native quality to the ram.
then instead of re-decoding the data from ram (very slow) use the data in the texture.
to improve this even more, test if the cpu has modified the data in the ram copy, if so, update the texture in memory and mark it as dynamic to avoid redundant work in future frames.
having all this implemented this is what is archived:
sms: full quality with scaled efb copies and fully functional goop cleaning :)
ztp: efb to texture speed with full map support.
nsmbw: this is a hard to emulate game, as it make a lot of shading and texture modification in cpu. it only have 35 fps in my system with new efb to ram but is 10 fps faster than normal efb to ram.
this game also show me another unimplemented feature, copy efb to multiple textures at the same time (is used to animate coins and other things in the world).
this is a remaining todo in efb to texture.
a lot of games should improve, so please test and let me know any regresion caused by this commit.
if everyone likes this the next step is, implement efb to multilpe textures and merge efb to ram and efb to texture.
then port to the other plugins.
enjoy.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5846 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-07-06 22:27:13 +00:00
|
|
|
int IntersectsMemoryRange(u32 range_address, u32 range_size);
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2009-03-07 18:05:29 +00:00
|
|
|
private:
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
typedef std::map<u32,TCacheEntry> TexCache;
|
|
|
|
|
|
|
|
static u8 *temp;
|
|
|
|
static TexCache textures;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void Init();
|
|
|
|
static void Cleanup();
|
|
|
|
static void Shutdown();
|
2009-03-06 16:47:04 +00:00
|
|
|
static void Invalidate(bool shutdown);
|
2009-11-14 17:50:51 +00:00
|
|
|
static void InvalidateRange(u32 start_address, u32 size);
|
ok, here goes a really experimental commit:
replace efb to ram implementation by a hybrid approach.
explanation:
when copying from efb to texture, instead of make a copy to a texture or to the ram, copy the data to both, in hi quality to the texture and in native quality to the ram.
then instead of re-decoding the data from ram (very slow) use the data in the texture.
to improve this even more, test if the cpu has modified the data in the ram copy, if so, update the texture in memory and mark it as dynamic to avoid redundant work in future frames.
having all this implemented this is what is archived:
sms: full quality with scaled efb copies and fully functional goop cleaning :)
ztp: efb to texture speed with full map support.
nsmbw: this is a hard to emulate game, as it make a lot of shading and texture modification in cpu. it only have 35 fps in my system with new efb to ram but is 10 fps faster than normal efb to ram.
this game also show me another unimplemented feature, copy efb to multiple textures at the same time (is used to animate coins and other things in the world).
this is a remaining todo in efb to texture.
a lot of games should improve, so please test and let me know any regresion caused by this commit.
if everyone likes this the next step is, implement efb to multilpe textures and merge efb to ram and efb to texture.
then port to the other plugins.
enjoy.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5846 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-07-06 22:27:13 +00:00
|
|
|
static void MakeRangeDynamic(u32 start_address, u32 size);
|
2010-04-14 13:57:16 +00:00
|
|
|
static TCacheEntry *Load(int stage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt,bool UseNativeMips, int maxlevel);
|
2009-09-04 06:09:21 +00:00
|
|
|
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect);
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2010-06-02 20:35:12 +00:00
|
|
|
#endif
|