Fixed Vulkan unittests for Visual Studio
A few things:
- The library wasn't located in the provided path
- The function pointers weren't using the convention call
- The libraries built from Visual Studio weren't taken into
account (probably only those generated from the CMake
generated project were loadable)
Change-Id: I7f9cc9aee920747b4bab77286ba811b33982cece
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33128
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/tests/VulkanUnitTests/Driver.cpp b/tests/VulkanUnitTests/Driver.cpp
index a2a0a25..3e237b1 100644
--- a/tests/VulkanUnitTests/Driver.cpp
+++ b/tests/VulkanUnitTests/Driver.cpp
@@ -56,9 +56,19 @@
EXPECT_NE((HMODULE)NULL, libvulkan);
return true;
#elif defined(NDEBUG)
- return load("./build/Release/libvk_swiftshader.dll");
+ #if defined(_WIN64)
+ return load("./build/Release_Win64/vk_swiftshader.dll") ||
+ #else
+ return load("./build/Release_Win32/vk_swiftshader.dll") ||
+ #endif
+ load("./build/Release/libvk_swiftshader.dll");
#else
- return load("./build/Debug/libvk_swiftshader.dll");
+ #if defined(_WIN64)
+ return load("./build/Debug_Win64/vk_swiftshader.dll") ||
+ #else
+ return load("./build/Debug_Win32/vk_swiftshader.dll") ||
+ #endif
+ load("./build/Debug/libvk_swiftshader.dll");
#endif
#elif OS_MAC
#if defined(STANDALONE)
diff --git a/tests/VulkanUnitTests/Driver.hpp b/tests/VulkanUnitTests/Driver.hpp
index 51fc9b2..cdacea5 100644
--- a/tests/VulkanUnitTests/Driver.hpp
+++ b/tests/VulkanUnitTests/Driver.hpp
@@ -48,12 +48,12 @@
VKAPI_ATTR PFN_vkVoidFunction(VKAPI_CALL* vk_icdGetInstanceProcAddr)(VkInstance instance, const char* pName);
// Global vulkan function pointers.
-#define VK_GLOBAL(N, R, ...) R (*N)(__VA_ARGS__)
+#define VK_GLOBAL(N, R, ...) VKAPI_ATTR R (VKAPI_CALL *N)(__VA_ARGS__)
#include "VkGlobalFuncs.hpp"
#undef VK_GLOBAL
// Per-instance vulkan function pointers.
-#define VK_INSTANCE(N, R, ...) R (*N)(__VA_ARGS__)
+#define VK_INSTANCE(N, R, ...) VKAPI_ATTR R (VKAPI_CALL *N)(__VA_ARGS__)
#include "VkInstanceFuncs.hpp"
#undef VK_INSTANCE
diff --git a/tests/VulkanUnitTests/VulkanUnitTests.vcxproj.user b/tests/VulkanUnitTests/VulkanUnitTests.vcxproj.user
index a8f5c5a..95c2037 100644
--- a/tests/VulkanUnitTests/VulkanUnitTests.vcxproj.user
+++ b/tests/VulkanUnitTests/VulkanUnitTests.vcxproj.user
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LocalDebuggerEnvironment>PATH=$(SolutionDir)out\$(Configuration)_$(Platform)</LocalDebuggerEnvironment>
+ <LocalDebuggerEnvironment>PATH=$(SolutionDir)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>--gtest_break_on_failure --gtest_filter=*</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LocalDebuggerEnvironment>PATH=$(SolutionDir)out\$(Configuration)_$(Platform)</LocalDebuggerEnvironment>
+ <LocalDebuggerEnvironment>PATH=$(SolutionDir)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file