diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 3d0bb02022..793b0d34f7 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1220,6 +1220,9 @@ if(TARGET Vulkan::Headers) target_link_libraries(${tool} PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS}) if(WIN32) target_compile_definitions(${tool} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + if(tool STREQUAL "vk_compute_test") + target_link_libraries(${tool} PRIVATE shell32) + endif() endif() endforeach() # OpFmaKHR width gate of vk_shader_fma.h (shaderFmaFloat32 / shaderFmaFloat64): no Vulkan instance, no GPU. diff --git a/runtime/test/vk_compute_test.cpp b/runtime/test/vk_compute_test.cpp index ef8446878b..875c85c6e0 100644 --- a/runtime/test/vk_compute_test.cpp +++ b/runtime/test/vk_compute_test.cpp @@ -39,11 +39,17 @@ #include #include #include +#include #include #include #include #include +#ifdef _WIN32 +#include +#include +#endif + static PFN_vkGetInstanceProcAddr gipa; #define CHECK(x) \ do { \ @@ -110,6 +116,18 @@ static bool parse_user_sgprs(const char* s, uint32_t* pc) { return true; } +static std::filesystem::path shader_argument([[maybe_unused]] const char* argument) { +#ifdef _WIN32 + // The CRT's narrow argv can replace characters outside the active code page. + int count = 0; + const std::unique_ptr wide_args( + CommandLineToArgvW(GetCommandLineW(), &count), LocalFree); + return wide_args && count > 1 ? std::filesystem::path(wide_args.get()[1]) : std::filesystem::path{}; +#else + return argument; +#endif +} + static int run(int argc, char** argv) { const bool require_wave64 = argc == 5 && !std::strcmp(argv[4], "--require-wave64"); if (argc != 4 && !require_wave64) { @@ -198,7 +216,7 @@ static int run(int argc, char** argv) { } out_words = uint32_t(n); } - std::ifstream f(argv[1], std::ios::binary); + std::ifstream f(shader_argument(argv[1]), std::ios::binary); std::vector code((std::istreambuf_iterator(f)), {}); uint32_t local[3]; const uint32_t spirv_version = spirv_local_size(code, local);