diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp index f694954ef9..1c433a7176 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp @@ -50,7 +50,6 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice() cl_uint num_devices = 0; cl_uint device_no = 0; const size_t bufsize = BUFFERSIZE; - char buf[BUFFERSIZE]; const VulkanInstance &instance = getVulkanInstance(); const VulkanPhysicalDeviceList &physicalDeviceList = instance.getPhysicalDeviceList(); @@ -753,43 +752,37 @@ std::ostream &operator<<(std::ostream &os, VulkanFormat format) return os; } -static char *findFilePath(const std::string filename) +static std::string findFilePath(const std::string &filename, + const std::string &startdir) { const char *searchPath[] = { - "./", // Same dir - "./shaders/", // In shaders folder in same dir - "../test_conformance/vulkan/shaders/" // In src folder + "/shaders/", // shaders directory, for most builds + "/../shaders/", // one directory up, for multi-config builds }; for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) { - std::string path(searchPath[i]); + std::string path(startdir); + path += searchPath[i]; + path += filename; - path.append(filename); FILE *fp; fp = fopen(path.c_str(), "rb"); if (fp != NULL) { fclose(fp); - // File found - char *file_path = (char *)(malloc(path.length() + 1)); - strncpy(file_path, path.c_str(), path.length() + 1); - return file_path; - } - if (fp) - { - fclose(fp); + return path; } } // File not found - return 0; + return ""; } -std::vector readFile(const std::string &filename) +std::vector readFile(const std::string &filename, + const std::string &startdir = "") { - char *file_path = findFilePath(filename); - - std::ifstream file(file_path, std::ios::ate | std::ios::binary); + std::string filepath = findFilePath(filename, startdir); + std::ifstream file(filepath, std::ios::ate | std::ios::binary); if (!file.is_open()) { @@ -800,6 +793,6 @@ std::vector readFile(const std::string &filename) file.seekg(0); file.read(buffer.data(), fileSize); file.close(); - printf("filesize is %d", fileSize); + printf("filesize is %zu\n", fileSize); return buffer; } diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp index b3cc7e44cc..d2f4b7bf91 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp @@ -72,5 +72,6 @@ operator<<(std::ostream& os, VulkanExternalSemaphoreHandleType externalSemaphoreHandleType); std::ostream& operator<<(std::ostream& os, VulkanFormat format); -std::vector readFile(const std::string& filename); +std::vector readFile(const std::string& filename, + const std::string& startdir); #endif // _vulkan_utility_hpp_ diff --git a/test_conformance/vulkan/CMakeLists.txt b/test_conformance/vulkan/CMakeLists.txt index c970a77e38..61a6014923 100644 --- a/test_conformance/vulkan/CMakeLists.txt +++ b/test_conformance/vulkan/CMakeLists.txt @@ -25,20 +25,8 @@ set (${MODULE_NAME}_SOURCES test_vulkan_api_consistency_for_1dimages.cpp test_vulkan_platform_device_info.cpp vulkan_interop_common.cpp - ../../test_common/harness/genericThread.cpp - ../../test_common/harness/errorHelpers.cpp - ../../test_common/harness/testHarness.cpp - ../../test_common/harness/kernelHelpers.cpp - ../../test_common/harness/mt19937.cpp - ../../test_common/harness/msvc9.c - ../../test_common/harness/parseParameters.cpp - ../../test_common/harness/deviceInfo.cpp - ../../test_common/harness/crc32.cpp ) -set_source_files_properties( - ${${MODULE_NAME}_SOURCES} - PROPERTIES LANGUAGE CXX) include_directories("../common/vulkan_wrapper") add_subdirectory(shaders) diff --git a/test_conformance/vulkan/shaders/CMakeLists.txt b/test_conformance/vulkan/shaders/CMakeLists.txt index 881b3f20d6..950774c04b 100644 --- a/test_conformance/vulkan/shaders/CMakeLists.txt +++ b/test_conformance/vulkan/shaders/CMakeLists.txt @@ -25,7 +25,7 @@ else() string(REPLACE "GLSL_TYPE_PREFIX" "${GLSL_TYPE_PREFIX}" IMAGE2D_SHADER_CONTENT "${IMAGE2D_SHADER_CONTENT}") file(WRITE ${IMAGE2D_SHADER_TMP_OUT_FILE} "${IMAGE2D_SHADER_CONTENT}") execute_process( - COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o image2D_${GLSL_FORMAT}.spv ${IMAGE2D_SHADER_TMP_OUT_FILE} + COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.spv ${IMAGE2D_SHADER_TMP_OUT_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE commandStatus OUTPUT_QUIET) @@ -34,7 +34,7 @@ else() endif() endforeach(IMAGE2D_FORMAT) execute_process( - COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${BUFFER_SHADER_IN_FILE}.spv ${BUFFER_SHADER_IN_FILE}.comp + COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${CMAKE_CURRENT_BINARY_DIR}/${BUFFER_SHADER_IN_FILE}.spv ${BUFFER_SHADER_IN_FILE}.comp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE commandStatus OUTPUT_QUIET) diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index de350f7022..b010fdb5bc 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -23,6 +23,7 @@ #include #include #include "harness/errorHelpers.h" +#include "harness/os_helpers.h" #include "deviceInfo.h" #define MAX_BUFFERS 5 @@ -115,7 +116,7 @@ int run_test_with_two_queue( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; @@ -447,7 +448,8 @@ int run_test_with_one_queue( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); + VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; vkDescriptorSetLayoutBindingList.addBinding( @@ -749,7 +751,7 @@ int run_test_with_multi_import_same_ctx( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; @@ -1097,7 +1099,7 @@ int run_test_with_multi_import_diff_ctx( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList( diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index 4c5d44a024..a3c8de993c 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -17,6 +17,7 @@ #include #include #include "harness/errorHelpers.h" +#include "harness/os_helpers.h" #include #include "deviceInfo.h" @@ -272,8 +273,8 @@ int run_test_with_two_queue( std::string fileName = "image2D_" + std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv"; - log_info("Load %s file", fileName.c_str()); - vkImage2DShader = readFile(fileName); + log_info("Load file: %s\n", fileName.c_str()); + vkImage2DShader = readFile(fileName, exe_dir()); VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader); VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout, @@ -884,8 +885,8 @@ int run_test_with_one_queue( std::string fileName = "image2D_" + std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv"; - log_info("Load %s file", fileName.c_str()); - vkImage2DShader = readFile(fileName); + log_info("Load file: %s\n", fileName.c_str()); + vkImage2DShader = readFile(fileName, exe_dir()); VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader); VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout, @@ -1474,7 +1475,7 @@ int test_image_common(cl_device_id device_, cl_context context_, err = setMaxImageDimensions(deviceId, max_width, max_height); test_error_and_cleanup(err, CLEANUP, "error setting max image dimensions"); - log_info("Set max_width to %lu and max_height to %lu\n", max_width, + log_info("Set max_width to %zu and max_height to %zu\n", max_width, max_height); context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &err);