From a9364cd5dbaee3d6b747e3dfecebaf789883f3c4 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sat, 20 Dec 2014 17:10:58 +0100 Subject: [PATCH] OGL: Support stereoscopic XFB blit to screen. --- Source/Core/VideoBackends/OGL/Render.cpp | 33 +++++++++++++----------- Source/Core/VideoBackends/OGL/Render.h | 2 ++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index a03f8cd61d..2def435a11 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1270,6 +1270,22 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE ClearEFBCache(); } +void Renderer::BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height) +{ + if (g_ActiveConfig.iStereoMode == STEREO_SBS || g_ActiveConfig.iStereoMode == STEREO_TAB) + { + TargetRectangle leftRc, rightRc; + ConvertStereoRectangle(dst, leftRc, rightRc); + + m_post_processor->BlitFromTexture(src, leftRc, src_texture, src_width, src_height, 0); + m_post_processor->BlitFromTexture(src, rightRc, src_texture, src_width, src_height, 1); + } + else + { + m_post_processor->BlitFromTexture(src, dst, src_texture, src_width, src_height); + } +} + void Renderer::ReinterpretPixelData(unsigned int convtype) { if (convtype == 0 || convtype == 2) @@ -1473,8 +1489,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co sourceRc.right -= fbStride - fbWidth; - // TODO: Virtual XFB stereoscopic 3D support. - m_post_processor->BlitFromTexture(sourceRc, drawRc, xfbSource->texture, xfbSource->texWidth, xfbSource->texHeight, 1); + BlitScreen(sourceRc, drawRc, xfbSource->texture, xfbSource->texWidth, xfbSource->texHeight); } } else @@ -1483,19 +1498,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co // for msaa mode, we must resolve the efb content to non-msaa GLuint tex = FramebufferManager::ResolveAndGetRenderTarget(rc); - - if (g_ActiveConfig.iStereoMode == STEREO_SBS || g_ActiveConfig.iStereoMode == STEREO_TAB) - { - TargetRectangle leftRc, rightRc; - ConvertStereoRectangle(flipped_trc, leftRc, rightRc); - - m_post_processor->BlitFromTexture(targetRc, leftRc, tex, s_target_width, s_target_height, 0); - m_post_processor->BlitFromTexture(targetRc, rightRc, tex, s_target_width, s_target_height, 1); - } - else - { - m_post_processor->BlitFromTexture(targetRc, flipped_trc, tex, s_target_width, s_target_height); - } + BlitScreen(targetRc, flipped_trc, tex, s_target_width, s_target_height); } glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); diff --git a/Source/Core/VideoBackends/OGL/Render.h b/Source/Core/VideoBackends/OGL/Render.h index b536d1cecb..cfa01a2e6f 100644 --- a/Source/Core/VideoBackends/OGL/Render.h +++ b/Source/Core/VideoBackends/OGL/Render.h @@ -91,6 +91,8 @@ public: private: void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const u32* data); + + void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height); }; }