From cc7f5c4bb1fd95c53e437427940cf5c394c53e97 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 28 Nov 2018 18:34:05 +0100 Subject: [PATCH] [d3d11] Duplicate format table into D3D11 device Removes the direct D3D11Device->DXGIAdapter dependency. --- src/d3d11/d3d11_device.cpp | 22 +++++++--------------- src/d3d11/d3d11_device.h | 2 +- src/d3d11/meson.build | 6 +++++- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 6dd1d55d..e62b53f0 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -103,15 +103,9 @@ namespace dxvk { m_featureFlags (FeatureFlags), m_dxvkDevice (pDxgiDevice->GetDXVKDevice()), m_dxvkAdapter (m_dxvkDevice->adapter()), + m_d3d11Formats (m_dxvkAdapter), m_d3d11Options (m_dxvkAdapter->instance()->config()), m_dxbcOptions (m_dxvkDevice, m_d3d11Options) { - Com adapter; - - if (FAILED(pDxgiDevice->GetAdapter(&adapter)) - || FAILED(adapter->QueryInterface(__uuidof(IDXGIVkAdapter), - reinterpret_cast(&m_dxgiAdapter)))) - throw DxvkError("D3D11Device: Failed to query adapter"); - m_initializer = new D3D11Initializer(m_dxvkDevice); m_context = new D3D11ImmediateContext(this, m_dxvkDevice); m_d3d10Device = new D3D10Device(this, m_context); @@ -512,8 +506,7 @@ namespace dxvk { DxvkVertexAttribute attrib; attrib.location = entry != nullptr ? entry->registerId : 0; attrib.binding = pInputElementDescs[i].InputSlot; - attrib.format = m_dxgiAdapter->LookupFormat( - pInputElementDescs[i].Format, DXGI_VK_FORMAT_MODE_COLOR).Format; + attrib.format = LookupFormat(pInputElementDescs[i].Format, DXGI_VK_FORMAT_MODE_COLOR).Format; attrib.offset = pInputElementDescs[i].AlignedByteOffset; // The application may choose to let the implementation @@ -1135,8 +1128,7 @@ namespace dxvk { *pNumQualityLevels = 0; // We need to check whether the format is - VkFormat format = m_dxgiAdapter->LookupFormat( - Format, DXGI_VK_FORMAT_MODE_ANY).Format; + VkFormat format = LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY).Format; if (format == VK_FORMAT_UNDEFINED) { Logger::err(str::format("D3D11: Unsupported format: ", Format)); @@ -1360,14 +1352,14 @@ namespace dxvk { DXGI_VK_FORMAT_INFO D3D11Device::LookupFormat( DXGI_FORMAT Format, DXGI_VK_FORMAT_MODE Mode) const { - return m_dxgiAdapter->LookupFormat(Format, Mode); + return m_d3d11Formats.GetFormatInfo(Format, Mode); } DXGI_VK_FORMAT_FAMILY D3D11Device::LookupFamily( DXGI_FORMAT Format, DXGI_VK_FORMAT_MODE Mode) const { - return m_dxgiAdapter->LookupFormatFamily(Format, Mode); + return m_d3d11Formats.GetFormatFamily(Format, Mode); } @@ -1560,7 +1552,7 @@ namespace dxvk { HRESULT D3D11Device::GetFormatSupportFlags(DXGI_FORMAT Format, UINT* pFlags1, UINT* pFlags2) const { // Query some general information from DXGI, DXVK and Vulkan about the format - const DXGI_VK_FORMAT_INFO fmtMapping = m_dxgiAdapter->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY); + const DXGI_VK_FORMAT_INFO fmtMapping = LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY); const VkFormatProperties fmtSupport = m_dxvkAdapter->formatProperties(fmtMapping.Format); const DxvkFormatInfo* fmtProperties = imageFormatInfo(fmtMapping.Format); @@ -1608,7 +1600,7 @@ namespace dxvk { if (fmtSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT || fmtSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { - const VkFormat depthFormat = m_dxgiAdapter->LookupFormat(Format, DXGI_VK_FORMAT_MODE_DEPTH).Format; + const VkFormat depthFormat = LookupFormat(Format, DXGI_VK_FORMAT_MODE_DEPTH).Format; if (GetImageTypeSupport(fmtMapping.Format, VK_IMAGE_TYPE_1D)) flags1 |= D3D11_FORMAT_SUPPORT_TEXTURE1D; if (GetImageTypeSupport(fmtMapping.Format, VK_IMAGE_TYPE_2D)) flags1 |= D3D11_FORMAT_SUPPORT_TEXTURE2D; diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index 0fe46678..718d33ce 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -363,7 +363,6 @@ namespace dxvk { private: IDXGIObject* m_container; - Com m_dxgiAdapter; const D3D_FEATURE_LEVEL m_featureLevel; const UINT m_featureFlags; @@ -371,6 +370,7 @@ namespace dxvk { const Rc m_dxvkDevice; const Rc m_dxvkAdapter; + const DXGIVkFormatTable m_d3d11Formats; const D3D11Options m_d3d11Options; const DxbcOptions m_dxbcOptions; diff --git a/src/d3d11/meson.build b/src/d3d11/meson.build index 5e2149cb..a604e687 100644 --- a/src/d3d11/meson.build +++ b/src/d3d11/meson.build @@ -1,3 +1,7 @@ +dxgi_common_src = [ + '../dxgi/dxgi_format.cpp', +] + d3d10_src = [ '../d3d10/d3d10_blend.cpp', '../d3d10/d3d10_buffer.cpp', @@ -48,7 +52,7 @@ d3d11_src = [ 'd3d11_view_uav.cpp', ] -d3d11_dll = shared_library('d3d11'+dll_ext, d3d11_src + d3d10_src, glsl_generator.process(dxgi_shaders), +d3d11_dll = shared_library('d3d11'+dll_ext, dxgi_common_src + d3d11_src + d3d10_src, glsl_generator.process(dxgi_shaders), name_prefix : '', dependencies : [ lib_dxgi, dxbc_dep, dxvk_dep ], include_directories : dxvk_include_path,