summaryrefslogtreecommitdiffstats
path: root/tools/gfx/vulkan/vk-module.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-07-19 14:47:34 -0700
committerGitHub <noreply@github.com>2021-07-19 14:47:34 -0700
commit6162950d9012833ef5d4f96b99c67a46bf97ce6d (patch)
tree5eaca94218168560f7e7bf94ead208c24fa34485 /tools/gfx/vulkan/vk-module.cpp
parentb00e2dc8e777a481f79c5c4fea4d1d0481fc445e (diff)
Enable swiftshader in linux CI builds (#1909)
Diffstat (limited to 'tools/gfx/vulkan/vk-module.cpp')
-rw-r--r--tools/gfx/vulkan/vk-module.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/tools/gfx/vulkan/vk-module.cpp b/tools/gfx/vulkan/vk-module.cpp
index 985df1a7b..cff75569e 100644
--- a/tools/gfx/vulkan/vk-module.cpp
+++ b/tools/gfx/vulkan/vk-module.cpp
@@ -11,45 +11,38 @@
# include <dlfcn.h>
#endif
+#include "../renderer-shared.h"
+
namespace gfx {
using namespace Slang;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! VulkanModule !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-Slang::Result VulkanModule::init()
+Slang::Result VulkanModule::init(bool useSoftwareImpl)
{
if (isInitialized())
{
destroy();
- return SLANG_OK;
}
const char* dynamicLibraryName = "Unknown";
+ m_isSoftware = useSoftwareImpl;
#if SLANG_WINDOWS_FAMILY
- dynamicLibraryName = "vulkan-1.dll";
+ dynamicLibraryName = useSoftwareImpl ? "vk_swiftshader.dll" : "vulkan-1.dll";
HMODULE module = ::LoadLibraryA(dynamicLibraryName);
m_module = (void*)module;
#else
- dynamicLibraryName = "libvulkan.so.1";
- m_module = dlopen(dynamicLibraryName, RTLD_NOW);
-#endif
-
- if (!m_module)
+ dynamicLibraryName = useSoftwareImpl ? "libvk_swiftshader.so" : "libvulkan.so.1";
+ if (useSoftwareImpl)
{
- dynamicLibraryName = "vk_swiftshader";
-#if SLANG_WINDOWS_FAMILY
- HMODULE swiftShaderModule = ::LoadLibraryA(dynamicLibraryName);
- m_module = (void*)swiftShaderModule;
-#else
- m_module = dlopen(dynamicLibraryName, RTLD_NOW);
-#endif
- m_isSoftware = true;
+ dlopen("libpthread.so.0", RTLD_NOW | RTLD_GLOBAL);
}
+ m_module = dlopen(dynamicLibraryName, RTLD_NOW);
+#endif
if (!m_module)
{
- fprintf(stderr, "error: failed load '%s'\n", dynamicLibraryName);
return SLANG_FAIL;
}