Files
dolphin/Source/Core/VideoBackends/D3D/main.cpp
T

146 lines
4.7 KiB
C++
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
2015-05-18 01:08:10 +02:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
2010-06-13 19:50:06 +00:00
#include <memory>
2014-03-12 15:33:41 -04:00
#include <string>
2010-06-13 19:50:06 +00:00
#include "Common/Common.h"
2016-01-02 15:01:12 -05:00
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
2014-03-12 15:33:41 -04:00
#include "Common/StringUtil.h"
2010-06-13 19:50:06 +00:00
2014-12-04 23:01:20 -03:00
#include "VideoBackends/D3D/BoundingBox.h"
2014-02-17 05:18:15 -05:00
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/PerfQuery.h"
2016-01-02 15:01:12 -05:00
#include "VideoBackends/D3D/Render.h"
2019-03-09 23:31:36 +10:00
#include "VideoBackends/D3D/SwapChain.h"
2014-02-17 05:18:15 -05:00
#include "VideoBackends/D3D/VertexManager.h"
#include "VideoBackends/D3D/VideoBackend.h"
2019-03-09 23:31:36 +10:00
#include "VideoBackends/D3DCommon/Common.h"
2011-01-25 16:43:08 +00:00
#include "VideoCommon/FramebufferManager.h"
2018-02-25 01:15:35 +10:00
#include "VideoCommon/ShaderCache.h"
#include "VideoCommon/TextureCacheBase.h"
2016-07-21 19:04:57 -04:00
#include "VideoCommon/VideoCommon.h"
2014-02-17 05:18:15 -05:00
#include "VideoCommon/VideoConfig.h"
2010-06-13 19:50:06 +00:00
namespace DX11
{
2014-03-13 00:39:55 +01:00
std::string VideoBackend::GetName() const
{
return "D3D";
}
2014-03-13 00:39:55 +01:00
std::string VideoBackend::GetDisplayName() const
2010-06-13 19:50:06 +00:00
{
return _trans("Direct3D 11");
2010-06-13 19:50:06 +00:00
}
2016-01-13 21:38:11 +01:00
void VideoBackend::InitBackendInfo()
{
2019-03-09 23:31:36 +10:00
if (!D3DCommon::LoadLibraries())
return;
2019-03-09 23:31:36 +10:00
FillBackendInfo();
D3DCommon::UnloadLibraries();
}
void VideoBackend::FillBackendInfo()
{
2016-07-21 19:04:57 -04:00
g_Config.backend_info.api_type = APIType::D3D;
g_Config.backend_info.MaxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
g_Config.backend_info.bUsesLowerLeftOrigin = false;
g_Config.backend_info.bSupportsExclusiveFullscreen = true;
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsOversizedViewports = false;
g_Config.backend_info.bSupportsGeometryShaders = true;
g_Config.backend_info.bSupportsComputeShaders = false;
g_Config.backend_info.bSupports3DVision = true;
g_Config.backend_info.bSupportsPostProcessing = true;
g_Config.backend_info.bSupportsPaletteConversion = true;
g_Config.backend_info.bSupportsClipControl = true;
2016-08-05 22:31:34 +02:00
g_Config.backend_info.bSupportsDepthClamp = true;
g_Config.backend_info.bSupportsReversedDepthRange = false;
g_Config.backend_info.bSupportsLogicOp = true;
g_Config.backend_info.bSupportsMultithreading = false;
g_Config.backend_info.bSupportsGPUTextureDecoding = true;
g_Config.backend_info.bSupportsST3CTextures = false;
2017-05-29 17:02:09 -05:00
g_Config.backend_info.bSupportsCopyToVram = true;
g_Config.backend_info.bSupportsLargePoints = false;
g_Config.backend_info.bSupportsPartialDepthCopies = false;
2017-07-20 15:25:24 +10:00
g_Config.backend_info.bSupportsBitfield = false;
g_Config.backend_info.bSupportsDynamicSamplerIndexing = false;
g_Config.backend_info.bSupportsBPTCTextures = false;
2017-10-25 22:44:39 -07:00
g_Config.backend_info.bSupportsFramebufferFetch = false;
2018-02-25 17:56:09 +10:00
g_Config.backend_info.bSupportsBackgroundCompiling = true;
2019-03-09 23:31:36 +10:00
g_Config.backend_info.bSupportsST3CTextures = true;
g_Config.backend_info.bSupportsBPTCTextures = true;
g_Config.backend_info.bSupportsEarlyZ = true;
g_Config.backend_info.bSupportsBBox = true;
g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true;
g_Config.backend_info.bSupportsGSInstancing = true;
g_Config.backend_info.bSupportsSSAA = true;
g_Config.backend_info.bSupportsShaderBinaries = true;
g_Config.backend_info.bSupportsPipelineCacheData = false;
2019-03-09 23:31:36 +10:00
g_Config.backend_info.Adapters = D3DCommon::GetAdapterNames();
g_Config.backend_info.AAModes = D3D::GetAAModes(g_Config.iAdapter);
}
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
2010-06-13 19:50:06 +00:00
{
2019-03-09 23:31:36 +10:00
if (!D3D::Create(g_Config.iAdapter, g_Config.bEnableValidationLayer))
return false;
FillBackendInfo();
InitializeShared();
2010-06-13 19:50:06 +00:00
2019-03-09 23:31:36 +10:00
std::unique_ptr<SwapChain> swap_chain;
if (wsi.render_surface && !(swap_chain = SwapChain::Create(wsi)))
{
2019-03-09 23:31:36 +10:00
PanicAlertT("Failed to create D3D swap chain");
ShutdownShared();
D3D::Destroy();
return false;
}
2019-03-09 23:31:36 +10:00
g_renderer = std::make_unique<Renderer>(std::move(swap_chain), wsi.render_surface_scale);
g_vertex_manager = std::make_unique<VertexManager>();
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
g_framebuffer_manager = std::make_unique<FramebufferManager>();
g_texture_cache = std::make_unique<TextureCacheBase>();
g_perf_query = std::make_unique<PerfQuery>();
if (!g_renderer->Initialize() || !g_vertex_manager->Initialize() ||
!g_shader_cache->Initialize() || !g_framebuffer_manager->Initialize() ||
!g_texture_cache->Initialize())
{
2019-03-09 23:31:36 +10:00
Shutdown();
2018-02-25 01:15:35 +10:00
return false;
}
2018-02-25 01:15:35 +10:00
2016-06-27 12:45:00 +02:00
BBox::Init();
g_shader_cache->InitializeShaderCache();
2018-11-28 14:30:47 +10:00
return true;
2010-06-13 19:50:06 +00:00
}
void VideoBackend::Shutdown()
2010-06-13 19:50:06 +00:00
{
2018-02-25 01:15:35 +10:00
g_shader_cache->Shutdown();
g_renderer->Shutdown();
BBox::Shutdown();
2010-07-18 10:11:34 +00:00
g_perf_query.reset();
g_texture_cache.reset();
g_framebuffer_manager.reset();
2018-02-25 01:15:35 +10:00
g_shader_cache.reset();
g_vertex_manager.reset();
g_renderer.reset();
2014-12-04 23:01:20 -03:00
ShutdownShared();
2019-03-09 23:31:36 +10:00
D3D::Destroy();
2013-02-26 16:42:32 +01:00
}
} // namespace DX11