From 90d05fe37e6baf0d88a9eee8a63f0610dfba33ee Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 15 Nov 2022 15:34:03 -0800 Subject: [PATCH 1/3] VideoCommon/FramebufferManager: Always update frame access mask on depth peeks 0e02ddcf52ed86060ac1a0a85fa144738fa5163c removed separate logic for tiled versus non-tiled EFB peek caches, and as part of that made it so that color peeks updated the frame access mask even when a non-tiled cache is in use. However, the same change was not made for depth peeks. I'm not sure if this affected anything in practice. --- Source/Core/VideoCommon/FramebufferManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index a7b248f25d..490afab3a8 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -439,8 +439,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) { From 55e1c3b51d43ac1e889694a363efcce204318f91 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 15 Nov 2022 15:48:53 -0800 Subject: [PATCH 2/3] VideoCommon/FramebufferManager: use !IsUsingTiledEFBCache() in GetEFBCacheTileRect This is for readability only, and should behave identically. --- Source/Core/VideoCommon/FramebufferManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index 490afab3a8..c1713d9c81 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -394,7 +394,7 @@ bool FramebufferManager::IsEFBCacheTilePresent(bool depth, u32 x, u32 y, u32* ti MathUtil::Rectangle FramebufferManager::GetEFBCacheTileRect(u32 tile_index) const { - if (m_efb_cache_tile_size == 0) + if (!IsUsingTiledEFBCache()) return MathUtil::Rectangle(0, 0, EFB_WIDTH, EFB_HEIGHT); const u32 tile_y = tile_index / m_efb_cache_tiles_wide; From 1fdf15a1be499c308a2e3c7af96d09824638dc3e Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 15 Nov 2022 16:04:07 -0800 Subject: [PATCH 3/3] VideoCommon/FramebufferManager: Rename m_efb_cache_tiles_wide to m_efb_cache_tile_row_stride This also initializes it in the non-tiled case just for consistency, although it's not actually read in that case. --- Source/Core/VideoCommon/FramebufferManager.cpp | 15 ++++++++++----- Source/Core/VideoCommon/FramebufferManager.h | 9 +++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index c1713d9c81..f025b2dfde 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -386,8 +386,9 @@ 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; } @@ -397,8 +398,8 @@ MathUtil::Rectangle FramebufferManager::GetEFBCacheTileRect(u32 tile_index) if (!IsUsingTiledEFBCache()) return MathUtil::Rectangle(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( @@ -682,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); diff --git a/Source/Core/VideoCommon/FramebufferManager.h b/Source/Core/VideoCommon/FramebufferManager.h index 16c7f18d3c..dd073dda12 100644 --- a/Source/Core/VideoCommon/FramebufferManager.h +++ b/Source/Core/VideoCommon/FramebufferManager.h @@ -191,9 +191,14 @@ protected: // Format conversion shaders std::array, 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 = {};