Video Backends: Implement vertical scaling for xfb copies. This fixes the

display of PAL games that run in 50hz mode.
This commit is contained in:
iwubcode
2017-07-02 21:24:20 -05:00
parent 5a372020ea
commit b285188de1
8 changed files with 65 additions and 34 deletions

View File

@ -26,6 +26,8 @@ struct EFBEncodeParams
s32 SrcTop;
u32 DestWidth;
u32 ScaleFactor;
float y_scale;
u32 padding[3];
};
PSTextureEncoder::PSTextureEncoder()
@ -45,7 +47,7 @@ void PSTextureEncoder::Init()
// EFB2RAM copies use max (EFB_WIDTH * 4) by (EFB_HEIGHT / 4)
// XFB2RAM copies use max (EFB_WIDTH / 2) by (EFB_HEIGHT)
D3D11_TEXTURE2D_DESC t2dd = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM, EFB_WIDTH * 4,
EFB_HEIGHT, 1, 1, D3D11_BIND_RENDER_TARGET);
1024, 1, 1, D3D11_BIND_RENDER_TARGET);
hr = D3D::device->CreateTexture2D(&t2dd, nullptr, &m_out);
CHECK(SUCCEEDED(hr), "create efb encode output texture");
D3D::SetDebugObjectName(m_out, "efb encoder output texture");
@ -127,6 +129,7 @@ void PSTextureEncoder::Encode(u8* dst, const EFBCopyParams& params, u32 native_w
encode_params.SrcTop = src_rect.top;
encode_params.DestWidth = native_width;
encode_params.ScaleFactor = scale_by_half ? 2 : 1;
encode_params.y_scale = params.y_scale;
D3D::context->UpdateSubresource(m_encodeParams, 0, nullptr, &encode_params, 0, 0);
D3D::stateman->SetPixelConstants(m_encodeParams);
@ -134,7 +137,7 @@ void PSTextureEncoder::Encode(u8* dst, const EFBCopyParams& params, u32 native_w
// TODO: This only produces perfect downsampling for 2x IR, other resolutions will need more
// complex down filtering to average all pixels and produce the correct result.
// Also, box filtering won't be correct for anything other than 1x IR
if (scale_by_half || g_renderer->GetEFBScale() != 1)
if (scale_by_half || g_renderer->GetEFBScale() != 1 || params.y_scale > 1.0f)
D3D::SetLinearCopySampler();
else
D3D::SetPointCopySampler();