Updated with a less aggressive optimisation to EFB copy to RAM. The destination texture now does not get invalidated if its hash is found in the texture cache. Fixes Metroid Prime 3.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6353 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
skidau 2010-11-07 04:28:33 +00:00
parent 8775abacc6
commit 6666b400a3
3 changed files with 16 additions and 18 deletions

View File

@ -137,9 +137,7 @@ void TextureCache::MakeRangeDynamic(u32 start_address, u32 size)
bool TextureCache::Find(u32 start_address, u64 hash)
{
TexCache::iterator
iter = textures.lower_bound(start_address),
tcend = textures.upper_bound(start_address);
TexCache::iterator iter = textures.lower_bound(start_address);
if (iter->second->hash == hash)
return true;

View File

@ -271,7 +271,7 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
// Draw...
D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,dstWidth,dstHeight,shader,VertexShaderCache::GetSimpleVertexShader(0));
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
// .. and then readback the results.
// .. and then read back the results.
// TODO: make this less slow.
D3DLOCKED_RECT drect;
@ -406,12 +406,6 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture,u32 Sou
int size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, format);
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
@ -444,6 +438,12 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture,u32 Sou
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0);
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
TextureCache::MakeRangeDynamic(address,size_in_bytes);
return hash;
}

View File

@ -214,7 +214,7 @@ void EncodeToRamUsingShader(FRAGMENTSHADER& shader, GLuint srcTexture, const Tar
glEnd();
GL_REPORT_ERRORD();
// .. and then readback the results.
// .. and then read back the results.
// TODO: make this less slow.
int writeStride = bpmem.copyMipMapStrideChannels * 32;
@ -345,12 +345,6 @@ u64 EncodeToRamFromTexture(u32 address,GLuint source_texture,float MValueX,float
int size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, format);
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
@ -380,6 +374,12 @@ u64 EncodeToRamFromTexture(u32 address,GLuint source_texture,float MValueX,float
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0 && !bFromZBuffer);
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
TextureCache::MakeRangeDynamic(address,size_in_bytes);
return hash;
}
@ -411,7 +411,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
Renderer::ResetAPIState(); // reset any game specific settings
// swich to texture converter frame buffer
// switch to texture converter frame buffer
// attach destTexture as color destination
g_framebufferManager.SetFramebuffer(s_texConvFrameBuffer);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, destTexture);