diff options
Diffstat (limited to 'tools/gfx/d3d')
| -rw-r--r-- | tools/gfx/d3d/d3d-util.cpp | 28 | ||||
| -rw-r--r-- | tools/gfx/d3d/d3d-util.h | 7 |
2 files changed, 22 insertions, 13 deletions
diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp index 05a948773..eece71c16 100644 --- a/tools/gfx/d3d/d3d-util.cpp +++ b/tools/gfx/d3d/d3d-util.cpp @@ -10,6 +10,7 @@ #include <stdio.h> #include "core/slang-basic.h" +#include "core/slang-platform.h" namespace gfx { using namespace Slang; @@ -498,15 +499,22 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) } } -/* static */HMODULE D3DUtil::getDxgiModule() +/* static */SharedLibrary::Handle D3DUtil::getDxgiModule() { - static HMODULE s_dxgiModule = LoadLibraryA("dxgi.dll"); - if (!s_dxgiModule) - { - fprintf(stderr, "error: failed load 'dxgi.dll'\n"); - return nullptr; - } - +#if SLANG_WINDOWS_FAMILY + const char* const libPath = "dxgi"; +#else + const char* const libPath = "dxvk_dxgi"; +#endif + static SharedLibrary::Handle s_dxgiModule = [&](){ + SharedLibrary::Handle h = nullptr; + SharedLibrary::load(libPath, h); + if (!h) + { + fprintf(stderr, "error: failed to load dll '%s'\n", libPath); + } + return h; + }(); return s_dxgiModule; } @@ -522,7 +530,7 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) typedef HRESULT(WINAPI *PFN_DXGI_CREATE_FACTORY_2)(UINT Flags, REFIID riid, _COM_Outptr_ void **ppFactory); { - auto createFactory2 = (PFN_DXGI_CREATE_FACTORY_2)::GetProcAddress(dxgiModule, "CreateDXGIFactory2"); + auto createFactory2 = (PFN_DXGI_CREATE_FACTORY_2)SharedLibrary::findSymbolAddressByName(dxgiModule, "CreateDXGIFactory2"); if (createFactory2) { UINT dxgiFlags = 0; @@ -541,7 +549,7 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) } { - auto createFactory = (PFN_DXGI_CREATE_FACTORY)::GetProcAddress(dxgiModule, "CreateDXGIFactory"); + auto createFactory = (PFN_DXGI_CREATE_FACTORY)SharedLibrary::findSymbolAddressByName(dxgiModule, "CreateDXGIFactory"); if (!createFactory) { fprintf(stderr, "error: failed load symbol '%s'\n", "CreateDXGIFactory"); diff --git a/tools/gfx/d3d/d3d-util.h b/tools/gfx/d3d/d3d-util.h index 617ae4af2..1869d7de6 100644 --- a/tools/gfx/d3d/d3d-util.h +++ b/tools/gfx/d3d/d3d-util.h @@ -7,13 +7,14 @@ #include "slang-com-ptr.h" #include "core/slang-basic.h" +#include "core/slang-platform.h" #include "../flag-combiner.h" #include "slang-gfx.h" -#include <D3Dcommon.h> -#include <DXGIFormat.h> +#include <d3dcommon.h> +#include <dxgiformat.h> #include <dxgi.h> #include <d3d12.h> @@ -82,7 +83,7 @@ class D3DUtil static SlangResult createFactory(DeviceCheckFlags flags, Slang::ComPtr<IDXGIFactory>& outFactory); /// Get the dxgiModule - static HMODULE getDxgiModule(); + static Slang::SharedLibrary::Handle getDxgiModule(); /// Find adapters static SlangResult findAdapters(DeviceCheckFlags flags, const AdapterLUID* adapterLUID, IDXGIFactory* dxgiFactory, Slang::List<Slang::ComPtr<IDXGIAdapter>>& dxgiAdapters); |
