2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:29:41 +00:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-09 01:37:08 +00:00
|
|
|
|
2017-01-23 16:20:20 +00:00
|
|
|
#include "VideoBackends/Software/SWRenderer.h"
|
|
|
|
|
2014-06-03 05:08:54 +00:00
|
|
|
#include <string>
|
2014-05-03 02:47:04 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2017-05-18 12:59:38 +00:00
|
|
|
#include "Core/Config/GraphicsSettings.h"
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "VideoBackends/Software/EfbCopy.h"
|
2017-11-19 05:16:22 +00:00
|
|
|
#include "VideoBackends/Software/EfbInterface.h"
|
2015-09-26 08:07:48 +00:00
|
|
|
#include "VideoBackends/Software/SWOGLWindow.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
2017-01-23 16:20:20 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2013-04-13 05:48:53 +00:00
|
|
|
|
2017-03-04 06:40:08 +00:00
|
|
|
SWRenderer::SWRenderer()
|
|
|
|
: ::Renderer(static_cast<int>(MAX_XFB_WIDTH), static_cast<int>(MAX_XFB_HEIGHT))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
void SWRenderer::Init()
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
void SWRenderer::Shutdown()
|
2013-11-16 04:07:08 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
UpdateActiveConfig();
|
2013-11-16 04:07:08 +00:00
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
void SWRenderer::RenderText(const std::string& pstr, int left, int top, u32 color)
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SWOGLWindow::s_instance->PrintText(pstr, left, top, color);
|
2010-06-09 01:37:08 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 11:51:39 +00:00
|
|
|
// Called on the GPU thread
|
2017-10-01 16:19:29 +00:00
|
|
|
void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region, u64 ticks,
|
|
|
|
float Gamma)
|
2013-08-20 11:51:39 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
|
|
|
|
|
|
|
DrawDebugText();
|
|
|
|
|
2017-09-29 05:31:08 +00:00
|
|
|
SWOGLWindow::s_instance->ShowImage(texture, xfb_region);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
UpdateActiveConfig();
|
2015-10-09 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
u32 value = 0;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
2017-01-23 07:51:46 +00:00
|
|
|
case EFBAccessType::PeekZ:
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
value = EfbInterface::GetDepth(x, y);
|
|
|
|
break;
|
|
|
|
}
|
2017-01-23 07:51:46 +00:00
|
|
|
case EFBAccessType::PeekColor:
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-09-21 22:53:13 +00:00
|
|
|
const u32 color = EfbInterface::GetColor(x, y);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
// rgba to argb
|
|
|
|
value = (color >> 8) | (color & 0xff) << 24;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
2015-10-09 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u16 SWRenderer::BBoxRead(int index)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return BoundingBox::coords[index];
|
2015-10-09 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SWRenderer::BBoxWrite(int index, u16 value)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
BoundingBox::coords[index] = value;
|
2015-10-09 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TargetRectangle SWRenderer::ConvertEFBRectangle(const EFBRectangle& rc)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
TargetRectangle result;
|
|
|
|
result.left = rc.left;
|
|
|
|
result.top = rc.top;
|
|
|
|
result.right = rc.right;
|
|
|
|
result.bottom = rc.bottom;
|
|
|
|
return result;
|
2015-10-09 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void SWRenderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable,
|
|
|
|
bool zEnable, u32 color, u32 z)
|
2015-10-09 18:50:36 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
EfbCopy::ClearEfb();
|
2010-06-09 01:37:08 +00:00
|
|
|
}
|