2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:29:41 -06:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2017-09-09 13:52:35 -06:00
|
|
|
#include <cstring>
|
2015-10-09 12:50:36 -06:00
|
|
|
#include <memory>
|
2014-03-12 13:33:41 -06:00
|
|
|
#include <string>
|
2017-02-03 10:31:20 -07:00
|
|
|
#include <utility>
|
2014-03-12 13:33:41 -06:00
|
|
|
|
2018-06-30 02:53:24 -06:00
|
|
|
#include "Common/Common.h"
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2018-10-03 07:02:45 -06:00
|
|
|
#include "Common/GL/GLContext.h"
|
2019-02-14 18:59:50 -07:00
|
|
|
#include "Common/MsgHandler.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
|
|
|
|
#include "VideoBackends/Software/Clipper.h"
|
|
|
|
#include "VideoBackends/Software/DebugUtil.h"
|
|
|
|
#include "VideoBackends/Software/EfbInterface.h"
|
|
|
|
#include "VideoBackends/Software/Rasterizer.h"
|
2015-09-26 02:07:48 -06:00
|
|
|
#include "VideoBackends/Software/SWOGLWindow.h"
|
2014-02-19 04:14:09 -07:00
|
|
|
#include "VideoBackends/Software/SWRenderer.h"
|
2017-04-22 22:44:34 -06:00
|
|
|
#include "VideoBackends/Software/SWTexture.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoBackends/Software/SWVertexLoader.h"
|
2017-05-29 16:02:09 -06:00
|
|
|
#include "VideoBackends/Software/TextureCache.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoBackends/Software/VideoBackend.h"
|
|
|
|
|
2019-02-14 18:59:50 -07:00
|
|
|
#include "VideoCommon/FramebufferManager.h"
|
2015-10-09 12:50:36 -06:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2016-07-21 17:04:57 -06:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2015-10-09 12:50:36 -06:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2011-01-30 18:28:32 -07:00
|
|
|
namespace SW
|
2009-10-11 18:48:24 -06:00
|
|
|
{
|
2015-10-09 12:50:36 -06:00
|
|
|
class PerfQuery : public PerfQueryBase
|
2009-10-11 18:48:24 -06:00
|
|
|
{
|
2015-10-09 12:50:36 -06:00
|
|
|
public:
|
|
|
|
PerfQuery() {}
|
|
|
|
~PerfQuery() {}
|
|
|
|
void EnableQuery(PerfQueryGroup type) override {}
|
|
|
|
void DisableQuery(PerfQueryGroup type) override {}
|
2018-05-18 13:13:03 -06:00
|
|
|
void ResetQuery() override { EfbInterface::ResetPerfQuery(); }
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override { return EfbInterface::GetPerfQueryResult(type); }
|
2015-10-09 12:50:36 -06:00
|
|
|
void FlushResults() override {}
|
2017-07-30 13:56:12 -06:00
|
|
|
bool IsFlushed() const override { return true; }
|
2015-10-09 12:50:36 -06:00
|
|
|
};
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
std::string VideoSoftware::GetName() const
|
2013-02-26 08:42:32 -07:00
|
|
|
{
|
2020-09-06 04:56:45 -06:00
|
|
|
return NAME;
|
2013-02-26 08:42:32 -07:00
|
|
|
}
|
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
std::string VideoSoftware::GetDisplayName() const
|
2012-12-17 13:54:20 -07:00
|
|
|
{
|
2018-06-30 02:53:24 -06:00
|
|
|
return _trans("Software Renderer");
|
2009-10-11 18:48:24 -06:00
|
|
|
}
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2019-07-20 16:57:50 -06:00
|
|
|
std::optional<std::string> VideoSoftware::GetWarningMessage() const
|
|
|
|
{
|
|
|
|
return _trans("The software renderer is significantly slower than other "
|
|
|
|
"backends and is only recommended for debugging purposes.\n\nDo you "
|
|
|
|
"really want to enable software rendering? If unsure, select 'No'.");
|
|
|
|
}
|
|
|
|
|
2016-01-13 13:38:11 -07:00
|
|
|
void VideoSoftware::InitBackendInfo()
|
2009-10-11 18:48:24 -06:00
|
|
|
{
|
2016-07-21 17:04:57 -06:00
|
|
|
g_Config.backend_info.api_type = APIType::Nothing;
|
2017-03-09 07:01:23 -07:00
|
|
|
g_Config.backend_info.MaxTextureSize = 16384;
|
2019-02-14 18:59:50 -07:00
|
|
|
g_Config.backend_info.bUsesLowerLeftOrigin = false;
|
2015-10-09 12:50:36 -06: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 06:08:46 -06:00
|
|
|
g_Config.backend_info.bSupportsMultithreading = false;
|
2016-11-27 01:14:55 -07:00
|
|
|
g_Config.backend_info.bSupportsComputeShaders = false;
|
2016-11-27 01:14:57 -07:00
|
|
|
g_Config.backend_info.bSupportsGPUTextureDecoding = false;
|
2017-04-16 03:30:11 -06:00
|
|
|
g_Config.backend_info.bSupportsST3CTextures = false;
|
2017-07-27 06:00:04 -06:00
|
|
|
g_Config.backend_info.bSupportsBPTCTextures = false;
|
2017-05-29 16:02:09 -06:00
|
|
|
g_Config.backend_info.bSupportsCopyToVram = false;
|
2019-02-14 18:59:50 -07:00
|
|
|
g_Config.backend_info.bSupportsLargePoints = false;
|
2020-05-24 00:11:10 -06:00
|
|
|
g_Config.backend_info.bSupportsDepthReadback = false;
|
2019-03-01 22:03:49 -07:00
|
|
|
g_Config.backend_info.bSupportsPartialDepthCopies = false;
|
2017-10-25 23:44:39 -06:00
|
|
|
g_Config.backend_info.bSupportsFramebufferFetch = false;
|
2018-02-25 00:56:09 -07:00
|
|
|
g_Config.backend_info.bSupportsBackgroundCompiling = false;
|
2018-05-25 08:04:18 -06:00
|
|
|
g_Config.backend_info.bSupportsLogicOp = true;
|
2019-04-15 05:55:26 -06:00
|
|
|
g_Config.backend_info.bSupportsShaderBinaries = false;
|
|
|
|
g_Config.backend_info.bSupportsPipelineCacheData = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
// aamodes
|
|
|
|
g_Config.backend_info.AAModes = {1};
|
2009-10-11 18:48:24 -06:00
|
|
|
}
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2018-10-03 07:03:22 -06:00
|
|
|
bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
|
2009-10-11 18:48:24 -06:00
|
|
|
{
|
2016-01-13 13:14:20 -07:00
|
|
|
InitializeShared();
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2018-10-03 07:03:26 -06:00
|
|
|
std::unique_ptr<SWOGLWindow> window = SWOGLWindow::Create(wsi);
|
|
|
|
if (!window)
|
|
|
|
return false;
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
Clipper::Init();
|
|
|
|
Rasterizer::Init();
|
|
|
|
DebugUtil::Init();
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2018-10-03 07:03:26 -06:00
|
|
|
g_renderer = std::make_unique<SWRenderer>(std::move(window));
|
2018-01-25 22:09:07 -07:00
|
|
|
g_vertex_manager = std::make_unique<SWVertexLoader>();
|
2019-02-14 18:59:50 -07:00
|
|
|
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
|
|
|
|
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
2018-01-25 22:09:07 -07:00
|
|
|
g_perf_query = std::make_unique<PerfQuery>();
|
|
|
|
g_texture_cache = std::make_unique<TextureCache>();
|
2019-02-14 18:59:50 -07:00
|
|
|
|
|
|
|
if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() ||
|
|
|
|
!g_renderer->Initialize() || !g_framebuffer_manager->Initialize() ||
|
|
|
|
!g_texture_cache->Initialize())
|
|
|
|
{
|
2020-12-02 11:17:27 -07:00
|
|
|
PanicAlertFmt("Failed to initialize renderer classes");
|
2019-02-14 18:59:50 -07:00
|
|
|
Shutdown();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_shader_cache->InitializeShaderCache();
|
|
|
|
return true;
|
2013-02-16 16:50:40 -07:00
|
|
|
}
|
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
void VideoSoftware::Shutdown()
|
2014-11-13 15:26:49 -07:00
|
|
|
{
|
2018-02-24 08:15:35 -07:00
|
|
|
if (g_shader_cache)
|
|
|
|
g_shader_cache->Shutdown();
|
|
|
|
|
2018-01-25 22:09:07 -07:00
|
|
|
if (g_renderer)
|
|
|
|
g_renderer->Shutdown();
|
2016-01-13 13:14:20 -07:00
|
|
|
|
|
|
|
DebugUtil::Shutdown();
|
|
|
|
g_texture_cache.reset();
|
|
|
|
g_perf_query.reset();
|
2019-02-14 18:59:50 -07:00
|
|
|
g_framebuffer_manager.reset();
|
|
|
|
g_shader_cache.reset();
|
2016-01-13 13:14:20 -07:00
|
|
|
g_vertex_manager.reset();
|
|
|
|
g_renderer.reset();
|
2018-01-25 22:09:07 -07:00
|
|
|
ShutdownShared();
|
2014-02-02 06:16:43 -07:00
|
|
|
}
|
2018-10-03 07:02:45 -06:00
|
|
|
} // namespace SW
|