From cb66889856ac49bd8cecbe733213baabc94009d9 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 26 May 2020 13:44:05 +1000 Subject: [PATCH] GPU/OpenGL: Fix non-interleaved interlaced display --- src/core/gpu_hw_opengl.cpp | 7 ++++--- src/core/gpu_hw_shadergen.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 86afe2ac4..ce1401373 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -612,9 +612,10 @@ void GPU_HW_OpenGL::UpdateDisplay() m_display_texture.BindFramebuffer(GL_DRAW_FRAMEBUFFER); m_vram_texture.Bind(); - const u32 flipped_vram_offset_y = VRAM_HEIGHT - vram_offset_y - display_height; + const u8 interleaved_shift = BoolToUInt8(!m_GPUSTAT.vertical_resolution); + const u32 flipped_vram_offset_y = VRAM_HEIGHT - vram_offset_y - (display_height >> interleaved_shift); const u32 scaled_flipped_vram_offset_y = - m_vram_texture.GetHeight() - scaled_vram_offset_y - scaled_display_height; + m_vram_texture.GetHeight() - scaled_vram_offset_y - (scaled_display_height >> interleaved_shift); const u32 reinterpret_field_offset = GetInterlacedDisplayLineOffset(); const u32 reinterpret_start_x = m_crtc_state.regs.X * m_resolution_scale; const u32 reinterpret_crop_left = (m_crtc_state.display_vram_left - m_crtc_state.regs.X) * m_resolution_scale; @@ -623,7 +624,7 @@ void GPU_HW_OpenGL::UpdateDisplay() UploadUniformBuffer(uniforms, sizeof(uniforms)); m_batch_ubo_dirty = true; - glViewport(0, reinterpret_field_offset, scaled_display_width, scaled_display_height); + glViewport(0, 0, scaled_display_width, scaled_display_height); glBindVertexArray(m_attributeless_vao_id); glDrawArrays(GL_TRIANGLES, 0, 3); diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 63951cabe..c40ad9531 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -1026,7 +1026,7 @@ std::string GPU_HW_ShaderGen::GenerateDisplayFragmentShader(bool depth_24bit, GP uint2 icoords = uint2(v_pos.xy); #if INTERLACED - if (((icoords.y / RESOLUTION_SCALE) & 1u) != u_field_offset) + if (((fixYCoord(icoords.y) / RESOLUTION_SCALE) & 1u) != u_field_offset) discard; #if !INTERLEAVED