Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 19 additions & 1 deletion runtime/test/vk_compute_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@
#include <algorithm>
#include <chrono>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>

#ifdef _WIN32
#include <memory>
#include <shellapi.h>
#endif

static PFN_vkGetInstanceProcAddr gipa;
#define CHECK(x) \
do { \
Expand Down Expand Up @@ -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<wchar_t*, decltype(&LocalFree)> 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) {
Expand Down Expand Up @@ -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<char> code((std::istreambuf_iterator<char>(f)), {});
uint32_t local[3];
const uint32_t spirv_version = spirv_local_size(code, local);
Expand Down