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/d3d12/d3d12-device.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/d3d12/d3d12-device.cpp')
| -rw-r--r-- | tools/gfx/d3d12/d3d12-device.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp index 312c81d75..9bf54a01b 100644 --- a/tools/gfx/d3d12/d3d12-device.cpp +++ b/tools/gfx/d3d12/d3d12-device.cpp @@ -405,8 +405,13 @@ Result DeviceImpl::initialize(const Desc& desc) // Rather than statically link against D3D, we load it dynamically. - HMODULE d3dModule = LoadLibraryA("d3d12.dll"); - if (!d3dModule) + SharedLibrary::Handle d3dModule; +#if SLANG_WINDOWS_FAMILY + const char* libName = "d3d11"; +#else + const char* libName = "vkd3d-proton-d3d12"; +#endif + if (SLANG_FAILED(SharedLibrary::load(libName, d3dModule))) { getDebugCallback()->handleMessage( DebugMessageType::Error, DebugMessageSource::Layer, "error: failed load 'd3d12.dll'\n"); @@ -1990,7 +1995,7 @@ void DeviceImpl::submitResourceCommandsAndWait(const DeviceImpl::ResourceCommand m_resourceCommandTransientHeap->synchronizeAndReset(); } -void DeviceImpl::processExperimentalFeaturesDesc(void* d3dModule, void* inDesc) +void DeviceImpl::processExperimentalFeaturesDesc(SharedLibrary::Handle d3dModule, void* inDesc) { typedef HRESULT(WINAPI* PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)( UINT NumFeatures, @@ -2002,7 +2007,7 @@ void DeviceImpl::processExperimentalFeaturesDesc(void* d3dModule, void* inDesc) D3D12ExperimentalFeaturesDesc desc = {}; memcpy(&desc, inDesc, sizeof(desc)); auto enableExperimentalFeaturesFunc = - (PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)loadProc((HMODULE)d3dModule, "D3D12EnableExperimentalFeatures"); + (PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)loadProc(d3dModule, "D3D12EnableExperimentalFeatures"); if (!enableExperimentalFeaturesFunc) { getDebugCallback()->handleMessage( @@ -2173,9 +2178,9 @@ Result DeviceImpl::createCommandQueueImpl(CommandQueueImpl** outQueue) return SLANG_OK; } -PROC DeviceImpl::loadProc(HMODULE module, char const* name) +void* DeviceImpl::loadProc(SharedLibrary::Handle module, char const* name) { - PROC proc = ::GetProcAddress(module, name); + void* proc = SharedLibrary::findSymbolAddressByName(module, name); if (!proc) { fprintf(stderr, "error: failed load symbol '%s'\n", name); |
