diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 19258256db..995e1f3a37 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -658,10 +658,10 @@ void Renderer::UpdateViewport() ERROR_LOG(VIDEO, "Tried to set a viewport which is too wide to emulate with Direct3D11. Requested EFB size is %dx%d\n", Renderer::GetFullTargetWidth(), Renderer::GetFullTargetHeight()); // Fix the viewport to fit to the old EFB size, TODO: Check this for off-by-one errors - newx *= (float)old_fulltarget_w / (float)Renderer::GetFullTargetWidth(); - newy *= (float)old_fulltarget_h / (float)Renderer::GetFullTargetHeight(); - newwidth *= (float)old_fulltarget_w / (float)Renderer::GetFullTargetWidth(); - newheight *= (float)old_fulltarget_h / (float)Renderer::GetFullTargetHeight(); + newx *= (float)(old_fulltarget_w-1) / (float)(Renderer::GetFullTargetWidth()-1); + newy *= (float)(old_fulltarget_h-1) / (float)(Renderer::GetFullTargetHeight()-1); + newwidth *= (float)(old_fulltarget_w-1) / (float)(Renderer::GetFullTargetWidth()-1); + newheight *= (float)(old_fulltarget_h-1) / (float)(Renderer::GetFullTargetHeight()-1); s_Fulltarget_width = old_fulltarget_w; s_Fulltarget_height = old_fulltarget_h; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index d6f63dbe23..a8a2e3df23 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -692,9 +692,6 @@ void Renderer::UpdateViewport() int scissorXOff = bpmem.scissorOffset.x << 1; int scissorYOff = bpmem.scissorOffset.y << 1; - int Xstride = (Renderer::GetFullTargetWidth() - Renderer::GetTargetWidth()) / 2; - int Ystride = (Renderer::GetFullTargetHeight() - Renderer::GetTargetHeight()) / 2; - // TODO: ceil, floor or just cast to int? int X = EFBToScaledX((int)ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - scissorXOff)) + TargetStrideX(); int Y = EFBToScaledY((int)ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - scissorYOff)) + TargetStrideY(); @@ -740,16 +737,16 @@ void Renderer::UpdateViewport() { D3DCAPS9 caps = D3D::GetCaps(); // Make sure that the requested size is actually supported by the GFX driver - if (Renderer::GetFullTargetWidth() > caps.MaxTextureWidth || Renderer::GetFullTargetHeight() > caps.MaxTextureHeight) + if (Renderer::GetFullTargetWidth() > (int)caps.MaxTextureWidth || Renderer::GetFullTargetHeight() > (int)caps.MaxTextureHeight) { // Skip EFB recreation and viewport setting. Most likely causes glitches in this case, but prevents crashes at least ERROR_LOG(VIDEO, "Tried to set a viewport which is too wide to emulate with Direct3D9. Requested EFB size is %dx%d, keeping the %dx%d EFB now\n", Renderer::GetFullTargetWidth(), Renderer::GetFullTargetHeight(), old_fulltarget_w, old_fulltarget_h); - // Fix the viewport to fit to the old EFB size, TODO: Check this for off-by-one errors - X *= old_fulltarget_w / Renderer::GetFullTargetWidth(); - Y *= old_fulltarget_h / Renderer::GetFullTargetHeight(); - Width *= old_fulltarget_w / Renderer::GetFullTargetWidth(); - Height *= old_fulltarget_h / Renderer::GetFullTargetHeight(); + // Fix the viewport to fit to the old EFB size + X *= (old_fulltarget_w-1) / (Renderer::GetFullTargetWidth()-1); + Y *= (old_fulltarget_h-1) / (Renderer::GetFullTargetHeight()-1); + Width *= (old_fulltarget_w-1) / (Renderer::GetFullTargetWidth()-1); + Height *= (old_fulltarget_h-1) / (Renderer::GetFullTargetHeight()-1); s_Fulltarget_width = old_fulltarget_w; s_Fulltarget_height = old_fulltarget_h; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index d157ca9d1e..1cc71566c6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -781,9 +781,6 @@ void Renderer::UpdateViewport() int scissorXOff = bpmem.scissorOffset.x << 1; int scissorYOff = bpmem.scissorOffset.y << 1; - // int Xstride = (s_Fulltarget_width - s_target_width) / 2; - // int Ystride = (s_Fulltarget_height - s_target_height) / 2; - // TODO: ceil, floor or just cast to int? int X = EFBToScaledX((int)ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - (float)scissorXOff)); int Y = EFBToScaledY((int)ceil((float)EFB_HEIGHT - xfregs.rawViewport[4] + xfregs.rawViewport[1] + (float)scissorYOff));