D3D various: "Safe texture cache" option, texture replace instead of destroy/create when possible, a commented out "optimization" that didn't speed things up (use DrawPrimitive instead of DrawIndexedPrimitive when possible), reduce code duplication in Flush(), don't periodically clean out the shader caches since it's not really beneficial - shaders are cheap to keep. some code cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4302 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-09-19 13:14:55 +00:00
parent dae1a68bfc
commit 7a8f6bdd6d
17 changed files with 259 additions and 170 deletions

View File

@ -222,6 +222,7 @@ FRAGMENTSHADER* PixelShaderCache::GetShader(bool dstAlphaEnable)
void PixelShaderCache::ProgressiveCleanup()
{
/*
PSCache::iterator iter = pshaders.begin();
while (iter != pshaders.end()) {
PSCacheEntry &entry = iter->second;
@ -237,6 +238,7 @@ void PixelShaderCache::ProgressiveCleanup()
iter++;
}
SETSTAT(stats.numPixelShadersAlive, (int)pshaders.size());
*/
}
bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)

View File

@ -148,7 +148,7 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown)
return;
glDeleteTextures(1, &texture);
if (!isRenderTarget && !shutdown && !g_ActiveConfig.bSafeTextureCache) {
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset * 4);
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr);
if (ptr && *ptr == hash)
*ptr = oldpixel;
}
@ -183,12 +183,6 @@ void TextureMngr::Shutdown()
temp = NULL;
}
#ifdef _WIN32
#define ERASE_THROUGH_ITERATOR(container, iterator) iterator = container.erase(iterator)
#else
#define ERASE_THROUGH_ITERATOR(container, iterator) container.erase(iterator++)
#endif
void TextureMngr::ProgressiveCleanup()
{
TexCache::iterator iter = textures.begin();
@ -210,7 +204,8 @@ void TextureMngr::ProgressiveCleanup()
}
}
void TextureMngr::InvalidateRange(u32 start_address, u32 size) {
void TextureMngr::InvalidateRange(u32 start_address, u32 size)
{
TexCache::iterator iter = textures.begin();
while (iter != textures.end())
{
@ -291,11 +286,12 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
bool skip_texture_create = false;
TexCache::iterator iter = textures.find(texID);
if (iter != textures.end()) {
if (iter != textures.end())
{
TCacheEntry &entry = iter->second;
if (!g_ActiveConfig.bSafeTextureCache)
hash_value = ((u32 *)ptr)[entry.hashoffset];
hash_value = ((u32 *)ptr)[0];
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash)))
{
@ -355,20 +351,15 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
if (dfmt == PC_TEX_FMT_NONE)
dfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt);
entry.hashoffset = 0;
//entry.paletteHash = hashseed;
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
entry.oldpixel = ((u32 *)ptr)[0];
if (g_ActiveConfig.bSafeTextureCache)
entry.hash = hash_value;
else
{
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[entry.hashoffset] = entry.hash;
((u32 *)ptr)[0] = entry.hash;
}
//DebugLog("%c addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
// , address, tex_format, entry.hash, width, height);
entry.addr = address;
entry.size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, tex_format);
@ -511,7 +502,6 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
TCacheEntry& entry = textures[address];
entry.hash = 0;
entry.hashoffset = 0;
entry.frameCount = frameCount;
int w = (abs(source_rect.GetWidth()) >> bScaleByHalf);

View File

@ -36,7 +36,6 @@ public:
u32 size_in_bytes;
u32 hash;
u32 paletteHash;
u32 hashoffset;
u32 oldpixel; // used for simple cleanup
TexMode0 mode; // current filter and clamp modes that texture is set to

View File

@ -182,6 +182,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
void VertexShaderCache::ProgressiveCleanup()
{
/*
VSCache::iterator iter = vshaders.begin();
while (iter != vshaders.end()) {
VSCacheEntry &entry = iter->second;
@ -199,6 +200,7 @@ void VertexShaderCache::ProgressiveCleanup()
}
SETSTAT(stats.numVertexShadersAlive, vshaders.size());
*/
}
bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrprogram)