From 4c9c8a7a4d9b97fec6041a562638fbea521533ed Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Fri, 14 Apr 2023 17:08:18 +0800 Subject: 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 --- tools/gfx/d3d11/d3d11-device.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tools/gfx/d3d11/d3d11-device.cpp') diff --git a/tools/gfx/d3d11/d3d11-device.cpp b/tools/gfx/d3d11/d3d11-device.cpp index cc2eda089..e6a348dc1 100644 --- a/tools/gfx/d3d11/d3d11-device.cpp +++ b/tools/gfx/d3d11/d3d11-device.cpp @@ -46,15 +46,20 @@ SlangResult DeviceImpl::initialize(const Desc& desc) m_desc = desc; // Rather than statically link against D3D, we load it dynamically. - HMODULE d3dModule = LoadLibraryA("d3d11.dll"); - if (!d3dModule) + SharedLibrary::Handle d3dModule; +#if SLANG_WINDOWS_FAMILY + const char* libName = "d3d11"; +#else + const char* libName = "dxvk_d3d11"; +#endif + if (SLANG_FAILED(SharedLibrary::load(libName, d3dModule))) { - fprintf(stderr, "error: failed load 'd3d11.dll'\n"); + fprintf(stderr, "error: failed to load '%s'\n", libName); return SLANG_FAIL; } PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN D3D11CreateDeviceAndSwapChain_ = - (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)GetProcAddress(d3dModule, "D3D11CreateDeviceAndSwapChain"); + (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)SharedLibrary::findSymbolAddressByName(d3dModule, "D3D11CreateDeviceAndSwapChain"); if (!D3D11CreateDeviceAndSwapChain_) { fprintf(stderr, @@ -63,7 +68,7 @@ SlangResult DeviceImpl::initialize(const Desc& desc) } PFN_D3D11_CREATE_DEVICE D3D11CreateDevice_ = - (PFN_D3D11_CREATE_DEVICE)GetProcAddress(d3dModule, "D3D11CreateDevice"); + (PFN_D3D11_CREATE_DEVICE)SharedLibrary::findSymbolAddressByName(d3dModule, "D3D11CreateDevice"); if (!D3D11CreateDevice_) { fprintf(stderr, -- cgit v1.2.3