From 53881219ce040326f0c291fafbf864a4198e7734 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 14 Nov 2019 00:59:09 +1000 Subject: [PATCH] GPU: Fix handling of interlaced non-480-line mode --- src/core/gpu_hw_d3d11.cpp | 10 +++++----- src/core/gpu_hw_opengl.cpp | 7 +++---- src/core/gpu_hw_shadergen.cpp | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index 9bb9c9717..7c328b321 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -432,6 +432,7 @@ void GPU_HW_D3D11::BlitTexture(ID3D11RenderTargetView* dst, u32 dst_x, u32 dst_y static_cast(src_height) / static_cast(src_texture_height)}; m_context->OMSetRenderTargets(1, &dst, nullptr); + m_context->PSSetShaderResources(0, 1, &src); SetViewport(dst_x, dst_y, dst_width, dst_height); SetScissor(dst_x, dst_y, dst_width, dst_height); DrawUtilityShader(m_copy_pixel_shader.Get(), uniforms, sizeof(uniforms)); @@ -535,8 +536,7 @@ void GPU_HW_D3D11::UpdateDisplay() } else { - const u32 field_offset = BoolToUInt8(m_GPUSTAT.vertical_interlace && !m_GPUSTAT.drawing_even_line); - const u32 scaled_field_offset = field_offset * m_resolution_scale; + const u32 field_offset = BoolToUInt8(m_GPUSTAT.vertical_interlace && m_GPUSTAT.interlaced_field); ID3D11PixelShader* display_pixel_shader = m_display_pixel_shaders[BoolToUInt8(m_GPUSTAT.display_area_color_depth_24)] @@ -556,7 +556,7 @@ void GPU_HW_D3D11::UpdateDisplay() m_context->PSSetShaderResources(0, 1, m_vram_downsample_texture.GetD3DSRVArray()); const u32 uniforms[4] = {vram_offset_x, vram_offset_y, field_offset}; - SetViewportAndScissor(0, scaled_field_offset, display_width, display_height); + SetViewportAndScissor(0, field_offset, display_width, display_height); DrawUtilityShader(display_pixel_shader, uniforms, sizeof(uniforms)); UploadUniformBlock(uniforms, sizeof(uniforms)); @@ -569,8 +569,8 @@ void GPU_HW_D3D11::UpdateDisplay() m_context->OMSetRenderTargets(1, m_display_texture.GetD3DRTVArray(), nullptr); m_context->PSSetShaderResources(0, 1, m_vram_texture.GetD3DSRVArray()); - const u32 uniforms[4] = {scaled_vram_offset_x, scaled_vram_offset_y, scaled_field_offset}; - SetViewportAndScissor(0, scaled_field_offset, scaled_display_width, scaled_display_height); + const u32 uniforms[4] = {scaled_vram_offset_x, scaled_vram_offset_y, field_offset}; + SetViewportAndScissor(0, field_offset, scaled_display_width, scaled_display_height); DrawUtilityShader(display_pixel_shader, uniforms, sizeof(uniforms)); UploadUniformBlock(uniforms, sizeof(uniforms)); diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index f988e7e08..98eca2f54 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -448,8 +448,7 @@ void GPU_HW_OpenGL::UpdateDisplay() const u32 flipped_vram_offset_y = VRAM_HEIGHT - vram_offset_y - display_height; const u32 scaled_flipped_vram_offset_y = m_vram_texture->GetHeight() - scaled_vram_offset_y - scaled_display_height; - const u32 field_offset = BoolToUInt8(m_GPUSTAT.vertical_interlace && !m_GPUSTAT.drawing_even_line); - const u32 scaled_field_offset = field_offset * m_resolution_scale; + const u32 field_offset = BoolToUInt8(m_GPUSTAT.vertical_interlace && m_GPUSTAT.interlaced_field); glDisable(GL_BLEND); glDisable(GL_SCISSOR_TEST); @@ -491,9 +490,9 @@ void GPU_HW_OpenGL::UpdateDisplay() m_display_texture->BindFramebuffer(GL_DRAW_FRAMEBUFFER); m_vram_texture->Bind(); - glViewport(0, scaled_field_offset, scaled_display_width, scaled_display_height); + glViewport(0, field_offset, scaled_display_width, scaled_display_height); - const u32 uniforms[4] = {scaled_vram_offset_x, scaled_flipped_vram_offset_y, scaled_field_offset}; + const u32 uniforms[4] = {scaled_vram_offset_x, scaled_flipped_vram_offset_y, field_offset}; UploadUniformBlock(uniforms, sizeof(uniforms)); m_batch_ubo_dirty = true; diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index d98c441c0..3f430ebc0 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -649,7 +649,7 @@ std::string GPU_HW_ShaderGen::GenerateDisplayFragmentShader(bool depth_24bit, bo int2 icoords = int2(v_pos.xy); #if INTERLACED - if ((((icoords.y - u_base_coords.z) / RESOLUTION_SCALE) & 1) != 0) + if (((icoords.y - u_base_coords.z) & 1) != 0) discard; #endif