Merge pull request #11280 from Pokechu22/efb-cache-cleanup

VideoCommon/FramebufferManager: Further EFB cache cleanup
This commit is contained in:
Admiral H. Curtiss 2022-11-16 02:22:53 +01:00 committed by GitHub
commit 99a918d884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 10 deletions

View File

@ -386,19 +386,20 @@ bool FramebufferManager::IsEFBCacheTilePresent(bool depth, u32 x, u32 y, u32* ti
}
else
{
*tile_index =
((y / m_efb_cache_tile_size) * m_efb_cache_tiles_wide) + (x / m_efb_cache_tile_size);
const u32 tile_x = x / m_efb_cache_tile_size;
const u32 tile_y = y / m_efb_cache_tile_size;
*tile_index = (tile_y * m_efb_cache_tile_row_stride) + tile_x;
}
return data.tiles[*tile_index].present;
}
MathUtil::Rectangle<int> FramebufferManager::GetEFBCacheTileRect(u32 tile_index) const
{
if (m_efb_cache_tile_size == 0)
if (!IsUsingTiledEFBCache())
return MathUtil::Rectangle<int>(0, 0, EFB_WIDTH, EFB_HEIGHT);
const u32 tile_y = tile_index / m_efb_cache_tiles_wide;
const u32 tile_x = tile_index % m_efb_cache_tiles_wide;
const u32 tile_y = tile_index / m_efb_cache_tile_row_stride;
const u32 tile_x = tile_index % m_efb_cache_tile_row_stride;
const u32 start_y = tile_y * m_efb_cache_tile_size;
const u32 start_x = tile_x * m_efb_cache_tile_size;
return MathUtil::Rectangle<int>(
@ -439,8 +440,7 @@ float FramebufferManager::PeekEFBDepth(u32 x, u32 y)
if (!IsEFBCacheTilePresent(true, x, y, &tile_index))
PopulateEFBCache(true, tile_index);
if (IsUsingTiledEFBCache())
m_efb_depth_cache.tiles[tile_index].frame_access_mask |= 1;
m_efb_depth_cache.tiles[tile_index].frame_access_mask |= 1;
if (m_efb_depth_cache.needs_flush)
{
@ -683,7 +683,11 @@ bool FramebufferManager::CreateReadbackFramebuffer()
const u32 tiles_wide = ((EFB_WIDTH + (m_efb_cache_tile_size - 1)) / m_efb_cache_tile_size);
const u32 tiles_high = ((EFB_HEIGHT + (m_efb_cache_tile_size - 1)) / m_efb_cache_tile_size);
total_tiles = tiles_wide * tiles_high;
m_efb_cache_tiles_wide = tiles_wide;
m_efb_cache_tile_row_stride = tiles_wide;
}
else
{
m_efb_cache_tile_row_stride = 1;
}
m_efb_color_cache.tiles.resize(total_tiles);

View File

@ -191,9 +191,14 @@ protected:
// Format conversion shaders
std::array<std::unique_ptr<AbstractPipeline>, 6> m_format_conversion_pipelines;
// EFB cache - for CPU EFB access
// EFB cache - for CPU EFB access (EFB peeks/pokes), not for EFB copies
// Width and height of a tile in pixels at 1x IR. 0 indicates non-tiled, in which case a single
// tile is used for the entire EFB.
// Note that as EFB peeks and pokes are a CPU feature, they always operate at 1x IR.
u32 m_efb_cache_tile_size = 0;
u32 m_efb_cache_tiles_wide = 0;
// Number of tiles that make up a row in m_efb_color_cache.tiles / m_efb_depth_cache.tiles.
u32 m_efb_cache_tile_row_stride = 1;
EFBCacheData m_efb_color_cache = {};
EFBCacheData m_efb_depth_cache = {};