GPU: Align display widths to 4 pixels

Documentation thanks to nocash.

Fixes line on edge in X2 - No Relief, Gunbird.
This commit is contained in:
Connor McLaughlin 2020-05-17 18:46:56 +10:00
parent 664bd06df6
commit 0ef0c36704

View file

@ -500,9 +500,8 @@ void GPU::UpdateCRTCDisplayParameters()
const u8 height_shift = BoolToUInt8(m_GPUSTAT.In480iMode()); const u8 height_shift = BoolToUInt8(m_GPUSTAT.In480iMode());
// Determine screen size. // Determine screen size.
cs.display_width = std::max<u16>( cs.display_width = (((cs.horizontal_active_end - cs.horizontal_active_start) / cs.dot_clock_divider) + 2u) & ~3u;
((cs.horizontal_active_end - cs.horizontal_active_start) + (cs.dot_clock_divider - 1)) / cs.dot_clock_divider, 1u); cs.display_height = (cs.vertical_active_end - cs.vertical_active_start) << height_shift;
cs.display_height = std::max<u16>((cs.vertical_active_end - cs.vertical_active_start) << height_shift, 1u);
// Determine if we need to adjust the VRAM rectangle (because the display is starting outside the visible area) or add // Determine if we need to adjust the VRAM rectangle (because the display is starting outside the visible area) or add
// padding. // padding.
@ -521,21 +520,19 @@ void GPU::UpdateCRTCDisplayParameters()
if (horizontal_display_end <= cs.horizontal_active_end) if (horizontal_display_end <= cs.horizontal_active_end)
{ {
cs.display_vram_width = std::max<u16>( const u16 active_ticks =
(((horizontal_display_end - horizontal_display_end -
std::min(horizontal_display_end, std::max(horizontal_display_start, cs.horizontal_active_start))) + std::min(horizontal_display_end, std::max(horizontal_display_start, cs.horizontal_active_start));
(cs.dot_clock_divider - 1)) /
cs.dot_clock_divider), cs.display_vram_width = ((active_ticks / cs.dot_clock_divider) + 2u) & ~3u;
1u);
} }
else else
{ {
cs.display_vram_width = std::max<u16>( const u16 active_ticks =
(((cs.horizontal_active_end - cs.horizontal_active_end -
std::min(cs.horizontal_active_end, std::max(horizontal_display_start, cs.horizontal_active_start))) + std::min(cs.horizontal_active_end, std::max(horizontal_display_start, cs.horizontal_active_start));
(cs.dot_clock_divider - 1)) /
cs.dot_clock_divider), cs.display_vram_width = ((active_ticks / cs.dot_clock_divider) + 2u) & ~3u;
1u);
} }
if (vertical_display_start >= cs.vertical_active_start) if (vertical_display_start >= cs.vertical_active_start)