From 3697583f71e86e82b9f0f36f50c4b75ea1bd4f0b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 18 Mar 2020 21:23:54 +0100 Subject: [PATCH] [d3d10] Separate d3d10core from d3d10 This way we skip compiling and linking unnecessary garbage into the core library. --- src/d3d10/d3d10_core.cpp | 67 ++++++++++++++++++++++++++++++++++++++++ src/d3d10/d3d10_main.cpp | 56 ++------------------------------- src/d3d10/meson.build | 20 ++++++++---- 3 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 src/d3d10/d3d10_core.cpp diff --git a/src/d3d10/d3d10_core.cpp b/src/d3d10/d3d10_core.cpp new file mode 100644 index 000000000..d4d229ed8 --- /dev/null +++ b/src/d3d10/d3d10_core.cpp @@ -0,0 +1,67 @@ +#include +#include + +#include "../dxgi/dxgi_interfaces.h" + +extern "C" { + using namespace dxvk; + + HRESULT __stdcall D3D11CoreCreateDevice( + IDXGIFactory* pFactory, + IDXGIAdapter* pAdapter, + UINT Flags, + const D3D_FEATURE_LEVEL* pFeatureLevels, + UINT FeatureLevels, + ID3D11Device** ppDevice); + + + DLLEXPORT HRESULT __stdcall D3D10CoreCreateDevice( + IDXGIFactory* pFactory, + IDXGIAdapter* pAdapter, + UINT Flags, + D3D_FEATURE_LEVEL FeatureLevel, + ID3D10Device** ppDevice) { + InitReturnPtr(ppDevice); + + Com d3d11Device; + + HRESULT hr = pAdapter->CheckInterfaceSupport( + __uuidof(ID3D10Device), nullptr); + + if (FAILED(hr)) + return hr; + + hr = D3D11CoreCreateDevice(pFactory, pAdapter, + Flags, &FeatureLevel, 1, &d3d11Device); + + if (FAILED(hr)) + return hr; + + Com multithread; + d3d11Device->QueryInterface(__uuidof(ID3D10Multithread), reinterpret_cast(&multithread)); + multithread->SetMultithreadProtected(!(Flags & D3D10_CREATE_DEVICE_SINGLETHREADED)); + + Com dxvkDevice; + d3d11Device->QueryInterface(__uuidof(IDXGIDXVKDevice), reinterpret_cast(&dxvkDevice)); + dxvkDevice->SetAPIVersion(10); + + if (FAILED(d3d11Device->QueryInterface( + __uuidof(ID3D10Device), reinterpret_cast(ppDevice)))) + return E_FAIL; + + return S_OK; + } + + + UINT64 STDMETHODCALLTYPE D3D10CoreGetVersion() { + // Match the Windows 10 return value, but we + // don't know the exact function signature + return 0xa000100041770ull; + } + + + HRESULT STDMETHODCALLTYPE D3D10CoreRegisterLayers() { + return E_NOTIMPL; + } + +} diff --git a/src/d3d10/d3d10_main.cpp b/src/d3d10/d3d10_main.cpp index 6080aed82..7bec4d0be 100644 --- a/src/d3d10/d3d10_main.cpp +++ b/src/d3d10/d3d10_main.cpp @@ -12,52 +12,12 @@ namespace dxvk { extern "C" { using namespace dxvk; - HRESULT __stdcall D3D11CoreCreateDevice( - IDXGIFactory* pFactory, - IDXGIAdapter* pAdapter, - UINT Flags, - const D3D_FEATURE_LEVEL* pFeatureLevels, - UINT FeatureLevels, - ID3D11Device** ppDevice); - - - DLLEXPORT HRESULT __stdcall D3D10CoreCreateDevice( + HRESULT __stdcall D3D10CoreCreateDevice( IDXGIFactory* pFactory, IDXGIAdapter* pAdapter, UINT Flags, D3D_FEATURE_LEVEL FeatureLevel, - ID3D10Device** ppDevice) { - InitReturnPtr(ppDevice); - - Com d3d11Device; - - HRESULT hr = pAdapter->CheckInterfaceSupport( - __uuidof(ID3D10Device), nullptr); - - if (FAILED(hr)) - return hr; - - hr = D3D11CoreCreateDevice(pFactory, pAdapter, - Flags, &FeatureLevel, 1, &d3d11Device); - - if (FAILED(hr)) - return hr; - - Com multithread; - d3d11Device->QueryInterface(__uuidof(ID3D10Multithread), reinterpret_cast(&multithread)); - multithread->SetMultithreadProtected(!(Flags & D3D10_CREATE_DEVICE_SINGLETHREADED)); - - Com dxvkDevice; - d3d11Device->QueryInterface(__uuidof(IDXGIDXVKDevice), reinterpret_cast(&dxvkDevice)); - dxvkDevice->SetAPIVersion(10); - - if (FAILED(d3d11Device->QueryInterface( - __uuidof(ID3D10Device), reinterpret_cast(ppDevice)))) - return E_FAIL; - - return S_OK; - } - + ID3D10Device** ppDevice); static HRESULT D3D10InternalCreateDeviceAndSwapChain( IDXGIAdapter* pAdapter, @@ -361,13 +321,6 @@ extern "C" { } - UINT64 STDMETHODCALLTYPE D3D10CoreGetVersion() { - // Match the Windows 10 return value, but we - // don't know the exact function signature - return 0xa000100041770ull; - } - - UINT64 STDMETHODCALLTYPE D3D10GetVersion() { return 0xa000100041770ull; } @@ -377,11 +330,6 @@ extern "C" { return E_NOTIMPL; } - - HRESULT STDMETHODCALLTYPE D3D10CoreRegisterLayers() { - return E_NOTIMPL; - } - } diff --git a/src/d3d10/meson.build b/src/d3d10/meson.build index c3a0ab4d6..d1d8d6a6f 100644 --- a/src/d3d10/meson.build +++ b/src/d3d10/meson.build @@ -2,27 +2,35 @@ d3d10_res = wrc_generator.process('version10.rc') d3d10_1_res = wrc_generator.process('version10_1.rc') d3d10_core_res = wrc_generator.process('version10_core.rc') +d3d10_core_src = [ + 'd3d10_core.cpp', +] + d3d10_main_src = [ 'd3d10_main.cpp', 'd3d10_reflection.cpp', 'd3d10_state_block.cpp', ] -d3d10_deps = [ lib_d3dcompiler_43, lib_dxgi ] -d3d10_deps += dxvk_winelib ? lib_d3d11 : d3d11_dep +d3d10_d3d11_dep = dxvk_winelib ? lib_d3d11 : d3d11_dep -d3d10_core_dll = shared_library('d3d10core'+dll_ext, d3d10_main_src, d3d10_core_res, +d3d10_core_dll = shared_library('d3d10core'+dll_ext, d3d10_core_src, d3d10_core_res, name_prefix : '', - dependencies : [ d3d10_deps, dxbc_dep, dxvk_dep ], + dependencies : [ d3d10_d3d11_dep ], include_directories : dxvk_include_path, install : true, objects : not dxvk_msvc ? 'd3d10core'+def_spec_ext : [], vs_module_defs : 'd3d10core'+def_spec_ext, override_options : ['cpp_std='+dxvk_cpp_std]) +d3d10_core_dep = declare_dependency( + link_with : [ d3d10_core_dll ]) + +d3d10_deps = [ lib_d3dcompiler_43, lib_dxgi, dxbc_dep, dxvk_dep, d3d10_core_dep ] + d3d10_dll = shared_library('d3d10'+dll_ext, d3d10_main_src, d3d10_res, name_prefix : '', - dependencies : [ d3d10_deps, dxbc_dep, dxvk_dep ], + dependencies : [ d3d10_deps ], include_directories : dxvk_include_path, install : true, objects : not dxvk_msvc ? 'd3d10'+def_spec_ext : [], @@ -31,7 +39,7 @@ d3d10_dll = shared_library('d3d10'+dll_ext, d3d10_main_src, d3d10_res, d3d10_1_dll = shared_library('d3d10_1'+dll_ext, d3d10_main_src, d3d10_1_res, name_prefix : '', - dependencies : [ d3d10_deps, dxbc_dep, dxvk_dep ], + dependencies : [ d3d10_deps ], include_directories : dxvk_include_path, install : true, objects : not dxvk_msvc ? 'd3d10_1'+def_spec_ext : [],