diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-04-14 17:08:18 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-14 17:08:18 +0800 |
| commit | 4c9c8a7a4d9b97fec6041a562638fbea521533ed (patch) | |
| tree | bcbe353f9c3a64ce7e7e5419c4172a5fadac297b /tools/gfx/d3d/d3d-util.cpp | |
| parent | 5a629b3ccd801a1f0647e971d01481c55d3381c2 (diff) | |
Some small fixes with Windows/DX usage (#2797)
* Correct case of windows.h includes
* Use Slang::SharedLibrary to load directx dlls
* s/max/std::max/
* Factor common OS code in calcHasApi
* Add DXIL test for compute/simple
* s/false/FALSE for calls to WinAPI functions
* Factor common OS code in gfxGetAdapters
* 2 missing headers
d3d12sdklayers for ID3DDebug
climits for UINT_MAX
* Define out unused function on Linux
* Only try to load Vulkan and CUDA on Windows or Linux
* simplify D3DUtil::getDxgiModule
* Remove WIN32_LEAN_AND_MEAN &co from source files
Add a global define
* Set WIN32_LEAN_AND_MEAN &friends in headers
Restore previous state also
* regenerate vs projects
Diffstat (limited to 'tools/gfx/d3d/d3d-util.cpp')
| -rw-r--r-- | tools/gfx/d3d/d3d-util.cpp | 28 |
1 files changed, 18 insertions, 10 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"); |
