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-09-09 19:52:35 +00:00
|
|
|
#include <cstring>
|
2015-10-09 18:50:36 +00:00
|
|
|
#include <memory>
|
2014-03-12 19:33:41 +00:00
|
|
|
#include <string>
|
2017-02-03 17:31:20 +00:00
|
|
|
#include <utility>
|
2014-03-12 19:33:41 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2017-05-29 22:02:09 +00:00
|
|
|
#include "Common/GL/GLInterfaceBase.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
|
|
|
|
#include "VideoBackends/Software/Clipper.h"
|
|
|
|
#include "VideoBackends/Software/DebugUtil.h"
|
|
|
|
#include "VideoBackends/Software/EfbInterface.h"
|
|
|
|
#include "VideoBackends/Software/Rasterizer.h"
|
2015-09-26 08:07:48 +00:00
|
|
|
#include "VideoBackends/Software/SWOGLWindow.h"
|
2014-02-19 11:14:09 +00:00
|
|
|
#include "VideoBackends/Software/SWRenderer.h"
|
2017-04-23 04:44:34 +00:00
|
|
|
#include "VideoBackends/Software/SWTexture.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/Software/SWVertexLoader.h"
|
2017-05-29 22:02:09 +00:00
|
|
|
#include "VideoBackends/Software/TextureCache.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/Software/VideoBackend.h"
|
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "VideoCommon/FramebufferManagerBase.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2016-07-21 23:04:57 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2010-06-09 01:37:08 +00:00
|
|
|
|
2012-12-17 20:54:20 +00:00
|
|
|
#define VSYNC_ENABLED 0
|
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
namespace SW
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
2015-10-09 18:50:36 +00:00
|
|
|
class PerfQuery : public PerfQueryBase
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
2015-10-09 18:50:36 +00:00
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
PerfQuery() {}
|
|
|
|
~PerfQuery() {}
|
|
|
|
void EnableQuery(PerfQueryGroup type) override {}
|
|
|
|
void DisableQuery(PerfQueryGroup type) override {}
|
|
|
|
void ResetQuery() override
|
|
|
|
{
|
|
|
|
memset(EfbInterface::perf_values, 0, sizeof(EfbInterface::perf_values));
|
|
|
|
}
|
2017-07-30 19:56:12 +00:00
|
|
|
u32 GetQueryResult(PerfQueryType type) override { return EfbInterface::perf_values[type]; }
|
2016-06-24 08:43:46 +00:00
|
|
|
void FlushResults() override {}
|
2017-07-30 19:56:12 +00:00
|
|
|
bool IsFlushed() const override { return true; }
|
2015-10-09 18:50:36 +00:00
|
|
|
};
|
2010-06-09 01:37:08 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
std::string VideoSoftware::GetName() const
|
2013-02-26 15:42:32 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return "Software Renderer";
|
2013-02-26 15:42:32 +00:00
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
std::string VideoSoftware::GetDisplayName() const
|
2012-12-17 20:54:20 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return "Software Renderer";
|
2010-06-09 01:37:08 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 20:38:11 +00:00
|
|
|
void VideoSoftware::InitBackendInfo()
|
2013-10-29 05:23:17 +00:00
|
|
|
{
|
2016-07-21 23:04:57 +00:00
|
|
|
g_Config.backend_info.api_type = APIType::Nothing;
|
2017-03-09 14:01:23 +00:00
|
|
|
g_Config.backend_info.MaxTextureSize = 16384;
|
2016-06-24 08:43:46 +00:00
|
|
|
g_Config.backend_info.bSupports3DVision = false;
|
|
|
|
g_Config.backend_info.bSupportsDualSourceBlend = true;
|
|
|
|
g_Config.backend_info.bSupportsEarlyZ = true;
|
|
|
|
g_Config.backend_info.bSupportsOversizedViewports = true;
|
|
|
|
g_Config.backend_info.bSupportsPrimitiveRestart = false;
|
2016-08-13 12:08:46 +00:00
|
|
|
g_Config.backend_info.bSupportsMultithreading = false;
|
2016-11-27 08:14:55 +00:00
|
|
|
g_Config.backend_info.bSupportsComputeShaders = false;
|
2016-11-10 13:26:57 +00:00
|
|
|
g_Config.backend_info.bSupportsInternalResolutionFrameDumps = false;
|
2016-11-27 08:14:57 +00:00
|
|
|
g_Config.backend_info.bSupportsGPUTextureDecoding = false;
|
2017-04-16 09:30:11 +00:00
|
|
|
g_Config.backend_info.bSupportsST3CTextures = false;
|
2017-07-27 12:00:04 +00:00
|
|
|
g_Config.backend_info.bSupportsBPTCTextures = false;
|
2017-05-29 22:02:09 +00:00
|
|
|
g_Config.backend_info.bSupportsCopyToVram = false;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
// aamodes
|
|
|
|
g_Config.backend_info.AAModes = {1};
|
2010-06-09 01:37:08 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
bool VideoSoftware::Initialize(void* window_handle)
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
InitBackendInfo();
|
2016-01-13 20:14:20 +00:00
|
|
|
InitializeShared();
|
2013-04-14 03:54:02 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
SWOGLWindow::Init(window_handle);
|
2013-04-14 03:54:02 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
Clipper::Init();
|
|
|
|
Rasterizer::Init();
|
|
|
|
SWRenderer::Init();
|
|
|
|
DebugUtil::Init();
|
2013-04-14 03:54:02 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
return true;
|
2013-02-16 23:50:40 +00:00
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
void VideoSoftware::Shutdown()
|
2014-11-13 22:26:49 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SWOGLWindow::Shutdown();
|
2016-01-13 20:14:20 +00:00
|
|
|
|
|
|
|
ShutdownShared();
|
2013-08-20 11:51:39 +00:00
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
void VideoSoftware::Video_Cleanup()
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
2016-01-13 20:14:20 +00:00
|
|
|
CleanupShared();
|
|
|
|
|
|
|
|
SWRenderer::Shutdown();
|
|
|
|
DebugUtil::Shutdown();
|
|
|
|
// The following calls are NOT Thread Safe
|
|
|
|
// And need to be called from the video thread
|
|
|
|
SWRenderer::Shutdown();
|
|
|
|
g_framebuffer_manager.reset();
|
|
|
|
g_texture_cache.reset();
|
|
|
|
g_perf_query.reset();
|
|
|
|
g_vertex_manager.reset();
|
|
|
|
g_renderer.reset();
|
2010-06-09 01:37:08 +00:00
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
// This is called after Video_Initialize() from the Core
|
|
|
|
void VideoSoftware::Video_Prepare()
|
2010-06-09 01:37:08 +00:00
|
|
|
{
|
2017-05-29 22:02:09 +00:00
|
|
|
GLInterface->MakeCurrent();
|
|
|
|
SWOGLWindow::s_instance->Prepare();
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
g_renderer = std::make_unique<SWRenderer>();
|
|
|
|
g_vertex_manager = std::make_unique<SWVertexLoader>();
|
|
|
|
g_perf_query = std::make_unique<PerfQuery>();
|
|
|
|
g_texture_cache = std::make_unique<TextureCache>();
|
|
|
|
SWRenderer::Init();
|
2014-02-02 13:16:43 +00:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:48:17 +00:00
|
|
|
unsigned int VideoSoftware::PeekMessages()
|
2011-02-07 22:01:08 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return SWOGLWindow::s_instance->PeekMessages();
|
2011-02-07 22:01:08 +00:00
|
|
|
}
|
2011-03-16 22:58:24 +00:00
|
|
|
}
|