GPU: Disable display when CRTC configuration is invalid

This commit is contained in:
Connor McLaughlin 2020-04-27 21:49:34 +10:00
parent 79111e4e03
commit 8c6cb877eb
5 changed files with 27 additions and 16 deletions

View File

@ -517,19 +517,21 @@ void GPU::UpdateCRTCDisplayParameters()
if (horizontal_display_end <= cs.horizontal_active_end)
{
cs.display_vram_width =
std::max<u16>((((horizontal_display_end - std::max(horizontal_display_start, cs.horizontal_active_start)) +
(cs.dot_clock_divider - 1)) /
cs.dot_clock_divider),
1u);
cs.display_vram_width = std::max<u16>(
(((horizontal_display_end -
std::min(horizontal_display_end, std::max(horizontal_display_start, cs.horizontal_active_start))) +
(cs.dot_clock_divider - 1)) /
cs.dot_clock_divider),
1u);
}
else
{
cs.display_vram_width =
std::max<u16>((((cs.horizontal_active_end - std::max(horizontal_display_start, cs.horizontal_active_start)) +
(cs.dot_clock_divider - 1)) /
cs.dot_clock_divider),
1u);
cs.display_vram_width = std::max<u16>(
(((cs.horizontal_active_end -
std::min(cs.horizontal_active_end, std::max(horizontal_display_start, cs.horizontal_active_start))) +
(cs.dot_clock_divider - 1)) /
cs.dot_clock_divider),
1u);
}
if (vertical_display_start >= cs.vertical_active_start)
@ -545,13 +547,16 @@ void GPU::UpdateCRTCDisplayParameters()
if (vertical_display_end <= cs.vertical_active_end)
{
cs.display_vram_height = (vertical_display_end - std::max(vertical_display_start, cs.vertical_active_start))
cs.display_vram_height = (vertical_display_end - std::min(vertical_display_end, std::max(vertical_display_start,
cs.vertical_active_start)))
<< height_shift;
}
else
{
cs.display_vram_height = (cs.vertical_active_end - std::max(vertical_display_start, cs.vertical_active_start))
<< height_shift;
cs.display_vram_height =
(cs.vertical_active_end -
std::min(vertical_display_end, std::max(vertical_display_start, cs.vertical_active_start)))
<< height_shift;
}
}

View File

@ -334,6 +334,12 @@ protected:
// Ticks for hblank/vblank.
void Execute(TickCount ticks);
/// Returns false if the DAC is loading any data from VRAM.
ALWAYS_INLINE bool IsDisplayDisabled() const
{
return m_GPUSTAT.display_disable || m_crtc_state.display_vram_width == 0 || m_crtc_state.display_vram_height == 0;
}
/// Returns true if scanout should be interlaced.
ALWAYS_INLINE bool IsInterlacedDisplayEnabled() const { return (!m_force_progressive_scan) & m_GPUSTAT.In480iMode(); }

View File

@ -552,7 +552,7 @@ void GPU_HW_D3D11::UpdateDisplay()
const u32 scaled_display_height = display_height * m_resolution_scale;
const bool interlaced = IsInterlacedDisplayEnabled();
if (m_GPUSTAT.display_disable)
if (IsDisplayDisabled())
{
m_host_display->ClearDisplayTexture();
}

View File

@ -544,7 +544,7 @@ void GPU_HW_OpenGL::UpdateDisplay()
const u32 scaled_display_height = display_height * m_resolution_scale;
const bool interlaced = IsInterlacedDisplayEnabled();
if (m_GPUSTAT.display_disable)
if (IsDisplayDisabled())
{
m_host_display->ClearDisplayTexture();
}

View File

@ -144,7 +144,7 @@ void GPU_SW::UpdateDisplay()
if (!m_system->GetSettings().debugging.show_vram)
{
if (m_GPUSTAT.display_disable)
if (IsDisplayDisabled())
{
m_host_display->ClearDisplayTexture();
return;