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
|
|
|
|
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
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
|
|
|
|
#include "VideoBackends/Software/Clipper.h"
|
|
|
|
#include "VideoBackends/Software/DebugUtil.h"
|
2015-10-09 12:50:36 -06:00
|
|
|
#include "VideoBackends/Software/EfbCopy.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#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"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoBackends/Software/SWVertexLoader.h"
|
|
|
|
#include "VideoBackends/Software/VideoBackend.h"
|
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
#include "VideoCommon/FramebufferManagerBase.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/OnScreenDisplay.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
|
|
|
|
2012-12-17 13:54:20 -07:00
|
|
|
#define VSYNC_ENABLED 0
|
|
|
|
|
2011-01-30 18:28:32 -07:00
|
|
|
namespace SW
|
2010-06-08 19:37:08 -06:00
|
|
|
{
|
2015-10-09 12:50:36 -06:00
|
|
|
class PerfQuery : public PerfQueryBase
|
2010-06-08 19:37:08 -06:00
|
|
|
{
|
2015-10-09 12:50:36 -06:00
|
|
|
public:
|
2016-06-24 02:43:46 -06: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));
|
|
|
|
}
|
|
|
|
u32 GetQueryResult(PerfQueryType type) override { return EfbInterface::perf_values[type]; };
|
|
|
|
void FlushResults() override {}
|
|
|
|
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
|
|
|
class TextureCache : public TextureCacheBase
|
2010-06-08 19:37:08 -06:00
|
|
|
{
|
2015-10-09 12:50:36 -06:00
|
|
|
public:
|
2016-08-13 06:56:01 -06:00
|
|
|
bool CompileShaders() override { return true; }
|
|
|
|
void DeleteShaders() override {}
|
2016-06-24 02:43:46 -06:00
|
|
|
void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette,
|
2016-08-13 06:56:01 -06:00
|
|
|
TlutFormat format) override
|
|
|
|
{
|
|
|
|
}
|
2017-04-04 07:55:36 -06:00
|
|
|
void CopyEFB(u8* dst, const EFBCopyFormat& format, u32 native_width, u32 bytes_per_row,
|
|
|
|
u32 num_blocks_y, u32 memory_stride, bool is_depth_copy,
|
|
|
|
const EFBRectangle& src_rect, bool scale_by_half) override
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
EfbCopy::CopyEfb();
|
|
|
|
}
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
private:
|
2016-06-24 02:43:46 -06:00
|
|
|
struct TCacheEntry : TCacheEntryBase
|
|
|
|
{
|
|
|
|
TCacheEntry(const TCacheEntryConfig& _config) : TCacheEntryBase(_config) {}
|
|
|
|
~TCacheEntry() {}
|
2016-09-06 16:57:58 -06:00
|
|
|
void Load(const u8* buffer, u32 width, u32 height, u32 expanded_width, u32 level) override {}
|
2016-12-26 13:33:57 -07:00
|
|
|
void FromRenderTarget(bool is_depth_copy, const EFBRectangle& srcRect, bool scaleByHalf,
|
|
|
|
unsigned int cbufid, const float* colmat) override
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
EfbCopy::CopyEfb();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyRectangleFromTexture(const TCacheEntryBase* source,
|
|
|
|
const MathUtil::Rectangle<int>& srcrect,
|
|
|
|
const MathUtil::Rectangle<int>& dstrect) override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bind(unsigned int stage) override {}
|
|
|
|
bool Save(const std::string& filename, unsigned int level) override { return false; }
|
|
|
|
};
|
|
|
|
|
|
|
|
TCacheEntryBase* CreateTexture(const TCacheEntryConfig& config) override
|
|
|
|
{
|
|
|
|
return new TCacheEntry(config);
|
|
|
|
}
|
2015-10-09 12:50:36 -06:00
|
|
|
};
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
class XFBSource : public XFBSourceBase
|
2011-02-08 04:02:34 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight) override {}
|
|
|
|
void CopyEFB(float Gamma) override {}
|
2015-10-09 12:50:36 -06:00
|
|
|
};
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
class FramebufferManager : public FramebufferManagerBase
|
2010-06-24 14:54:03 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
|
|
|
unsigned int target_height,
|
|
|
|
unsigned int layers) override
|
|
|
|
{
|
|
|
|
return std::make_unique<XFBSource>();
|
|
|
|
}
|
2017-02-03 10:31:20 -07:00
|
|
|
|
|
|
|
std::pair<u32, u32> GetTargetSize() const override { return std::make_pair(0, 0); }
|
2016-06-24 02:43:46 -06:00
|
|
|
void CopyToRealXFB(u32 xfbAddr, u32 fbStride, u32 fbHeight, const EFBRectangle& sourceRc,
|
|
|
|
float Gamma = 1.0f) override
|
|
|
|
{
|
|
|
|
EfbCopy::CopyEfb();
|
|
|
|
}
|
2015-10-09 12:50:36 -06:00
|
|
|
};
|
2013-04-12 23:48:53 -06:00
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
std::string VideoSoftware::GetName() const
|
2013-02-26 08:42:32 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
return "Software Renderer";
|
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
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
return "Software Renderer";
|
2010-06-08 19:37:08 -06:00
|
|
|
}
|
|
|
|
|
2016-01-13 13:38:11 -07:00
|
|
|
void VideoSoftware::InitBackendInfo()
|
2013-10-28 23:23:17 -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;
|
2016-06-24 02:43:46 -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-10 06:26:57 -07:00
|
|
|
g_Config.backend_info.bSupportsInternalResolutionFrameDumps = false;
|
2016-11-27 01:14:57 -07:00
|
|
|
g_Config.backend_info.bSupportsGPUTextureDecoding = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// aamodes
|
|
|
|
g_Config.backend_info.AAModes = {1};
|
2010-06-08 19:37:08 -06:00
|
|
|
}
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool VideoSoftware::Initialize(void* window_handle)
|
2010-06-08 19:37:08 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
InitBackendInfo();
|
2016-01-13 13:14:20 -07:00
|
|
|
InitializeShared();
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
SWOGLWindow::Init(window_handle);
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
Clipper::Init();
|
|
|
|
Rasterizer::Init();
|
|
|
|
SWRenderer::Init();
|
|
|
|
DebugUtil::Init();
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
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
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
SWOGLWindow::Shutdown();
|
2016-01-13 13:14:20 -07:00
|
|
|
|
|
|
|
ShutdownShared();
|
2013-08-20 05:51:39 -06:00
|
|
|
}
|
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
void VideoSoftware::Video_Cleanup()
|
2010-06-08 19:37:08 -06:00
|
|
|
{
|
2016-01-13 13:14:20 -07: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-08 19:37:08 -06:00
|
|
|
}
|
|
|
|
|
2015-10-09 12:50:36 -06:00
|
|
|
// This is called after Video_Initialize() from the Core
|
|
|
|
void VideoSoftware::Video_Prepare()
|
2010-06-08 19:37:08 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06: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();
|
|
|
|
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
2014-02-02 06:16:43 -07:00
|
|
|
}
|
|
|
|
|
2011-03-16 16:48:17 -06:00
|
|
|
unsigned int VideoSoftware::PeekMessages()
|
2011-02-07 15:01:08 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
return SWOGLWindow::s_instance->PeekMessages();
|
2011-02-07 15:01:08 -07:00
|
|
|
}
|
2011-03-16 16:58:24 -06:00
|
|
|
}
|