From e1332b1d7ed4696a4a727906bce62689b8eb329c Mon Sep 17 00:00:00 2001 From: iwubcode Date: Thu, 21 Dec 2017 11:22:46 -0600 Subject: Texture Cache Base: Move PAL vertical scaling to be baked into the texture size. This saves on a number of multiplications and fixes an issue where we were multiplying the y-scaling factor by the srcRectangle's height + 1 which was causing a crash in some GC titles --- Source/Core/VideoCommon/BPStructs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 108a478035..2e79db8477 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -252,12 +252,14 @@ static void BPWritten(const BPCmd& bp) float num_xfb_lines = 1.0f + bpmem.copyTexSrcWH.y * yScale; + srcRect.bottom = (int)(bpmem.copyTexSrcXY.y + num_xfb_lines); + u32 height = static_cast(num_xfb_lines); DEBUG_LOG(VIDEO, "RenderToXFB: destAddr: %08x | srcRect {%d %d %d %d} | fbWidth: %u | " - "fbStride: %u | fbHeight: %u", + "fbStride: %u | fbHeight: %u | yScale: %f", destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, - bpmem.copyTexSrcWH.x + 1, destStride, height); + bpmem.copyTexSrcWH.x + 1, destStride, height, yScale); bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride, -- cgit v1.2.3 From 50d96a4411642118c5c4570a12838d2fdd35b27b Mon Sep 17 00:00:00 2001 From: iwubcode Date: Thu, 21 Dec 2017 21:16:21 -0600 Subject: BPStructs: Use static cast for XFB/EFB copies --- Source/Core/VideoCommon/BPStructs.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 2e79db8477..7d027c7b72 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -214,14 +214,14 @@ static void BPWritten(const BPCmd& bp) u32 destStride = bpmem.copyMipMapStrideChannels << 5; EFBRectangle srcRect; - srcRect.left = (int)bpmem.copyTexSrcXY.x; - srcRect.top = (int)bpmem.copyTexSrcXY.y; + srcRect.left = static_cast(bpmem.copyTexSrcXY.x); + srcRect.top = static_cast(bpmem.copyTexSrcXY.y); // Here Width+1 like Height, otherwise some textures are corrupted already since the native // resolution. // TODO: What's the behavior of out of bound access? - srcRect.right = (int)(bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1); - srcRect.bottom = (int)(bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1); + srcRect.right = static_cast(bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1); + srcRect.bottom = static_cast(bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1); UPE_Copy PE_copy = bpmem.triggerEFBCopy; @@ -246,13 +246,13 @@ static void BPWritten(const BPCmd& bp) float yScale; if (PE_copy.scale_invert) - yScale = 256.0f / (float)bpmem.dispcopyyscale; + yScale = 256.0f / static_cast(bpmem.dispcopyyscale); else - yScale = (float)bpmem.dispcopyyscale / 256.0f; + yScale = static_cast(bpmem.dispcopyyscale) / 256.0f; float num_xfb_lines = 1.0f + bpmem.copyTexSrcWH.y * yScale; - srcRect.bottom = (int)(bpmem.copyTexSrcXY.y + num_xfb_lines); + srcRect.bottom = static_cast(bpmem.copyTexSrcXY.y + num_xfb_lines); u32 height = static_cast(num_xfb_lines); -- cgit v1.2.3