summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/SWRenderer.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2017-05-29 17:02:09 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2017-11-17 19:47:56 -0600
commit79387dddb24ddf035b70cd9379a42368dcd49e93 (patch)
tree7b783c46e1ffd052842f11112f58c61993f0af1b /Source/Core/VideoBackends/Software/SWRenderer.cpp
parent84ca9a4aec0048e5ac01caea8f8be9210eb947f6 (diff)
Add support for hybrid XFB
Diffstat (limited to 'Source/Core/VideoBackends/Software/SWRenderer.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/SWRenderer.cpp91
1 files changed, 4 insertions, 87 deletions
diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp
index dc378cbede..9074a429b9 100644
--- a/Source/Core/VideoBackends/Software/SWRenderer.cpp
+++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp
@@ -23,26 +23,13 @@
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
-static u8* s_xfbColorTexture[2];
-static int s_currentColorTexture = 0;
-
SWRenderer::SWRenderer()
: ::Renderer(static_cast<int>(MAX_XFB_WIDTH), static_cast<int>(MAX_XFB_HEIGHT))
{
}
-SWRenderer::~SWRenderer()
-{
- delete[] s_xfbColorTexture[0];
- delete[] s_xfbColorTexture[1];
-}
-
void SWRenderer::Init()
{
- s_xfbColorTexture[0] = new u8[MAX_XFB_WIDTH * MAX_XFB_HEIGHT * 4];
- s_xfbColorTexture[1] = new u8[MAX_XFB_WIDTH * MAX_XFB_HEIGHT * 4];
-
- s_currentColorTexture = 0;
}
void SWRenderer::Shutdown()
@@ -55,80 +42,16 @@ void SWRenderer::RenderText(const std::string& pstr, int left, int top, u32 colo
SWOGLWindow::s_instance->PrintText(pstr, left, top, color);
}
-u8* SWRenderer::GetNextColorTexture()
-{
- return s_xfbColorTexture[!s_currentColorTexture];
-}
-
-u8* SWRenderer::GetCurrentColorTexture()
-{
- return s_xfbColorTexture[s_currentColorTexture];
-}
-
-void SWRenderer::SwapColorTexture()
-{
- s_currentColorTexture = !s_currentColorTexture;
-}
-
-void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed* xfb, u32 fbWidth, u32 fbHeight)
-{
- if (fbWidth * fbHeight > MAX_XFB_WIDTH * MAX_XFB_HEIGHT)
- {
- ERROR_LOG(VIDEO, "Framebuffer is too large: %ix%i", fbWidth, fbHeight);
- return;
- }
-
- u32 offset = 0;
- u8* TexturePointer = GetNextColorTexture();
-
- for (u16 y = 0; y < fbHeight; y++)
- {
- for (u16 x = 0; x < fbWidth; x += 2)
- {
- // We do this one color sample (aka 2 RGB pixles) at a time
- int Y1 = xfb[x].Y - 16;
- int Y2 = xfb[x + 1].Y - 16;
- int U = int(xfb[x].UV) - 128;
- int V = int(xfb[x + 1].UV) - 128;
-
- // We do the inverse BT.601 conversion for YCbCr to RGB
- // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
- TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y1 + 1.596f * V), 0, 255);
- TexturePointer[offset++] =
- MathUtil::Clamp(int(1.164f * Y1 - 0.392f * U - 0.813f * V), 0, 255);
- TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y1 + 2.017f * U), 0, 255);
- TexturePointer[offset++] = 255;
-
- TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y2 + 1.596f * V), 0, 255);
- TexturePointer[offset++] =
- MathUtil::Clamp(int(1.164f * Y2 - 0.392f * U - 0.813f * V), 0, 255);
- TexturePointer[offset++] = MathUtil::Clamp(int(1.164f * Y2 + 2.017f * U), 0, 255);
- TexturePointer[offset++] = 255;
- }
- xfb += fbWidth;
- }
- SwapColorTexture();
-}
-
// Called on the GPU thread
-void SWRenderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
- const EFBRectangle& rc, u64 ticks, float Gamma)
+void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks, float Gamma)
{
- if (g_ActiveConfig.bUseXFB)
- {
- EfbInterface::yuv422_packed* xfb = (EfbInterface::yuv422_packed*)Memory::GetPointer(xfbAddr);
- UpdateColorTexture(xfb, fbWidth, fbHeight);
- }
- else
- {
- EfbInterface::BypassXFB(GetCurrentColorTexture(), fbWidth, fbHeight, rc, Gamma);
- }
+ SWOGLWindow::s_instance->ShowImage(texture, 1.0);
// Save screenshot
if (IsFrameDumping())
{
AVIDump::Frame state = AVIDump::FetchState(ticks);
- DumpFrameData(GetCurrentColorTexture(), fbWidth, fbHeight, fbWidth * 4, state);
+ //DumpFrameData(GetCurrentColorTexture(), fbWidth, fbHeight, fbWidth * 4, state);
FinishFrameData();
}
@@ -136,15 +59,9 @@ void SWRenderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
DrawDebugText();
- SWOGLWindow::s_instance->ShowImage(GetCurrentColorTexture(), fbWidth * 4, fbWidth, fbHeight, 1.0);
+ SWOGLWindow::s_instance->ShowImage(texture, 1.0);
UpdateActiveConfig();
-
- // virtual XFB is not supported
- if (g_ActiveConfig.bUseXFB)
- {
- Config::SetCurrent(Config::GFX_USE_REAL_XFB, true);
- }
}
u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)