Merge pull request #4458 from stenzek/strided-xfb

D3D/Vulkan: Handle strided XFB copies
This commit is contained in:
Stenzek 2016-11-20 12:34:11 +10:00 committed by GitHub
commit 3d21169dfc
3 changed files with 10 additions and 6 deletions

View File

@ -275,8 +275,10 @@ void FramebufferManager::CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight,
const EFBRectangle& sourceRc, float Gamma) const EFBRectangle& sourceRc, float Gamma)
{ {
u8* dst = Memory::GetPointer(xfbAddr); u8* dst = Memory::GetPointer(xfbAddr);
// below div2 due to dx using pixel width
s_xfbEncoder.Encode(dst, fbStride / 2, fbHeight, sourceRc, Gamma); // The destination stride can differ from the copy region width, in which case the pixels
// outside the copy region should not be written to.
s_xfbEncoder.Encode(dst, static_cast<u32>(sourceRc.GetWidth()), fbHeight, sourceRc, Gamma);
} }
std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int target_width, std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int target_width,

View File

@ -1415,9 +1415,11 @@ void FramebufferManager::CopyToRealXFB(u32 xfb_addr, u32 fb_stride, u32 fb_heigh
{static_cast<u32>(scaled_rc.GetWidth()), static_cast<u32>(scaled_rc.GetHeight())}}; {static_cast<u32>(scaled_rc.GetWidth()), static_cast<u32>(scaled_rc.GetHeight())}};
Texture2D* src_texture = ResolveEFBColorTexture(scaled_rc_vk); Texture2D* src_texture = ResolveEFBColorTexture(scaled_rc_vk);
// 2 bytes per pixel, so divide fb_stride by 2 to get the width. // The destination stride can differ from the copy region width, in which case the pixels
TextureCache::GetInstance()->EncodeYUYVTextureToMemory(xfb_ptr, fb_stride / 2, fb_stride, // outside the copy region should not be written to.
fb_height, src_texture, scaled_rc); TextureCache::GetInstance()->EncodeYUYVTextureToMemory(
xfb_ptr, static_cast<u32>(source_rc.GetWidth()), fb_stride, fb_height, src_texture,
scaled_rc);
// If we sourced directly from the EFB framebuffer, restore it to a color attachment. // If we sourced directly from the EFB framebuffer, restore it to a color attachment.
if (src_texture == m_efb_color_texture.get()) if (src_texture == m_efb_color_texture.get())

View File

@ -888,7 +888,7 @@ void TextureCache::EncodeYUYVTextureToMemory(void* dst_ptr, u32 dst_width, u32 d
m_rgb_to_yuyv_shader); m_rgb_to_yuyv_shader);
VkRect2D region = {{0, 0}, {output_width, dst_height}}; VkRect2D region = {{0, 0}, {output_width, dst_height}};
draw.BeginRenderPass(m_texture_encoder->GetEncodingTextureFramebuffer(), region); draw.BeginRenderPass(m_texture_encoder->GetEncodingTextureFramebuffer(), region);
draw.SetPSSampler(0, src_texture->GetView(), g_object_cache->GetPointSampler()); draw.SetPSSampler(0, src_texture->GetView(), g_object_cache->GetLinearSampler());
draw.DrawQuad(0, 0, static_cast<int>(output_width), static_cast<int>(dst_height), src_rect.left, draw.DrawQuad(0, 0, static_cast<int>(output_width), static_cast<int>(dst_height), src_rect.left,
src_rect.top, 0, src_rect.GetWidth(), src_rect.GetHeight(), src_rect.top, 0, src_rect.GetWidth(), src_rect.GetHeight(),
static_cast<int>(src_texture->GetWidth()), static_cast<int>(src_texture->GetWidth()),