diff --git a/src/core/gpu.h b/src/core/gpu.h index e142db967..4c54d21f1 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -448,7 +448,10 @@ protected: /// Returns a rectangle comprising the texture page area. Common::Rectangle GetTexturePageRectangle() const { - return Common::Rectangle::FromExtents(texture_page_x, texture_page_y, TEXTURE_PAGE_WIDTH, + static constexpr std::array texture_page_widths = { + {TEXTURE_PAGE_WIDTH / 4, TEXTURE_PAGE_WIDTH / 2, TEXTURE_PAGE_WIDTH, TEXTURE_PAGE_WIDTH}}; + return Common::Rectangle::FromExtents(texture_page_x, texture_page_y, + texture_page_widths[static_cast(mode_reg.texture_mode.GetValue())], TEXTURE_PAGE_HEIGHT); } @@ -456,8 +459,8 @@ protected: Common::Rectangle GetTexturePaletteRectangle() const { static constexpr std::array palette_widths = {{16, 256, 0, 0}}; - return Common::Rectangle::FromExtents( - texture_palette_x, texture_palette_y, palette_widths[static_cast(mode_reg.texture_mode.GetValue()) & 3], 1); + return Common::Rectangle::FromExtents(texture_palette_x, texture_palette_y, + palette_widths[static_cast(mode_reg.texture_mode.GetValue())], 1); } bool IsTexturePageChanged() const { return texture_page_changed; } diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 1c55d9bba..212f473a5 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -272,8 +272,9 @@ void GPU_HW::IncludeVRAMDityRectangle(const Common::Rectangle& 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 // shadow texture is updated - if (m_draw_mode.GetTexturePageRectangle().Intersects(rect) || - m_draw_mode.GetTexturePaletteRectangle().Intersects(rect)) + if (!m_draw_mode.IsTexturePageChanged() && + (m_draw_mode.GetTexturePageRectangle().Intersects(rect) || + m_draw_mode.IsUsingPalette() && m_draw_mode.GetTexturePaletteRectangle().Intersects(rect))) { m_draw_mode.SetTexturePageChanged(); } @@ -306,8 +307,9 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 if (m_draw_mode.IsTexturePageChanged()) { m_draw_mode.ClearTexturePageChangedFlag(); - if (m_vram_dirty_rect.Valid() && (m_draw_mode.GetTexturePageRectangle().Intersects(m_vram_dirty_rect) || - m_draw_mode.GetTexturePaletteRectangle().Intersects(m_vram_dirty_rect))) + if (m_vram_dirty_rect.Valid() && + (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"); if (!IsFlushed())