Check the hashes of efb copies before applying them as partial texture updates
This commit is contained in:
parent
018a05b77e
commit
ff709247e2
|
@ -246,60 +246,69 @@ TextureCache::TCacheEntryBase* TextureCache::DoPartialTextureUpdates(TexCache::i
|
||||||
&& entry->frameCount == FRAMECOUNT_INVALID
|
&& entry->frameCount == FRAMECOUNT_INVALID
|
||||||
&& entry->memory_stride == numBlocksX * block_size)
|
&& entry->memory_stride == numBlocksX * block_size)
|
||||||
{
|
{
|
||||||
u32 block_offset = (entry->addr - entry_to_update->addr) / block_size;
|
if (entry->hash == entry->CalculateHash())
|
||||||
u32 block_x = block_offset % numBlocksX;
|
|
||||||
u32 block_y = block_offset / numBlocksX;
|
|
||||||
|
|
||||||
u32 x = block_x * block_width;
|
|
||||||
u32 y = block_y * block_height;
|
|
||||||
MathUtil::Rectangle<int> srcrect, dstrect;
|
|
||||||
srcrect.left = 0;
|
|
||||||
srcrect.top = 0;
|
|
||||||
dstrect.left = 0;
|
|
||||||
dstrect.top = 0;
|
|
||||||
if (entry_need_scaling)
|
|
||||||
{
|
{
|
||||||
entry_need_scaling = false;
|
u32 block_offset = (entry->addr - entry_to_update->addr) / block_size;
|
||||||
u32 w = entry_to_update->native_width * entry->config.width / entry->native_width;
|
u32 block_x = block_offset % numBlocksX;
|
||||||
u32 h = entry_to_update->native_height * entry->config.height / entry->native_height;
|
u32 block_y = block_offset / numBlocksX;
|
||||||
u32 max = g_renderer->GetMaxTextureSize();
|
|
||||||
if (max < w || max < h)
|
u32 x = block_x * block_width;
|
||||||
|
u32 y = block_y * block_height;
|
||||||
|
MathUtil::Rectangle<int> srcrect, dstrect;
|
||||||
|
srcrect.left = 0;
|
||||||
|
srcrect.top = 0;
|
||||||
|
dstrect.left = 0;
|
||||||
|
dstrect.top = 0;
|
||||||
|
if (entry_need_scaling)
|
||||||
{
|
{
|
||||||
iter++;
|
entry_need_scaling = false;
|
||||||
continue;
|
u32 w = entry_to_update->native_width * entry->config.width / entry->native_width;
|
||||||
}
|
u32 h = entry_to_update->native_height * entry->config.height / entry->native_height;
|
||||||
if (entry_to_update->config.width != w || entry_to_update->config.height != h)
|
u32 max = g_renderer->GetMaxTextureSize();
|
||||||
{
|
if (max < w || max < h)
|
||||||
TextureCache::TCacheEntryConfig newconfig;
|
{
|
||||||
newconfig.width = w;
|
iter++;
|
||||||
newconfig.height = h;
|
continue;
|
||||||
newconfig.rendertarget = true;
|
}
|
||||||
TCacheEntryBase* newentry = AllocateTexture(newconfig);
|
if (entry_to_update->config.width != w || entry_to_update->config.height != h)
|
||||||
newentry->SetGeneralParameters(entry_to_update->addr, entry_to_update->size_in_bytes, entry_to_update->format);
|
{
|
||||||
newentry->SetDimensions(entry_to_update->native_width, entry_to_update->native_height, 1);
|
TextureCache::TCacheEntryConfig newconfig;
|
||||||
newentry->SetHashes(entry_to_update->base_hash, entry_to_update->hash);
|
newconfig.width = w;
|
||||||
newentry->frameCount = frameCount;
|
newconfig.height = h;
|
||||||
newentry->is_efb_copy = false;
|
newconfig.rendertarget = true;
|
||||||
srcrect.right = entry_to_update->config.width;
|
TCacheEntryBase* newentry = AllocateTexture(newconfig);
|
||||||
srcrect.bottom = entry_to_update->config.height;
|
newentry->SetGeneralParameters(entry_to_update->addr, entry_to_update->size_in_bytes, entry_to_update->format);
|
||||||
dstrect.right = w;
|
newentry->SetDimensions(entry_to_update->native_width, entry_to_update->native_height, 1);
|
||||||
dstrect.bottom = h;
|
newentry->SetHashes(entry_to_update->base_hash, entry_to_update->hash);
|
||||||
newentry->CopyRectangleFromTexture(entry_to_update, srcrect, dstrect);
|
newentry->frameCount = frameCount;
|
||||||
entry_to_update = newentry;
|
newentry->is_efb_copy = false;
|
||||||
u64 key = iter_t->first;
|
srcrect.right = entry_to_update->config.width;
|
||||||
iter_t = FreeTexture(iter_t);
|
srcrect.bottom = entry_to_update->config.height;
|
||||||
textures_by_address.emplace(key, entry_to_update);
|
dstrect.right = w;
|
||||||
|
dstrect.bottom = h;
|
||||||
|
newentry->CopyRectangleFromTexture(entry_to_update, srcrect, dstrect);
|
||||||
|
entry_to_update = newentry;
|
||||||
|
u64 key = iter_t->first;
|
||||||
|
iter_t = FreeTexture(iter_t);
|
||||||
|
textures_by_address.emplace(key, entry_to_update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
srcrect.right = entry->config.width;
|
||||||
|
srcrect.bottom = entry->config.height;
|
||||||
|
dstrect.left = x * entry_to_update->config.width / entry_to_update->native_width;
|
||||||
|
dstrect.top = y * entry_to_update->config.height / entry_to_update->native_height;
|
||||||
|
dstrect.right = (x + entry->native_width) * entry_to_update->config.width / entry_to_update->native_width;
|
||||||
|
dstrect.bottom = (y + entry->native_height) * entry_to_update->config.height / entry_to_update->native_height;
|
||||||
|
entry_to_update->CopyRectangleFromTexture(entry, srcrect, dstrect);
|
||||||
|
// Mark the texture update as used, so it isn't applied more than once
|
||||||
|
entry->frameCount = frameCount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the hash does not match, this EFB copy will not be used for anything, so remove it
|
||||||
|
iter = FreeTexture(iter);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
srcrect.right = entry->config.width;
|
|
||||||
srcrect.bottom = entry->config.height;
|
|
||||||
dstrect.left = x * entry_to_update->config.width / entry_to_update->native_width;
|
|
||||||
dstrect.top = y * entry_to_update->config.height / entry_to_update->native_height;
|
|
||||||
dstrect.right = (x + entry->native_width) * entry_to_update->config.width / entry_to_update->native_width;
|
|
||||||
dstrect.bottom = (y + entry->native_height) * entry_to_update->config.height / entry_to_update->native_height;
|
|
||||||
entry_to_update->CopyRectangleFromTexture(entry, srcrect, dstrect);
|
|
||||||
// Mark the texture update as used, so it isn't applied more than once
|
|
||||||
entry->frameCount = frameCount;
|
|
||||||
}
|
}
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue