GPU: Use correct texture page size in overlap tracking

This commit is contained in:
Connor McLaughlin 2020-02-12 20:58:34 +09:00
parent 278aa86d14
commit b8210ecbe3
2 changed files with 12 additions and 7 deletions

View File

@ -448,7 +448,10 @@ protected:
/// Returns a rectangle comprising the texture page area. /// Returns a rectangle comprising the texture page area.
Common::Rectangle<u32> GetTexturePageRectangle() const Common::Rectangle<u32> GetTexturePageRectangle() const
{ {
return Common::Rectangle<u32>::FromExtents(texture_page_x, texture_page_y, TEXTURE_PAGE_WIDTH, static constexpr std::array<u32, 4> texture_page_widths = {
{TEXTURE_PAGE_WIDTH / 4, TEXTURE_PAGE_WIDTH / 2, TEXTURE_PAGE_WIDTH, TEXTURE_PAGE_WIDTH}};
return Common::Rectangle<u32>::FromExtents(texture_page_x, texture_page_y,
texture_page_widths[static_cast<u8>(mode_reg.texture_mode.GetValue())],
TEXTURE_PAGE_HEIGHT); TEXTURE_PAGE_HEIGHT);
} }
@ -456,8 +459,8 @@ protected:
Common::Rectangle<u32> GetTexturePaletteRectangle() const Common::Rectangle<u32> GetTexturePaletteRectangle() const
{ {
static constexpr std::array<u32, 4> palette_widths = {{16, 256, 0, 0}}; static constexpr std::array<u32, 4> palette_widths = {{16, 256, 0, 0}};
return Common::Rectangle<u32>::FromExtents( return Common::Rectangle<u32>::FromExtents(texture_palette_x, texture_palette_y,
texture_palette_x, texture_palette_y, palette_widths[static_cast<u8>(mode_reg.texture_mode.GetValue()) & 3], 1); palette_widths[static_cast<u8>(mode_reg.texture_mode.GetValue())], 1);
} }
bool IsTexturePageChanged() const { return texture_page_changed; } bool IsTexturePageChanged() const { return texture_page_changed; }

View File

@ -272,8 +272,9 @@ void GPU_HW::IncludeVRAMDityRectangle(const Common::Rectangle<u32>& rect)
// the vram area can include the texture page, but the game can leave it as-is. in this case, set it as dirty so the // the vram area can include the texture page, but the game can leave it as-is. in this case, set it as dirty so the
// shadow texture is updated // shadow texture is updated
if (m_draw_mode.GetTexturePageRectangle().Intersects(rect) || if (!m_draw_mode.IsTexturePageChanged() &&
m_draw_mode.GetTexturePaletteRectangle().Intersects(rect)) (m_draw_mode.GetTexturePageRectangle().Intersects(rect) ||
m_draw_mode.IsUsingPalette() && m_draw_mode.GetTexturePaletteRectangle().Intersects(rect)))
{ {
m_draw_mode.SetTexturePageChanged(); m_draw_mode.SetTexturePageChanged();
} }
@ -306,8 +307,9 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32
if (m_draw_mode.IsTexturePageChanged()) if (m_draw_mode.IsTexturePageChanged())
{ {
m_draw_mode.ClearTexturePageChangedFlag(); m_draw_mode.ClearTexturePageChangedFlag();
if (m_vram_dirty_rect.Valid() && (m_draw_mode.GetTexturePageRectangle().Intersects(m_vram_dirty_rect) || if (m_vram_dirty_rect.Valid() &&
m_draw_mode.GetTexturePaletteRectangle().Intersects(m_vram_dirty_rect))) (m_draw_mode.GetTexturePageRectangle().Intersects(m_vram_dirty_rect) ||
(m_draw_mode.IsUsingPalette() && m_draw_mode.GetTexturePaletteRectangle().Intersects(m_vram_dirty_rect))))
{ {
Log_DevPrintf("Invalidating VRAM read cache due to drawing area overlap"); Log_DevPrintf("Invalidating VRAM read cache due to drawing area overlap");
if (!IsFlushed()) if (!IsFlushed())