compile Vulkan SPIR-V shaders in CMAKE_CURRENT_BINARY_DIR (#2055)

fixes #2040 

* Compiles the Vulkan SPIR-V files in a directory based off of
CMAKE_CURRENT_BINARY_DIR.
* Changes the search path for the Vulkan SPIR-V files to this directory
rather than a semi-arbitrary set of directories.
This commit is contained in:
Ben Ashbaugh
2024-09-16 06:28:03 -07:00
committed by GitHub
parent 21b0a09ef0
commit a395174037
6 changed files with 30 additions and 45 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -23,6 +23,7 @@
#include <memory>
#include <string.h>
#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<char> vkBufferShader = readFile("buffer.spv");
std::vector<char> 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<char> vkBufferShader = readFile("buffer.spv");
std::vector<char> 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<char> vkBufferShader = readFile("buffer.spv");
std::vector<char> 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<char> vkBufferShader = readFile("buffer.spv");
std::vector<char> vkBufferShader = readFile("buffer.spv", exe_dir());
VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader);
VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList(

View File

@@ -17,6 +17,7 @@
#include <vulkan_interop_common.hpp>
#include <string>
#include "harness/errorHelpers.h"
#include "harness/os_helpers.h"
#include <algorithm>
#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);