Video Common: Avoid 'presenting' duplicate frames by detecting when swap

hasn't changed since the last frame
This commit is contained in:
iwubcode 2017-08-20 14:24:37 -05:00
parent c58010404d
commit e6d85b0915
4 changed files with 6 additions and 3 deletions

View file

@ -639,11 +639,10 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const
auto* xfb_entry = g_texture_cache->GetTexture(xfbAddr, fbWidth, fbHeight, TextureFormat::XFB,
force_safe_texture_cache_hash);
if (xfb_entry)
if (xfb_entry && xfb_entry->id != m_last_xfb_id)
{
// TODO, check if xfb_entry is a duplicate of the previous frame and skip SwapImpl
m_last_xfb_texture = xfb_entry->texture.get();
m_last_xfb_id = xfb_entry->id;
// TODO: merge more generic parts into VideoCommon
g_renderer->SwapImpl(xfb_entry->texture.get(), rc, ticks, xfb_entry->gamma);

View file

@ -207,6 +207,7 @@ private:
} m_frame_dump_config;
AbstractTexture * m_last_xfb_texture;
u64 m_last_xfb_id = 0;
// Note: Only used for auto-ir
u32 m_last_xfb_width = MAX_XFB_WIDTH;

View file

@ -1611,6 +1611,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::AllocateCacheEntry(const Textur
}
TCacheEntry* cacheEntry = new TCacheEntry(std::move(texture));
cacheEntry->textures_by_hash_iter = textures_by_hash.end();
cacheEntry->id = last_entry_id++;
return cacheEntry;
}

View file

@ -89,6 +89,7 @@ public:
bool is_xfb_copy = false;
float y_scale = 1.0f;
float gamma = 1.0f;
u64 id;
unsigned int native_width,
native_height; // Texture dimensions from the GameCube's point of view
@ -268,6 +269,7 @@ private:
TexAddrCache textures_by_address;
TexHashCache textures_by_hash;
TexPool texture_pool;
u64 last_entry_id = 0;
// Backup configuration values
struct BackupConfig