2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:25:12 +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/
|
|
|
|
|
|
|
|
#include <d3dx9.h>
|
|
|
|
|
2009-09-01 11:14:58 +00:00
|
|
|
#include "Globals.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "Statistics.h"
|
2009-03-07 18:05:29 +00:00
|
|
|
#include "MemoryUtil.h"
|
2009-09-01 11:14:58 +00:00
|
|
|
#include "Hash.h"
|
|
|
|
|
|
|
|
#include "CommonPaths.h"
|
|
|
|
#include "FileUtil.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
#include "D3DBase.h"
|
|
|
|
#include "D3DTexture.h"
|
2009-11-08 20:35:11 +00:00
|
|
|
#include "D3DUtil.h"
|
2009-09-13 17:46:33 +00:00
|
|
|
#include "FramebufferManager.h"
|
2009-11-08 20:35:11 +00:00
|
|
|
#include "PixelShaderCache.h"
|
|
|
|
#include "PixelShaderManager.h"
|
|
|
|
#include "VertexShaderManager.h"
|
|
|
|
#include "VertexShaderCache.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
#include "Render.h"
|
|
|
|
|
|
|
|
#include "TextureDecoder.h"
|
|
|
|
#include "TextureCache.h"
|
2009-12-22 06:47:42 +00:00
|
|
|
#include "HiresTextures.h"
|
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
|
|
|
#include "TextureConverter.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-18 03:12:32 +00:00
|
|
|
#include "debugger/debugger.h"
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
u8 *TextureCache::temp = NULL;
|
|
|
|
TextureCache::TexCache TextureCache::textures;
|
|
|
|
|
|
|
|
extern int frameCount;
|
|
|
|
|
|
|
|
#define TEMP_SIZE (1024*1024*4)
|
2009-03-07 18:05:29 +00:00
|
|
|
#define TEXTURE_KILL_THRESHOLD 200
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-03-06 16:47:04 +00:00
|
|
|
void TextureCache::TCacheEntry::Destroy(bool shutdown)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
if (texture)
|
|
|
|
texture->Release();
|
|
|
|
texture = 0;
|
2009-09-19 13:14:55 +00:00
|
|
|
if (!isRenderTarget && !shutdown && !g_ActiveConfig.bSafeTextureCache)
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
2009-09-15 21:05:31 +00:00
|
|
|
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr);
|
2009-03-07 18:05:29 +00:00
|
|
|
if (ptr && *ptr == hash)
|
2008-12-08 05:25:12 +00:00
|
|
|
*ptr = oldpixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextureCache::Init()
|
|
|
|
{
|
2009-03-07 18:05:29 +00:00
|
|
|
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
|
2009-09-13 08:21:35 +00:00
|
|
|
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
|
2009-12-22 06:47:42 +00:00
|
|
|
HiresTextures::Init(globals->unique_id);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-03-06 16:47:04 +00:00
|
|
|
void TextureCache::Invalidate(bool shutdown)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-05-28 23:14:16 +00:00
|
|
|
for (TexCache::iterator iter = textures.begin(); iter != textures.end(); ++iter)
|
2009-03-06 16:47:04 +00:00
|
|
|
iter->second.Destroy(shutdown);
|
2008-12-08 05:25:12 +00:00
|
|
|
textures.clear();
|
2009-12-22 06:47:42 +00:00
|
|
|
HiresTextures::Shutdown();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 17:50:51 +00:00
|
|
|
void TextureCache::InvalidateRange(u32 start_address, u32 size)
|
|
|
|
{
|
|
|
|
TexCache::iterator iter = textures.begin();
|
|
|
|
while (iter != textures.end())
|
|
|
|
{
|
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 rangePosition = iter->second.IntersectsMemoryRange(start_address, size);
|
|
|
|
if (rangePosition == 0)
|
2009-11-14 17:50:51 +00:00
|
|
|
{
|
|
|
|
iter->second.Destroy(false);
|
2010-05-28 23:14:16 +00:00
|
|
|
textures.erase(iter++);
|
2009-11-14 17:50:51 +00:00
|
|
|
}
|
2010-07-12 19:30:25 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
++iter;
|
2009-11-14 17:50:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void TextureCache::MakeRangeDynamic(u32 start_address, u32 size)
|
|
|
|
{
|
|
|
|
TexCache::iterator iter = textures.begin();
|
|
|
|
while (iter != textures.end())
|
|
|
|
{
|
|
|
|
int rangePosition = iter->second.IntersectsMemoryRange(start_address, size);
|
|
|
|
if ( rangePosition == 0)
|
|
|
|
{
|
2010-07-09 20:56:16 +00:00
|
|
|
iter->second.hash = 0;
|
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
|
|
|
}
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int TextureCache::TCacheEntry::IntersectsMemoryRange(u32 range_address, u32 range_size)
|
2009-11-14 17:50:51 +00:00
|
|
|
{
|
|
|
|
if (addr + size_in_bytes < range_address)
|
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
|
|
|
return -1;
|
2009-11-14 17:50:51 +00:00
|
|
|
if (addr >= range_address + range_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
|
|
|
return 1;
|
|
|
|
return 0;
|
2009-11-14 17:50:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
void TextureCache::Shutdown()
|
|
|
|
{
|
2009-03-06 16:47:04 +00:00
|
|
|
Invalidate(true);
|
2010-06-05 01:38:22 +00:00
|
|
|
FreeMemoryPages(temp, TEMP_SIZE);
|
2009-03-07 18:05:29 +00:00
|
|
|
temp = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextureCache::Cleanup()
|
|
|
|
{
|
2009-09-13 08:21:35 +00:00
|
|
|
TexCache::iterator iter = textures.begin();
|
|
|
|
while (iter != textures.end())
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-09-02 15:38:04 +00:00
|
|
|
if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-07-12 19:30:25 +00:00
|
|
|
iter->second.Destroy(false);
|
|
|
|
iter = textures.erase(iter);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
++iter;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-14 13:57:16 +00:00
|
|
|
TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, int height, int tex_format, int tlutaddr, int tlutfmt,bool UseNativeMips, int maxlevel)
|
2009-12-07 18:48:31 +00:00
|
|
|
{
|
|
|
|
if (address == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
|
|
|
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1; //TexelSizeInNibbles(format)*width*height/16;
|
|
|
|
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1; //TexelSizeInNibbles(format)*width*height/16;
|
2010-04-14 13:57:16 +00:00
|
|
|
int bsdepth = TexDecoder_GetTexelSizeInNibbles(tex_format);
|
2009-12-07 18:48:31 +00:00
|
|
|
int expandedWidth = (width + bsw) & (~bsw);
|
|
|
|
int expandedHeight = (height + bsh) & (~bsh);
|
|
|
|
|
2010-02-03 03:52:50 +00:00
|
|
|
u64 hash_value;
|
2009-12-07 18:48:31 +00:00
|
|
|
u32 texID = address;
|
2010-02-03 03:52:50 +00:00
|
|
|
u64 texHash;
|
|
|
|
u32 FullFormat = tex_format;
|
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
|
|
|
bool TextureIsDinamic = false;
|
2010-02-03 03:52:50 +00:00
|
|
|
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
|
|
|
u32 FullFormat = (tex_format | (tlutfmt << 16));
|
2009-12-07 18:48:31 +00:00
|
|
|
|
2009-12-22 06:47:42 +00:00
|
|
|
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
|
2009-12-07 18:48:31 +00:00
|
|
|
{
|
2010-02-26 22:14:29 +00:00
|
|
|
texHash = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
2009-12-07 18:48:31 +00:00
|
|
|
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
|
|
|
{
|
|
|
|
// WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up)
|
|
|
|
// tlut size can be up to 32768B (GX_TF_C14X2) but Safer == Slower.
|
|
|
|
// This trick (to change the texID depending on the TLUT addr) is a trick to get around
|
|
|
|
// an issue with metroid prime's fonts, where it has multiple sets of fonts on top of
|
|
|
|
// each other stored in a single texture, and uses the palette to make different characters
|
|
|
|
// visible or invisible. Thus, unless we want to recreate the textures for every drawn character,
|
|
|
|
// we must make sure that texture with different tluts get different IDs.
|
2010-02-26 22:14:29 +00:00
|
|
|
u64 tlutHash = TexDecoder_GetHash64(&texMem[tlutaddr], TexDecoder_GetPaletteSize(tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
First a bugfix:
fixed a misbehavior in the clear code that causes depth clear problems in reference hardware (Intel as example).
add 6 parameters to optimize Safe Texture Cache:
SafeTextureCacheColorSamples, SafeTextureCacheIndexedSamples, SafeTextureCacheTlutSamples:
this 3 parameters gives the number of samples taken to calculate the final hash value, less samples = more speed, more samples = more accuracy
if 0 is specified the hash is calculated using all the data in the texture.
SafeTextureCacheColorMaxSize, SafeTextureCacheIndexedMaxSize, SafeTextureCacheTlutMaxSize:
this parameters limits the amount of data used for the hash calculation, it could appear as redundant but in some games is better to make a full hash of the first bytes instead of some samples of all the texture.
color, indexed, tlut : define the texture type, full color data, indexed, and the tlut memory.
the parameters are available in the config , no GUI at this time, if the test are OK will add it to the GUI.
if someone needs it will give more examples on how to configure the values for specific games.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5116 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-02-23 21:52:12 +00:00
|
|
|
texHash ^= tlutHash;
|
2009-12-07 18:48:31 +00:00
|
|
|
if (g_ActiveConfig.bSafeTextureCache)
|
2010-02-10 15:55:24 +00:00
|
|
|
{
|
2010-02-26 22:14:29 +00:00
|
|
|
texID = texID ^ ((u32)(tlutHash & 0xFFFFFFFF)) ^ ((u32)((tlutHash >> 32) & 0xFFFFFFFF));
|
2010-02-10 15:55:24 +00:00
|
|
|
}
|
2010-02-08 23:23:04 +00:00
|
|
|
}
|
2010-02-03 03:52:50 +00:00
|
|
|
if (g_ActiveConfig.bSafeTextureCache)
|
|
|
|
hash_value = texHash;
|
2009-12-07 18:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool skip_texture_create = false;
|
|
|
|
TexCache::iterator iter = textures.find(texID);
|
|
|
|
|
|
|
|
if (iter != textures.end())
|
|
|
|
{
|
|
|
|
TCacheEntry &entry = iter->second;
|
|
|
|
|
|
|
|
if (!g_ActiveConfig.bSafeTextureCache)
|
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
|
|
|
{
|
2010-07-09 20:56:16 +00:00
|
|
|
if(entry.isRenderTarget || entry.isDinamic)
|
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
|
|
|
{
|
|
|
|
if(!g_ActiveConfig.bCopyEFBToTexture && g_ActiveConfig.bVerifyTextureModificationsByCPU)
|
|
|
|
{
|
|
|
|
hash_value = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
2010-07-09 20:56:16 +00:00
|
|
|
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
|
|
|
|
{
|
|
|
|
hash_value ^= TexDecoder_GetHash64(&texMem[tlutaddr], TexDecoder_GetPaletteSize(tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hash_value = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hash_value = ((u32 *)ptr)[0];
|
|
|
|
}
|
|
|
|
}
|
2010-07-09 20:56:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if(entry.isRenderTarget || entry.isDinamic)
|
|
|
|
{
|
|
|
|
if(g_ActiveConfig.bCopyEFBToTexture || !g_ActiveConfig.bVerifyTextureModificationsByCPU)
|
|
|
|
{
|
|
|
|
hash_value = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (((entry.isRenderTarget || entry.isDinamic) && hash_value == entry.hash && address == entry.addr)
|
2010-07-12 19:30:25 +00:00
|
|
|
|| ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt/* && entry.MipLevels == maxlevel*/))
|
2009-12-07 18:48:31 +00:00
|
|
|
{
|
|
|
|
entry.frameCount = frameCount;
|
2010-07-12 19:30:25 +00:00
|
|
|
entry.isDinamic = false;
|
2009-12-07 18:48:31 +00:00
|
|
|
D3D::SetTexture(stage, entry.texture);
|
|
|
|
return &entry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
// Let's reload the new texture data into the same texture,
|
2009-12-07 18:48:31 +00:00
|
|
|
// instead of destroying it and having to create a new one.
|
|
|
|
// Might speed up movie playback very, very slightly.
|
2010-07-09 20:56:16 +00:00
|
|
|
TextureIsDinamic = (entry.isRenderTarget || entry.isDinamic) && !g_ActiveConfig.bCopyEFBToTexture;
|
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
|
|
|
|
|
|
|
if (!entry.isRenderTarget &&
|
|
|
|
((!entry.isDinamic && width == entry.w && height==entry.h && FullFormat == entry.fmt /* && entry.MipLevels < maxlevel*/)
|
|
|
|
|| (entry.isDinamic && entry.w == width && entry.h == height)))
|
2009-12-07 18:48:31 +00:00
|
|
|
{
|
|
|
|
skip_texture_create = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
entry.Destroy(false);
|
|
|
|
textures.erase(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-22 06:47:42 +00:00
|
|
|
|
2010-01-21 19:31:48 +00:00
|
|
|
// Make an entry in the table
|
2009-12-22 06:47:42 +00:00
|
|
|
TCacheEntry& entry = textures[texID];
|
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
|
|
|
entry.isDinamic = TextureIsDinamic;
|
2009-12-22 06:47:42 +00:00
|
|
|
PC_TexFormat pcfmt = PC_TEX_FMT_NONE;
|
|
|
|
|
|
|
|
if (g_ActiveConfig.bHiresTextures)
|
|
|
|
{
|
2010-01-21 19:31:48 +00:00
|
|
|
// Load Custom textures
|
2009-12-22 06:47:42 +00:00
|
|
|
char texPathTemp[MAX_PATH];
|
|
|
|
int oldWidth = width;
|
|
|
|
int oldHeight = height;
|
|
|
|
|
|
|
|
sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, texHash, tex_format);
|
|
|
|
pcfmt = HiresTextures::GetHiresTex(texPathTemp, &width, &height, tex_format, temp);
|
|
|
|
|
|
|
|
if (pcfmt != PC_TEX_FMT_NONE)
|
|
|
|
{
|
|
|
|
expandedWidth = width;
|
|
|
|
expandedHeight = height;
|
|
|
|
entry.scaleX = (float) width / oldWidth;
|
|
|
|
entry.scaleY = (float) height / oldHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-21 19:31:48 +00:00
|
|
|
if (pcfmt == PC_TEX_FMT_NONE)
|
2009-12-22 06:47:42 +00:00
|
|
|
pcfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt);
|
2009-09-19 13:14:55 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
D3DFORMAT d3d_fmt;
|
2010-01-21 19:31:48 +00:00
|
|
|
bool swap_r_b = false;
|
2008-12-08 05:25:12 +00:00
|
|
|
switch (pcfmt) {
|
|
|
|
case PC_TEX_FMT_BGRA32:
|
2010-01-21 19:31:48 +00:00
|
|
|
d3d_fmt = D3DFMT_A8R8G8B8;
|
|
|
|
break;
|
2009-11-14 17:50:51 +00:00
|
|
|
case PC_TEX_FMT_RGBA32:
|
2008-12-08 05:25:12 +00:00
|
|
|
d3d_fmt = D3DFMT_A8R8G8B8;
|
2010-01-21 19:31:48 +00:00
|
|
|
swap_r_b = true;
|
2008-12-08 05:25:12 +00:00
|
|
|
break;
|
2009-02-12 22:32:33 +00:00
|
|
|
case PC_TEX_FMT_RGB565:
|
|
|
|
d3d_fmt = D3DFMT_R5G6B5;
|
|
|
|
break;
|
2009-05-13 02:06:02 +00:00
|
|
|
case PC_TEX_FMT_IA4_AS_IA8:
|
2009-09-02 18:55:36 +00:00
|
|
|
d3d_fmt = D3DFMT_A8L8;
|
2009-02-14 09:04:40 +00:00
|
|
|
break;
|
2009-02-12 13:54:08 +00:00
|
|
|
case PC_TEX_FMT_I8:
|
2009-08-31 06:35:43 +00:00
|
|
|
case PC_TEX_FMT_I4_AS_I8:
|
2009-02-16 23:01:37 +00:00
|
|
|
d3d_fmt = D3DFMT_A8P8; // A hack which means the format is a packed
|
|
|
|
// 8-bit intensity texture. It is unpacked
|
|
|
|
// to A8L8 in D3DTexture.cpp
|
2009-02-13 14:14:45 +00:00
|
|
|
break;
|
|
|
|
case PC_TEX_FMT_IA8:
|
2009-02-12 13:54:08 +00:00
|
|
|
d3d_fmt = D3DFMT_A8L8;
|
|
|
|
break;
|
2009-02-16 23:01:37 +00:00
|
|
|
case PC_TEX_FMT_DXT1:
|
|
|
|
d3d_fmt = D3DFMT_DXT1;
|
|
|
|
break;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-03-07 18:05:29 +00:00
|
|
|
|
2009-09-15 21:05:31 +00:00
|
|
|
entry.oldpixel = ((u32 *)ptr)[0];
|
2010-07-09 20:56:16 +00:00
|
|
|
if (g_ActiveConfig.bSafeTextureCache || entry.isDinamic)
|
2009-09-19 13:14:55 +00:00
|
|
|
entry.hash = hash_value;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
|
2010-07-09 20:56:16 +00:00
|
|
|
((u32 *)ptr)[0] = entry.hash;
|
2009-09-19 13:14:55 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
entry.addr = address;
|
2010-04-22 02:51:07 +00:00
|
|
|
entry.size_in_bytes = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format);
|
2009-03-07 18:05:29 +00:00
|
|
|
entry.isRenderTarget = false;
|
2010-04-14 13:57:16 +00:00
|
|
|
bool isPow2 = !((width & (width - 1)) || (height & (height - 1)));
|
|
|
|
entry.isNonPow2 = false;
|
|
|
|
int TexLevels = (width > height)?width:height;
|
2010-05-04 14:43:30 +00:00
|
|
|
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : ((isPow2)? 0 : 1);
|
2010-06-06 14:44:35 +00:00
|
|
|
if(TexLevels > (maxlevel + 1) && maxlevel > 0)
|
|
|
|
TexLevels = (maxlevel + 1);
|
2010-06-05 00:01:18 +00:00
|
|
|
entry.MipLevels = maxlevel;
|
2010-06-05 01:38:22 +00:00
|
|
|
if (!skip_texture_create)
|
|
|
|
{
|
2010-05-02 14:05:14 +00:00
|
|
|
entry.texture = D3D::CreateTexture2D((BYTE*)temp, width, height, expandedWidth, d3d_fmt, swap_r_b, TexLevels);
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
|
|
|
else
|
2010-04-14 13:57:16 +00:00
|
|
|
{
|
2010-04-22 02:51:07 +00:00
|
|
|
D3D::ReplaceTexture2D(entry.texture, (BYTE*)temp, width, height, expandedWidth, d3d_fmt, swap_r_b, 0);
|
2009-09-19 13:14:55 +00:00
|
|
|
}
|
2010-04-14 13:57:16 +00:00
|
|
|
if(TexLevels > 1 && pcfmt != PC_TEX_FMT_NONE)
|
|
|
|
{
|
|
|
|
int level = 1;
|
|
|
|
int mipWidth = (width + 1) >> 1;
|
|
|
|
int mipHeight = (height + 1) >> 1;
|
|
|
|
ptr += entry.size_in_bytes;
|
|
|
|
while((mipHeight || mipWidth) && (level < TexLevels))
|
|
|
|
{
|
|
|
|
u32 currentWidth = (mipWidth > 0)? mipWidth : 1;
|
|
|
|
u32 currentHeight = (mipHeight > 0)? mipHeight : 1;
|
|
|
|
expandedWidth = (currentWidth + bsw) & (~bsw);
|
|
|
|
expandedHeight = (currentHeight + bsh) & (~bsh);
|
|
|
|
TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt);
|
|
|
|
D3D::ReplaceTexture2D(entry.texture, (BYTE*)temp, currentWidth, currentHeight, expandedWidth, d3d_fmt, swap_r_b,level);
|
|
|
|
u32 size = (max(mipWidth, bsw) * max(mipHeight, bsh) * bsdepth) >> 1;
|
|
|
|
ptr += size;
|
|
|
|
mipWidth >>= 1;
|
|
|
|
mipHeight >>= 1;
|
|
|
|
level++;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
entry.frameCount = frameCount;
|
2009-03-07 18:05:29 +00:00
|
|
|
entry.w = width;
|
|
|
|
entry.h = height;
|
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
|
|
|
entry.Scaledw = width;
|
|
|
|
entry.Scaledh = height;
|
2010-02-03 03:52:50 +00:00
|
|
|
entry.fmt = FullFormat;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 08:21:35 +00:00
|
|
|
if (g_ActiveConfig.bDumpTextures)
|
2009-09-19 13:14:55 +00:00
|
|
|
{
|
|
|
|
// dump texture to file
|
2008-12-08 05:25:12 +00:00
|
|
|
char szTemp[MAX_PATH];
|
2009-09-01 11:14:58 +00:00
|
|
|
char szDir[MAX_PATH];
|
2009-09-13 08:54:46 +00:00
|
|
|
const char* uniqueId = globals->unique_id;
|
2009-09-01 11:14:58 +00:00
|
|
|
bool bCheckedDumpDir = false;
|
2009-12-22 06:47:42 +00:00
|
|
|
|
2010-02-02 21:56:29 +00:00
|
|
|
sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), uniqueId);
|
2009-12-22 06:47:42 +00:00
|
|
|
|
2009-09-15 21:05:31 +00:00
|
|
|
if (!bCheckedDumpDir)
|
2009-09-01 11:14:58 +00:00
|
|
|
{
|
|
|
|
if (!File::Exists(szDir) || !File::IsDirectory(szDir))
|
|
|
|
File::CreateDir(szDir);
|
|
|
|
|
|
|
|
bCheckedDumpDir = true;
|
|
|
|
}
|
2009-12-22 06:47:42 +00:00
|
|
|
|
2010-01-21 10:23:13 +00:00
|
|
|
sprintf(szTemp, "%s/%s_%08x_%i.png", szDir, uniqueId, texHash, tex_format);
|
2009-12-22 06:47:42 +00:00
|
|
|
|
2009-09-01 11:14:58 +00:00
|
|
|
if (!File::Exists(szTemp))
|
2010-01-21 10:23:13 +00:00
|
|
|
D3DXSaveTextureToFileA(szTemp,D3DXIFF_PNG,entry.texture,0);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
INCSTAT(stats.numTexturesCreated);
|
|
|
|
SETSTAT(stats.numTexturesAlive, (int)textures.size());
|
|
|
|
|
|
|
|
//Set the texture!
|
2009-09-13 08:21:35 +00:00
|
|
|
D3D::SetTexture(stage, entry.texture);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-18 03:12:32 +00:00
|
|
|
DEBUGGER_PAUSE_LOG_AT(NEXT_NEW_TEXTURE,true,{printf("A new texture (%d x %d) is loaded", width, height);});
|
2009-03-07 18:05:29 +00:00
|
|
|
return &entry;
|
2009-12-09 13:51:28 +00:00
|
|
|
}
|
2010-06-16 10:12:57 +00:00
|
|
|
|
2009-09-04 06:09:21 +00:00
|
|
|
void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-09-03 21:56:08 +00:00
|
|
|
int efb_w = source_rect.GetWidth();
|
|
|
|
int efb_h = source_rect.GetHeight();
|
|
|
|
|
2009-09-04 06:09:21 +00:00
|
|
|
int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
|
|
|
|
int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
|
2010-03-14 18:57:50 +00:00
|
|
|
//compensate the texture grow if supersampling is enabled to conserve memory usage
|
2010-06-09 15:33:01 +00:00
|
|
|
float SuperSampleCompensation = g_ActiveConfig.iMultisampleMode + 1;
|
2010-06-05 00:01:18 +00:00
|
|
|
SuperSampleCompensation = 1.0f / SuperSampleCompensation;
|
2010-05-19 03:15:36 +00:00
|
|
|
float xScale = Renderer::GetTargetScaleX();
|
|
|
|
float yScale = Renderer::GetTargetScaleY();
|
2010-06-05 01:38:22 +00:00
|
|
|
|
2010-05-19 03:15:36 +00:00
|
|
|
int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled)?((int)(xScale * SuperSampleCompensation * tex_w)):tex_w;
|
|
|
|
int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled)?((int)(yScale * SuperSampleCompensation * tex_h)):tex_h;
|
2010-02-08 23:23:04 +00:00
|
|
|
|
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
|
|
|
TexCache::iterator iter;
|
2010-03-14 18:57:50 +00:00
|
|
|
LPDIRECT3DTEXTURE9 tex = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
iter = textures.find(address);
|
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
|
|
|
bool TextureIsDinamic = false;
|
2008-12-08 05:25:12 +00:00
|
|
|
if (iter != textures.end())
|
|
|
|
{
|
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
|
|
|
if ((iter->second.isRenderTarget && iter->second.Scaledw == Scaledtex_w && iter->second.Scaledh == Scaledtex_h)
|
|
|
|
|| (iter->second.isDinamic && iter->second.w == tex_w && iter->second.h == tex_h))
|
2010-06-05 01:38:22 +00:00
|
|
|
{
|
2009-11-08 20:35:11 +00:00
|
|
|
tex = iter->second.texture;
|
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
|
|
|
TextureIsDinamic = iter->second.isDinamic;
|
2009-11-08 20:35:11 +00:00
|
|
|
iter->second.frameCount = frameCount;
|
|
|
|
}
|
|
|
|
else
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-09-03 21:56:08 +00:00
|
|
|
// Remove it and recreate it as a render target
|
ok big changes here:
in videocommon little fix for the alpha test values, return to the original values as they are more accurate.
in D3D:
huge change in state management, now all the state management is centralized and redundant state changes are eliminated.
Fixed the overlapped viewport error in non ati cards:
the error was caused by this: when a viewport is defined larger than the current rendertarget, an error is thrown and the last valid viewport is used, this is the reference behavior, in ati cards if a larger viewport is defined, no eror is returned, the rendering is valid and is rendered using the projection defined by the viewport but limited to the rendertarget are, exactly like opengl or the GC hardware.
to solve this in reference drivers defined a large rendertarget (2x the size of the original) and proceed to render in a centered quad insithe the larger rendertarget, in this way larger viewports always falls inside a valid rendertarget size, the drawback of this is the waste of resources. it can be dynamized, depending or games or changed at runtime when a oversized viewport is detected, but i live that to future commits.
please test this and let me know the results.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4841 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-15 15:52:08 +00:00
|
|
|
if(iter->second.texture)
|
|
|
|
iter->second.texture->Release();
|
2009-09-03 21:56:08 +00:00
|
|
|
iter->second.texture = 0;
|
|
|
|
textures.erase(iter);
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
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
|
|
|
if(TextureIsDinamic)
|
|
|
|
{
|
|
|
|
Scaledtex_w = tex_w;
|
|
|
|
Scaledtex_h = tex_h;
|
|
|
|
}
|
2010-03-14 18:57:50 +00:00
|
|
|
if(!tex)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
TCacheEntry entry;
|
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
|
|
|
entry.addr = address;
|
2010-07-09 20:56:16 +00:00
|
|
|
entry.isRenderTarget = true;
|
2008-12-08 05:25:12 +00:00
|
|
|
entry.hash = 0;
|
|
|
|
entry.frameCount = frameCount;
|
2009-09-03 21:56:08 +00:00
|
|
|
entry.w = tex_w;
|
|
|
|
entry.h = tex_h;
|
2009-12-15 01:40:54 +00:00
|
|
|
entry.Scaledw = Scaledtex_w;
|
|
|
|
entry.Scaledh = Scaledtex_h;
|
2009-11-08 20:35:11 +00:00
|
|
|
entry.fmt = copyfmt;
|
ok big changes here:
in videocommon little fix for the alpha test values, return to the original values as they are more accurate.
in D3D:
huge change in state management, now all the state management is centralized and redundant state changes are eliminated.
Fixed the overlapped viewport error in non ati cards:
the error was caused by this: when a viewport is defined larger than the current rendertarget, an error is thrown and the last valid viewport is used, this is the reference behavior, in ati cards if a larger viewport is defined, no eror is returned, the rendering is valid and is rendered using the projection defined by the viewport but limited to the rendertarget are, exactly like opengl or the GC hardware.
to solve this in reference drivers defined a large rendertarget (2x the size of the original) and proceed to render in a centered quad insithe the larger rendertarget, in this way larger viewports always falls inside a valid rendertarget size, the drawback of this is the waste of resources. it can be dynamized, depending or games or changed at runtime when a oversized viewport is detected, but i live that to future commits.
please test this and let me know the results.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4841 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-15 15:52:08 +00:00
|
|
|
entry.isNonPow2 = true;
|
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
|
|
|
entry.isDinamic = false;
|
2009-12-15 01:40:54 +00:00
|
|
|
D3D::dev->CreateTexture(Scaledtex_w, Scaledtex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0);
|
2008-12-08 05:25:12 +00:00
|
|
|
textures[address] = entry;
|
|
|
|
tex = entry.texture;
|
|
|
|
}
|
2009-09-02 18:55:36 +00:00
|
|
|
|
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
|
|
|
// Make sure to resolve anything we need to read from.
|
|
|
|
LPDIRECT3DTEXTURE9 read_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source_rect) : FBManager.GetEFBColorTexture(source_rect);
|
|
|
|
|
|
|
|
// We have to run a pixel shader, for color conversion.
|
|
|
|
Renderer::ResetAPIState(); // reset any game specific settings
|
|
|
|
if(!TextureIsDinamic || g_ActiveConfig.bCopyEFBToTexture)
|
2009-11-08 20:35:11 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
float colmat[16]= {0.0f};
|
|
|
|
float fConstAdd[4] = {0.0f};
|
|
|
|
|
|
|
|
if (bFromZBuffer)
|
2009-11-08 20:35:11 +00:00
|
|
|
{
|
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
|
|
|
switch(copyfmt)
|
|
|
|
{
|
|
|
|
case 0: // Z4
|
|
|
|
case 1: // Z8
|
|
|
|
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1.0f;
|
|
|
|
break;
|
|
|
|
case 3: // Z16 //?
|
|
|
|
colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f;
|
|
|
|
case 11: // Z16 (reverse order)
|
|
|
|
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1.0f;
|
|
|
|
break;
|
|
|
|
case 6: // Z24X8
|
|
|
|
colmat[0] = colmat[5] = colmat[10] = 1.0f;
|
|
|
|
break;
|
|
|
|
case 9: // Z8M
|
|
|
|
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1.0f;
|
|
|
|
break;
|
|
|
|
case 10: // Z8L
|
|
|
|
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1.0f;
|
|
|
|
break;
|
|
|
|
case 12: // Z16L
|
|
|
|
colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1.0f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x", copyfmt);
|
|
|
|
colmat[2] = colmat[5] = colmat[8] = 1.0f;
|
|
|
|
break;
|
|
|
|
}
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
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
|
|
|
else if (bIsIntensityFmt)
|
2009-11-08 20:35:11 +00:00
|
|
|
{
|
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
|
|
|
fConstAdd[0] = fConstAdd[1] = fConstAdd[2] = 16.0f/255.0f;
|
|
|
|
switch (copyfmt)
|
|
|
|
{
|
|
|
|
case 0: // I4
|
|
|
|
case 1: // I8
|
|
|
|
case 2: // IA4
|
|
|
|
case 3: // IA8
|
|
|
|
colmat[0] = 0.257f; colmat[1] = 0.504f; colmat[2] = 0.098f;
|
|
|
|
colmat[4] = 0.257f; colmat[5] = 0.504f; colmat[6] = 0.098f;
|
|
|
|
colmat[8] = 0.257f; colmat[9] = 0.504f; colmat[10] = 0.098f;
|
|
|
|
|
|
|
|
if (copyfmt < 2)
|
|
|
|
{
|
|
|
|
fConstAdd[3] = 16.0f / 255.0f;
|
|
|
|
colmat[12] = 0.257f; colmat[13] = 0.504f; colmat[14] = 0.098f;
|
|
|
|
}
|
|
|
|
else// alpha
|
|
|
|
colmat[15] = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x", copyfmt);
|
|
|
|
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
|
|
|
|
break;
|
|
|
|
}
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
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
|
|
|
else
|
2009-11-08 20:35:11 +00:00
|
|
|
{
|
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
|
|
|
switch (copyfmt)
|
|
|
|
{
|
|
|
|
case 0: // R4
|
|
|
|
case 8: // R8
|
|
|
|
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
|
|
|
|
break;
|
|
|
|
case 2: // RA4
|
|
|
|
case 3: // RA8
|
|
|
|
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: // A8
|
|
|
|
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
|
|
|
|
break;
|
|
|
|
case 9: // G8
|
|
|
|
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
|
|
|
|
break;
|
|
|
|
case 10: // B8
|
|
|
|
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
|
|
|
|
break;
|
|
|
|
case 11: // RG8
|
|
|
|
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
|
|
|
|
break;
|
|
|
|
case 12: // GB8
|
|
|
|
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // RGB565
|
|
|
|
colmat[0] = colmat[5] = colmat[10] = 1;
|
|
|
|
fConstAdd[3] = 1; // set alpha to 1
|
|
|
|
break;
|
|
|
|
case 5: // RGB5A3
|
|
|
|
case 6: // RGBA8
|
|
|
|
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x", copyfmt);
|
|
|
|
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
|
|
|
|
break;
|
|
|
|
}
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
|
|
|
tex->GetSurfaceLevel(0,&Rendersurf);
|
|
|
|
D3D::dev->SetDepthStencilSurface(NULL);
|
|
|
|
D3D::dev->SetRenderTarget(0, Rendersurf);
|
|
|
|
|
|
|
|
D3DVIEWPORT9 vp;
|
|
|
|
|
|
|
|
// Stretch picture with increased internal resolution
|
|
|
|
vp.X = 0;
|
|
|
|
vp.Y = 0;
|
|
|
|
vp.Width = Scaledtex_w;
|
|
|
|
vp.Height = Scaledtex_h;
|
|
|
|
vp.MinZ = 0.0f;
|
|
|
|
vp.MaxZ = 1.0f;
|
|
|
|
D3D::dev->SetViewport(&vp);
|
|
|
|
RECT destrect;
|
|
|
|
destrect.bottom = Scaledtex_h;
|
|
|
|
destrect.left = 0;
|
|
|
|
destrect.right = Scaledtex_w;
|
|
|
|
destrect.top = 0;
|
|
|
|
|
|
|
|
|
|
|
|
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
|
|
|
|
TargetRectangle targetSource = Renderer::ConvertEFBRectangle(source_rect);
|
|
|
|
RECT sourcerect;
|
|
|
|
sourcerect.bottom = targetSource.bottom;
|
|
|
|
sourcerect.left = targetSource.left;
|
|
|
|
sourcerect.right = targetSource.right;
|
|
|
|
sourcerect.top = targetSource.top;
|
|
|
|
|
|
|
|
|
|
|
|
if(bFromZBuffer)
|
|
|
|
{
|
|
|
|
if(bScaleByHalf || g_ActiveConfig.iMultisampleMode)
|
|
|
|
{
|
|
|
|
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
|
|
|
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
|
|
|
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
|
|
|
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
D3DFORMAT bformat = FBManager.GetEFBDepthRTSurfaceFormat();
|
|
|
|
int SSAAMode = g_ActiveConfig.iMultisampleMode;
|
|
|
|
D3D::drawShadedTexQuad(
|
|
|
|
read_texture,
|
|
|
|
&sourcerect,
|
|
|
|
Renderer::GetFullTargetWidth() ,
|
|
|
|
Renderer::GetFullTargetHeight(),
|
|
|
|
Scaledtex_w,
|
|
|
|
Scaledtex_h,
|
|
|
|
((bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8) && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(SSAAMode): PixelShaderCache::GetColorMatrixProgram(SSAAMode),
|
|
|
|
VertexShaderCache::GetSimpleVertexShader(SSAAMode));
|
|
|
|
Rendersurf->Release();
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
2009-11-08 20:35:11 +00:00
|
|
|
|
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
|
|
|
if(!g_ActiveConfig.bCopyEFBToTexture)
|
2009-12-03 20:09:15 +00:00
|
|
|
{
|
2010-07-09 20:56:16 +00:00
|
|
|
textures[address].hash = TextureConverter::EncodeToRamFromTexture(
|
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
|
|
|
address,
|
|
|
|
read_texture,
|
|
|
|
Renderer::GetFullTargetWidth(),
|
|
|
|
Renderer::GetFullTargetHeight(),
|
|
|
|
xScale,
|
|
|
|
yScale,
|
|
|
|
(float)((Renderer::GetFullTargetWidth() - Renderer::GetTargetWidth()) / 2),
|
|
|
|
(float)((Renderer::GetFullTargetHeight() - Renderer::GetTargetHeight()) / 2) ,
|
|
|
|
bFromZBuffer,
|
|
|
|
bIsIntensityFmt,
|
|
|
|
copyfmt,
|
|
|
|
bScaleByHalf,
|
|
|
|
source_rect);
|
2009-12-03 20:09:15 +00:00
|
|
|
}
|
2010-02-03 03:52:50 +00:00
|
|
|
|
2009-12-02 04:17:18 +00:00
|
|
|
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
2009-12-03 20:09:15 +00:00
|
|
|
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
|
2010-02-03 03:52:50 +00:00
|
|
|
D3D::SetTexture(0,NULL);
|
2010-03-14 18:57:50 +00:00
|
|
|
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
2010-06-05 01:38:22 +00:00
|
|
|
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
|
|
|
Renderer::RestoreAPIState();
|
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
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2010-06-05 01:38:22 +00:00
|
|
|
|