From ac1cd8279b40a78f99e3d278b04f36a6f23e8529 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 5 Mar 2016 21:15:48 +1000 Subject: D3D12: Implement GPU-based bounding box --- Source/Core/VideoBackends/D3D12/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/D3D12/main.cpp') diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp index 8b045ba5b7..636723458a 100644 --- a/Source/Core/VideoBackends/D3D12/main.cpp +++ b/Source/Core/VideoBackends/D3D12/main.cpp @@ -116,7 +116,7 @@ void InitBackendInfo() g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported; // Requires full UAV functionality (only available in shader model 5) - g_Config.backend_info.bSupportsBBox = false; + g_Config.backend_info.bSupportsBBox = shader_model_5_supported; // Requires the instance attribute (only available in shader model 5) g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported; -- cgit v1.2.3 From 3372bfa6ab72c38763ed5b37dcb0fe6a9068a7eb Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 6 Mar 2016 18:45:57 +1000 Subject: D3D12: Remove feature level checks We don't create a device below feature level 11_0 anyway, so no point checking, we can just assume support. --- Source/Core/VideoBackends/D3D12/main.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoBackends/D3D12/main.cpp') diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp index 636723458a..1f75854a33 100644 --- a/Source/Core/VideoBackends/D3D12/main.cpp +++ b/Source/Core/VideoBackends/D3D12/main.cpp @@ -110,19 +110,17 @@ void InitBackendInfo() g_Config.backend_info.AAModes.push_back(modes[i].Count); } - bool shader_model_5_supported = (DX12::D3D::GetFeatureLevel(ad) >= D3D_FEATURE_LEVEL_11_0); - // Requires the earlydepthstencil attribute (only available in shader model 5) - g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported; + g_Config.backend_info.bSupportsEarlyZ = true; // Requires full UAV functionality (only available in shader model 5) - g_Config.backend_info.bSupportsBBox = shader_model_5_supported; + g_Config.backend_info.bSupportsBBox = true; // Requires the instance attribute (only available in shader model 5) - g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported; + g_Config.backend_info.bSupportsGSInstancing = true; // Sample shading requires shader model 5 - g_Config.backend_info.bSupportsSSAA = shader_model_5_supported; + g_Config.backend_info.bSupportsSSAA = true; } g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description)); ad->Release(); -- cgit v1.2.3 From 6f3573dda87d2796a031fb7afc5ac1cecbb7ee2f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 6 Mar 2016 18:48:35 +1000 Subject: D3D12: Implement XFB encoding/decoding (support Real XFB) --- Source/Core/VideoBackends/D3D12/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Source/Core/VideoBackends/D3D12/main.cpp') diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp index 1f75854a33..3cd04ba656 100644 --- a/Source/Core/VideoBackends/D3D12/main.cpp +++ b/Source/Core/VideoBackends/D3D12/main.cpp @@ -23,6 +23,7 @@ #include "VideoBackends/D3D12/TextureCache.h" #include "VideoBackends/D3D12/VertexManager.h" #include "VideoBackends/D3D12/VideoBackend.h" +#include "VideoBackends/D3D12/XFBEncoder.h" #include "VideoCommon/BPStructs.h" #include "VideoCommon/CommandProcessor.h" @@ -179,6 +180,7 @@ void VideoBackend::Video_Prepare() g_texture_cache = std::make_unique(); g_vertex_manager = std::make_unique(); g_perf_query = std::make_unique(); + g_xfb_encoder = std::make_unique(); ShaderCache::Init(); ShaderConstantsManager::Init(); StaticShaderCache::Init(); @@ -228,6 +230,7 @@ void VideoBackend::Shutdown() StaticShaderCache::Shutdown(); BBox::Shutdown(); + g_xfb_encoder.reset(); g_perf_query.reset(); g_vertex_manager.reset(); g_texture_cache.reset(); -- cgit v1.2.3 From 9bff1875479c4b31e93350a44e25f6cb154894f1 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 7 Mar 2016 00:36:37 +1000 Subject: D3D12: Cleanup startup/shutdown process Sorts out references that cause some modules to be kept around after backend shutdown. Should also solve the issue with errors being thrown due to the config being loaded after device creation, leading to the incorrect device being used in a multi-adapter system. --- Source/Core/VideoBackends/D3D12/main.cpp | 66 ++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 25 deletions(-) (limited to 'Source/Core/VideoBackends/D3D12/main.cpp') diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp index 3cd04ba656..e67ea2777a 100644 --- a/Source/Core/VideoBackends/D3D12/main.cpp +++ b/Source/Core/VideoBackends/D3D12/main.cpp @@ -65,11 +65,14 @@ std::string VideoBackend::GetDisplayName() const void InitBackendInfo() { - HRESULT hr = DX12::D3D::LoadDXGI(); - if (SUCCEEDED(hr)) hr = DX12::D3D::LoadD3D(); + HRESULT hr = D3D::LoadDXGI(); + if (FAILED(hr)) + return; + + hr = D3D::LoadD3D(); if (FAILED(hr)) { - DX12::D3D::UnloadDXGI(); + D3D::UnloadDXGI(); return; } @@ -86,9 +89,14 @@ void InitBackendInfo() IDXGIFactory* factory; IDXGIAdapter* ad; - hr = DX12::create_dxgi_factory(__uuidof(IDXGIFactory), (void**)&factory); + hr = create_dxgi_factory(__uuidof(IDXGIFactory), (void**)&factory); if (FAILED(hr)) + { PanicAlert("Failed to create IDXGIFactory object"); + D3D::UnloadD3D(); + D3D::UnloadDXGI(); + return; + } // adapters g_Config.backend_info.Adapters.clear(); @@ -103,26 +111,34 @@ void InitBackendInfo() // TODO: These don't get updated on adapter change, yet if (adapter_index == g_Config.iAdapter) { - std::string samples; - std::vector modes = DX12::D3D::EnumAAModes(ad); - // First iteration will be 1. This equals no AA. - for (unsigned int i = 0; i < modes.size(); ++i) + ID3D12Device* temp_device; + hr = d3d12_create_device(ad, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&temp_device)); + if (SUCCEEDED(hr)) { - g_Config.backend_info.AAModes.push_back(modes[i].Count); - } + std::string samples; + std::vector modes = D3D::EnumAAModes(temp_device); + // First iteration will be 1. This equals no AA. + for (unsigned int i = 0; i < modes.size(); ++i) + { + g_Config.backend_info.AAModes.push_back(modes[i].Count); + } + + // Requires the earlydepthstencil attribute (only available in shader model 5) + g_Config.backend_info.bSupportsEarlyZ = true; - // Requires the earlydepthstencil attribute (only available in shader model 5) - g_Config.backend_info.bSupportsEarlyZ = true; + // Requires full UAV functionality (only available in shader model 5) + g_Config.backend_info.bSupportsBBox = true; - // Requires full UAV functionality (only available in shader model 5) - g_Config.backend_info.bSupportsBBox = true; + // Requires the instance attribute (only available in shader model 5) + g_Config.backend_info.bSupportsGSInstancing = true; - // Requires the instance attribute (only available in shader model 5) - g_Config.backend_info.bSupportsGSInstancing = true; + // Sample shading requires shader model 5 + g_Config.backend_info.bSupportsSSAA = true; - // Sample shading requires shader model 5 - g_Config.backend_info.bSupportsSSAA = true; + temp_device->Release(); + } } + g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description)); ad->Release(); } @@ -132,8 +148,8 @@ void InitBackendInfo() g_Config.backend_info.PPShaders.clear(); g_Config.backend_info.AnaglyphShaders.clear(); - DX12::D3D::UnloadDXGI(); - DX12::D3D::UnloadD3D(); + D3D::UnloadD3D(); + D3D::UnloadDXGI(); } void VideoBackend::ShowConfig(void *hParent) @@ -144,11 +160,6 @@ void VideoBackend::ShowConfig(void *hParent) bool VideoBackend::Initialize(void *window_handle) { - bool d3d12_supported = D3D::AlertUserIfSelectedAdapterDoesNotSupportD3D12(); - - if (!d3d12_supported) - return false; - if (window_handle == nullptr) return false; @@ -167,6 +178,9 @@ bool VideoBackend::Initialize(void *window_handle) g_Config.VerifyValidity(); UpdateActiveConfig(); + if (FAILED(D3D::Create((HWND)window_handle))) + return false; + m_window_handle = window_handle; m_initialized = true; @@ -235,6 +249,8 @@ void VideoBackend::Shutdown() g_vertex_manager.reset(); g_texture_cache.reset(); g_renderer.reset(); + + D3D::Close(); } } -- cgit v1.2.3