From 0e052cfd8ecbb74204770ed872a701e64e75c38a Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 17 Jun 2019 12:08:44 -0400 Subject: Fix shared library loading for testing. (#986) * Fix shared library loading for testing. * Improve comments. --- source/core/slang-platform.h | 9 +++++++-- source/core/slang-render-api-util.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/core/slang-platform.h b/source/core/slang-platform.h index 31552e42b..c322d0568 100644 --- a/source/core/slang-platform.h +++ b/source/core/slang-platform.h @@ -15,7 +15,12 @@ namespace Slang typedef void(*FuncPtr)(void); - /// Load via an unadorned filename + /// Load via an unadorned filename. + /// + /// The unadorned filename here means without any platform specific filename elements. This typically means no extension and no prefix. + /// On windows this means without the '.dll' extension. + /// On linux this means without the 'lib' prefix and '.so' extension. + /// To load with a platform specific filename use the 'loadWithPlatformFilename' API /// /// @param the unadorned filename /// @return Returns a non null handle for the shared library on success. nullptr indicated failure @@ -42,7 +47,7 @@ namespace Slang /// The input name should be unadorned with any 'lib' prefix or extension static void appendPlatformFileName(const UnownedStringSlice& name, StringBuilder& dst); - /// Calculate the shared library + /// Given a path, calculate that path with the filename replaced with the platform filename (using appendPlatformFilename) static String calcPlatformPath(const UnownedStringSlice& path); private: diff --git a/source/core/slang-render-api-util.cpp b/source/core/slang-render-api-util.cpp index 3df971219..d8bcaf396 100644 --- a/source/core/slang-render-api-util.cpp +++ b/source/core/slang-render-api-util.cpp @@ -262,10 +262,10 @@ static bool _canLoadSharedLibrary(const char* libName) #if SLANG_WINDOWS_FAMILY switch (type) { - case RenderApiType::OpenGl: return _canLoadSharedLibrary("opengl32.dll"); - case RenderApiType::Vulkan: return _canLoadSharedLibrary("vulkan-1.dll"); - case RenderApiType::D3D11: return _canLoadSharedLibrary("d3d11.dll"); - case RenderApiType::D3D12: return _canLoadSharedLibrary("d3d12.dll"); + case RenderApiType::OpenGl: return _canLoadSharedLibrary("opengl32"); + case RenderApiType::Vulkan: return _canLoadSharedLibrary("vulkan-1"); + case RenderApiType::D3D11: return _canLoadSharedLibrary("d3d11"); + case RenderApiType::D3D12: return _canLoadSharedLibrary("d3d12"); default: break; } #elif SLANG_UNIX_FAMILY -- cgit v1.2.3