mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
External sharing new updates (#1482)
* Fix enqueue_flags test to use correct barrier type. Currently, enqueue_flags test uses CLK_LOCAL_MEM_FENCE. Use CLK_GLOBAL_MEM_FENCE instead as all threads across work-groups need to wait here. * Add check for support for Read-Wrie images Read-Write images have required OpenCL 2.x. Read-Write image tests are already being skipped for 1.x devices. With OpenCL 3.0, read-write images being optional, the tests should be run or skipped depending on the implementation support. Add a check to decide if Read-Write images are supported or required to be supported depending on OpenCL version and decide if the tests should be run on skipped. Fixes issue #894 * Fix formatting in case of Read-Write image checks. Fix formatting in case of Read-write image checks. Also, combine two ifs into one in case of kerne_read_write tests * Fix some more formatting for RW-image checks Remove unnecessary spaces at various places. Also, fix lengthy lines. * Fix malloc-size calculation in test imagedim unsigned char size is silently assumed to be 1 in imagedim test of test_basic. Pass sizeof(type) in malloc size calculation. Also, change loop variable from signed to unsigned. Add checks for null pointer for malloced memory. * Initial CTS for external sharing extensions Initial set of tests for below extensions with Vulkan as producer 1. cl_khr_external_memory 2. cl_khr_external_memory_win32 3. cl_khr_external_memory_opaque_fd 4. cl_khr_external_semaphore 5. cl_khr_external_semaphore_win32 6. cl_khr_external_semaphore_opaque_fd * Updates to external sharing CTS Updates to external sharing CTS 1. Fix some build issues to remove unnecessary, non-existent files 2. Add new tests for platform and device queries. 3. Some added checks for VK Support. * Update CTS build script for Vulkan Headers Update CTS build to clone Vulkan Headers repo and pass it to CTS build in preparation for external memory and semaphore tests * Fix Vulkan header path Fix Vulkan header include path. * Add Vulkan loader dependency Vulkan loader is required to build test_vulkan of OpenCL-CTS. Clone and build Vulkan loader as prerequisite to OpenCL-CTS. * Fix Vulkan loader path in test_vulkan Remove arch/os suffix in Vulkan loader path to match vulkan loader repo build. * Fix warnings around getHandle API. Return type of getHandle is defined differently based on win or linux builds. Use appropriate guards when using API at other places. While at it remove duplicate definition of ARRAY_SIZE. * Use ARRAY_SIZE in harness. Use already defined ARRAY_SIZE macro from test_harness. * Fix build issues for test_vulkan Fix build issues for test_vulkan 1. Add cl_ext.h in common files 2. Replace cl_mem_properties_khr with cl_mem_properties 3. Replace cl_external_mem_handle_type_khr with cl_external_memory_handle_type_khr 4. Type-cast malloc as required. * Fix code formatting. Fix code formatting to get CTS CI builds clean. * Fix formatting fixes part-2 Another set of formatting fixes. * Fix code formatting part-3 Some more code formatting fixes. * Fix code formatting issues part-4 More code formatting fixes. * Formatting fixes part-5 Some more formatting fixes * Fix formatting part-6 More formatting fixes continued. * Code formatting fixes part-7 Code formatting fixes for image * Code formatting fixes part-8 Fixes for platform and device query tests. * Code formatting fixes part-9 More formatting fixes for vulkan_wrapper * Code formatting fixes part-10 More fixes to wrapper header * Code formatting fixes part-11 Formatting fixes for api_list * Code formatting fixes part-12 Formatting fixes for api_list_map. * Code formatting changes part-13 Code formatting changes for utility. * Code formatting fixes part-15 Formatting fixes for wrapper. * Misc Code formatting fixes Some more misc code formatting fixes. * Fix build breaks due to code formatting Fix build issues arised with recent code formatting issues. * Fix presubmit script after merge Fix presubmit script after merge conflicts. * Fix Vulkan loader build in presubmit script. Use cmake ninja and appropriate toolchain for Vulkan loader dependency to fix linking issue on arm/aarch64. * Use static array sizes Use static array sizes to fix windows builds. * Some left-out formatting fixes. Fix remaining formatting issues. * Fix harness header path Fix harness header path While at it, remove Misc and test pragma. * Add/Fix license information Add Khronos License info for test_vulkan. Replace Apple license with Khronos as applicable. * Fix headers for Mac OSX builds. Use appropriate headers for Mac OSX builds * Fix Mac OSX builds. Use appropriate headers for Mac OSX builds. Also, fix some build issues due to type-casting. * Fix new code formatting issues Fix new code formatting issues with recent MacOS fixes. * Add back missing case statement Add back missing case statement that was accidentally removed. * Disable USE_GAS for Vulkan Loader build. Disable USE_GAS for Vulkan Loader build to fix aarch64 build. * Fixes to OpenCL external sharing tests Fix clReleaseSemaphore() API. Fix copyright year. Some other minor fixes. * Improvements to OpenCL external sharing CTS Use SPIR-V shaders instead of NV extension path from GLSL to Vulkan shaders. Fixes for lower end GPUs to use limited memory. Update copy-right year at some more places. * Fix new code formatting issues. Fix code formatting issues with recent changes for external sharing tests. * More formatting fixes. More formatting fixes for recent updates to external sharing tests. * Final code formatting fixes. Minor formatting fixes to get format checks clean.
This commit is contained in:
@@ -134,7 +134,6 @@ cl_device_id *devices;
|
||||
const size_t bufsize = BUFFERSIZE;
|
||||
char buf[BUFFERSIZE];
|
||||
cl_uchar uuid[CL_UUID_SIZE_KHR];
|
||||
VulkanDevice vkDevice;
|
||||
unsigned int numCQ;
|
||||
bool multiImport;
|
||||
bool multiCtx;
|
||||
@@ -220,9 +219,12 @@ int main(int argc, const char *argv[])
|
||||
if (!checkVkSupport())
|
||||
{
|
||||
log_info("Vulkan supported GPU not found \n");
|
||||
log_info("TEST SKIPPED \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VulkanDevice vkDevice;
|
||||
|
||||
cl_device_type requestedDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
char *force_cpu = getenv("CL_DEVICE_TYPE");
|
||||
if (force_cpu != NULL)
|
||||
|
||||
28
test_conformance/vulkan/shaders/buffer.comp
Normal file
28
test_conformance/vulkan/shaders/buffer.comp
Normal file
@@ -0,0 +1,28 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable
|
||||
|
||||
#define MAX_BUFFERS 5
|
||||
|
||||
layout(binding = 0) buffer Params
|
||||
{
|
||||
uint32_t numBuffers;
|
||||
uint32_t bufferSize;
|
||||
uint32_t interBufferOffset;
|
||||
};
|
||||
layout(binding = 1) buffer Buffer
|
||||
{
|
||||
uint8_t ptr[];
|
||||
} bufferPtrList[MAX_BUFFERS];
|
||||
layout(local_size_x = 512) in;
|
||||
void main() {
|
||||
for (uint32_t bufIdx = 0; bufIdx < numBuffers; bufIdx++) {
|
||||
uint32_t ptrIdx = gl_GlobalInvocationID.x;
|
||||
uint32_t limit = bufferSize;
|
||||
while (ptrIdx < limit) {
|
||||
bufferPtrList[bufIdx].ptr[ptrIdx]++;
|
||||
ptrIdx += (gl_NumWorkGroups.x * gl_WorkGroupSize.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
test_conformance/vulkan/shaders/buffer.spv
Normal file
BIN
test_conformance/vulkan/shaders/buffer.spv
Normal file
Binary file not shown.
31
test_conformance/vulkan/shaders/image2D.comp
Normal file
31
test_conformance/vulkan/shaders/image2D.comp
Normal file
@@ -0,0 +1,31 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable
|
||||
|
||||
#define MAX_2D_IMAGES 5
|
||||
#define MAX_2D_IMAGE_MIP_LEVELS 11
|
||||
#define MAX_2D_IMAGE_DESCRIPTORS MAX_2D_IMAGES * MAX_2D_IMAGE_MIP_LEVELS
|
||||
|
||||
layout(binding = 0) buffer Params
|
||||
{
|
||||
uint32_t numImage2DDescriptors;
|
||||
};
|
||||
layout(binding = 1, rgba32f ) uniform image2D image2DList[ MAX_2D_IMAGE_DESCRIPTORS ];
|
||||
layout(local_size_x = 32, local_size_y = 32) in;
|
||||
void main() {
|
||||
uvec3 numThreads = gl_NumWorkGroups * gl_WorkGroupSize;
|
||||
for (uint32_t image2DIdx = 0; image2DIdx < numImage2DDescriptors; image2DIdx++) {
|
||||
ivec2 imageDim = imageSize(image2DList[image2DIdx]);
|
||||
uint32_t heightBy2 = imageDim.y / 2;
|
||||
for (uint32_t row = gl_GlobalInvocationID.y; row < heightBy2; row += numThreads.y) {
|
||||
for (uint32_t col = gl_GlobalInvocationID.x; col < imageDim.x; col += numThreads.x) {
|
||||
ivec2 coordsA = ivec2(col, row);
|
||||
ivec2 coordsB = ivec2(col, imageDim.y - row - 1);
|
||||
vec4 dataA = imageLoad(image2DList[image2DIdx], coordsA);
|
||||
vec4 dataB = imageLoad(image2DList[image2DIdx], coordsB);
|
||||
imageStore(image2DList[image2DIdx], coordsA, dataB);
|
||||
imageStore(image2DList[image2DIdx], coordsB, dataA);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
test_conformance/vulkan/shaders/image2D_r16i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r16i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_r16ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r16ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_r32f.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r32f.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_r32i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r32i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_r32ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r32ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_r8i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r8i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_r8ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_r8ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg16i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg16i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg16ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg16ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg32f.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg32f.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg32i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg32i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg32ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg32ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg8i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg8i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rg8ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rg8ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba16i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba16i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba16ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba16ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba32f.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba32f.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba32i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba32i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba32ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba32ui.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba8i.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba8i.spv
Normal file
Binary file not shown.
BIN
test_conformance/vulkan/shaders/image2D_rgba8ui.spv
Normal file
BIN
test_conformance/vulkan/shaders/image2D_rgba8ui.spv
Normal file
Binary file not shown.
@@ -238,7 +238,7 @@ int test_consistency_external_image(cl_device_id deviceID, cl_context _context,
|
||||
const VulkanMemoryTypeList& memoryTypeList = vkImage2D->getMemoryTypeList();
|
||||
uint64_t totalImageMemSize = vkImage2D->getSize();
|
||||
|
||||
log_info("Memory type index: %d\n", (uint32_t)memoryTypeList[0]);
|
||||
log_info("Memory type index: %lu\n", (uint32_t)memoryTypeList[0]);
|
||||
log_info("Memory type property: %d\n",
|
||||
memoryTypeList[0].getMemoryTypeProperty());
|
||||
log_info("Image size : %d\n", totalImageMemSize);
|
||||
@@ -552,17 +552,17 @@ int test_consistency_external_semaphore(cl_device_id deviceID,
|
||||
|
||||
|
||||
// Pass invalid object to release call
|
||||
errNum = clReleaseSemaphoreObjectKHRptr(NULL);
|
||||
errNum = clReleaseSemaphoreKHRptr(NULL);
|
||||
test_failure_error(errNum, CL_INVALID_VALUE,
|
||||
"clReleaseSemaphoreObjectKHRptr fails with "
|
||||
"clReleaseSemaphoreKHRptr fails with "
|
||||
"CL_INVALID_VALUE when NULL semaphore object is passed");
|
||||
|
||||
// Release both semaphore objects
|
||||
errNum = clReleaseSemaphoreObjectKHRptr(clVk2Clsemaphore);
|
||||
test_error(errNum, "clReleaseSemaphoreObjectKHRptr failed");
|
||||
errNum = clReleaseSemaphoreKHRptr(clVk2Clsemaphore);
|
||||
test_error(errNum, "clReleaseSemaphoreKHRptr failed");
|
||||
|
||||
errNum = clReleaseSemaphoreObjectKHRptr(clCl2Vksemaphore);
|
||||
test_error(errNum, "clReleaseSemaphoreObjectKHRptr failed");
|
||||
errNum = clReleaseSemaphoreKHRptr(clCl2Vksemaphore);
|
||||
test_error(errNum, "clReleaseSemaphoreKHRptr failed");
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
@@ -39,35 +39,6 @@ struct Params
|
||||
};
|
||||
}
|
||||
|
||||
static const char *vkBufferShader =
|
||||
"#version 450\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_NV_gpu_shader5 : enable\n"
|
||||
"layout(binding = 0) buffer Params\n"
|
||||
"{\n"
|
||||
" uint32_t numBuffers;\n"
|
||||
" uint32_t bufferSize;\n"
|
||||
" uint32_t interBufferOffset;\n"
|
||||
"};\n"
|
||||
"layout(binding = 1) buffer Buffer\n"
|
||||
"{\n"
|
||||
" uint8_t ptr[];\n"
|
||||
"} bufferPtrList[" STRING(
|
||||
MAX_BUFFERS) "];\n"
|
||||
"layout(local_size_x = 512) in;\n"
|
||||
"void main() {\n"
|
||||
" for (uint32_t bufIdx = 0; bufIdx < numBuffers;"
|
||||
" bufIdx++) {\n"
|
||||
" uint32_t ptrIdx = gl_GlobalInvocationID.x;\n"
|
||||
" uint32_t limit = bufferSize;\n"
|
||||
" while (ptrIdx < limit) {\n"
|
||||
" bufferPtrList[bufIdx].ptr[ptrIdx]++;\n"
|
||||
" ptrIdx += (gl_NumWorkGroups.x * "
|
||||
"gl_WorkGroupSize.x);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
const char *kernel_text_numbuffer_1 = " \
|
||||
__kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a) { \n\
|
||||
int gid = get_global_id(0); \n\
|
||||
@@ -149,6 +120,8 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
|
||||
VulkanQueue &vkQueue = vkDevice.getQueue();
|
||||
|
||||
std::vector<char> vkBufferShader = readFile("buffer.spv");
|
||||
|
||||
VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader);
|
||||
VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList(
|
||||
MAX_BUFFERS + 1, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
@@ -446,6 +419,7 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
|
||||
VulkanQueue &vkQueue = vkDevice.getQueue();
|
||||
|
||||
std::vector<char> vkBufferShader = readFile("buffer.spv");
|
||||
VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader);
|
||||
VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList(
|
||||
MAX_BUFFERS + 1, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
@@ -716,6 +690,8 @@ int run_test_with_multi_import_same_ctx(
|
||||
|
||||
VulkanQueue &vkQueue = vkDevice.getQueue();
|
||||
|
||||
std::vector<char> vkBufferShader = readFile("buffer.spv");
|
||||
|
||||
VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader);
|
||||
VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList(
|
||||
MAX_BUFFERS + 1, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
@@ -1050,6 +1026,8 @@ int run_test_with_multi_import_diff_ctx(
|
||||
|
||||
VulkanQueue &vkQueue = vkDevice.getQueue();
|
||||
|
||||
std::vector<char> vkBufferShader = readFile("buffer.spv");
|
||||
|
||||
VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader);
|
||||
VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList(
|
||||
MAX_BUFFERS + 1, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#define MAX_2D_IMAGE_ELEMENT_SIZE 16
|
||||
#define MAX_2D_IMAGE_MIP_LEVELS 11
|
||||
#define MAX_2D_IMAGE_DESCRIPTORS MAX_2D_IMAGES *MAX_2D_IMAGE_MIP_LEVELS
|
||||
#define GLSL_FORMAT_STRING "<GLSL_FORMAT>"
|
||||
#define GLSL_TYPE_PREFIX_STRING "<GLSL_TYPE_PREFIX>"
|
||||
#define NUM_THREADS_PER_GROUP_X 32
|
||||
#define NUM_THREADS_PER_GROUP_Y 32
|
||||
#define NUM_BLOCKS(size, blockSize) \
|
||||
@@ -54,61 +52,8 @@ struct Params
|
||||
}
|
||||
static cl_uchar uuid[CL_UUID_SIZE_KHR];
|
||||
static cl_device_id deviceId = NULL;
|
||||
|
||||
static const char *vkImage2DShader =
|
||||
"#version 450\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_NV_gpu_shader5 : enable\n"
|
||||
"layout(binding = 0) buffer Params\n"
|
||||
"{\n"
|
||||
" uint32_t numImage2DDescriptors;\n"
|
||||
"};\n"
|
||||
"layout(binding = 1, " GLSL_FORMAT_STRING
|
||||
") uniform " GLSL_TYPE_PREFIX_STRING "image2D image2DList[" STRING(
|
||||
MAX_2D_IMAGE_DESCRIPTORS) "];\n"
|
||||
"layout(local_size_x = 32, local_size_y = "
|
||||
"32) in;\n"
|
||||
"void main() {\n"
|
||||
" uvec3 numThreads = gl_NumWorkGroups * "
|
||||
"gl_WorkGroupSize;\n"
|
||||
" for (uint32_t image2DIdx = 0; "
|
||||
"image2DIdx < numImage2DDescriptors; "
|
||||
"image2DIdx++)"
|
||||
" {\n"
|
||||
" ivec2 imageDim = "
|
||||
"imageSize(image2DList[image2DIdx]);\n"
|
||||
" uint32_t heightBy2 = imageDim.y / "
|
||||
"2;\n"
|
||||
" for (uint32_t row = "
|
||||
"gl_GlobalInvocationID.y; row < heightBy2; "
|
||||
"row += numThreads.y)"
|
||||
" {\n"
|
||||
" for (uint32_t col = "
|
||||
"gl_GlobalInvocationID.x; col < imageDim.x; "
|
||||
"col += numThreads.x)"
|
||||
" {\n"
|
||||
" ivec2 coordsA = ivec2(col, "
|
||||
"row);\n"
|
||||
" ivec2 coordsB = ivec2(col, "
|
||||
"imageDim.y - row - 1);\n"
|
||||
" " GLSL_TYPE_PREFIX_STRING
|
||||
"vec4 dataA = "
|
||||
"imageLoad(image2DList[image2DIdx], "
|
||||
"coordsA);\n"
|
||||
" " GLSL_TYPE_PREFIX_STRING
|
||||
"vec4 dataB = "
|
||||
"imageLoad(image2DList[image2DIdx], "
|
||||
"coordsB);\n"
|
||||
" "
|
||||
"imageStore(image2DList[image2DIdx], "
|
||||
"coordsA, dataB);\n"
|
||||
" "
|
||||
"imageStore(image2DList[image2DIdx], "
|
||||
"coordsB, dataA);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
size_t max_width = MAX_2D_IMAGE_WIDTH;
|
||||
size_t max_height = MAX_2D_IMAGE_HEIGHT;
|
||||
|
||||
const char *kernel_text_numImage_1 = " \
|
||||
__constant sampler_t smpImg = CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_NONE|CLK_FILTER_NEAREST;\n\
|
||||
@@ -268,8 +213,8 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
VULKAN_MEMORY_TYPE_PROPERTY_HOST_VISIBLE_COHERENT));
|
||||
vkParamsDeviceMemory.bindBuffer(vkParamsBuffer);
|
||||
|
||||
uint64_t maxImage2DSize = MAX_2D_IMAGE_WIDTH * MAX_2D_IMAGE_HEIGHT
|
||||
* MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
uint64_t maxImage2DSize =
|
||||
max_width * max_height * MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
VulkanBuffer vkSrcBuffer(vkDevice, maxImage2DSize);
|
||||
VulkanDeviceMemory vkSrcBufferDeviceMemory(
|
||||
vkDevice, vkSrcBuffer.getSize(),
|
||||
@@ -310,6 +255,12 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
clCl2VkExternalSemaphore = new clExternalSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory2;
|
||||
std::vector<char> vkImage2DShader;
|
||||
|
||||
for (size_t fIdx = 0; fIdx < vkFormatList.size(); fIdx++)
|
||||
{
|
||||
VulkanFormat vkFormat = vkFormatList[fIdx];
|
||||
@@ -317,15 +268,13 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
uint32_t elementSize = getVulkanFormatElementSize(vkFormat);
|
||||
ASSERT_LEQ(elementSize, (uint32_t)MAX_2D_IMAGE_ELEMENT_SIZE);
|
||||
log_info("elementSize= %d\n", elementSize);
|
||||
std::map<std::string, std::string> patternToSubstituteMap;
|
||||
patternToSubstituteMap[GLSL_FORMAT_STRING] =
|
||||
getVulkanFormatGLSLFormat(vkFormat);
|
||||
patternToSubstituteMap[GLSL_TYPE_PREFIX_STRING] =
|
||||
getVulkanFormatGLSLTypePrefix(vkFormat);
|
||||
|
||||
VulkanShaderModule vkImage2DShaderModule(
|
||||
vkDevice,
|
||||
prepareVulkanShader(vkImage2DShader, patternToSubstituteMap));
|
||||
std::string fileName = "image2D_"
|
||||
+ std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv";
|
||||
log_info("Load %s file", fileName.c_str());
|
||||
vkImage2DShader = readFile(fileName);
|
||||
VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader);
|
||||
|
||||
VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout,
|
||||
vkImage2DShaderModule);
|
||||
|
||||
@@ -333,13 +282,13 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
{
|
||||
uint32_t width = widthList[wIdx];
|
||||
log_info("Width: %d\n", width);
|
||||
ASSERT_LEQ(width, (uint32_t)MAX_2D_IMAGE_WIDTH);
|
||||
if (width > max_width) continue;
|
||||
region[0] = width;
|
||||
for (size_t hIdx = 0; hIdx < ARRAY_SIZE(heightList); hIdx++)
|
||||
{
|
||||
uint32_t height = heightList[hIdx];
|
||||
log_info("Height: %d", height);
|
||||
ASSERT_LEQ(height, (uint32_t)MAX_2D_IMAGE_HEIGHT);
|
||||
if (height > max_height) continue;
|
||||
region[1] = height;
|
||||
|
||||
uint32_t numMipLevels = 1;
|
||||
@@ -418,14 +367,6 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
const VulkanMemoryTypeList &memoryTypeList =
|
||||
vkDummyImage2D.getMemoryTypeList();
|
||||
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory2;
|
||||
for (size_t mtIdx = 0; mtIdx < memoryTypeList.size();
|
||||
mtIdx++)
|
||||
{
|
||||
@@ -834,6 +775,8 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vkImage2DShader.clear();
|
||||
}
|
||||
CLEANUP:
|
||||
if (clVk2CLExternalSemaphore) delete clVk2CLExternalSemaphore;
|
||||
@@ -866,8 +809,8 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
VULKAN_MEMORY_TYPE_PROPERTY_HOST_VISIBLE_COHERENT));
|
||||
vkParamsDeviceMemory.bindBuffer(vkParamsBuffer);
|
||||
|
||||
uint64_t maxImage2DSize = MAX_2D_IMAGE_WIDTH * MAX_2D_IMAGE_HEIGHT
|
||||
* MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
uint64_t maxImage2DSize =
|
||||
max_width * max_height * MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
VulkanBuffer vkSrcBuffer(vkDevice, maxImage2DSize);
|
||||
VulkanDeviceMemory vkSrcBufferDeviceMemory(
|
||||
vkDevice, vkSrcBuffer.getSize(),
|
||||
@@ -908,6 +851,12 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
clCl2VkExternalSemaphore = new clExternalSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory2;
|
||||
std::vector<char> vkImage2DShader;
|
||||
|
||||
for (size_t fIdx = 0; fIdx < vkFormatList.size(); fIdx++)
|
||||
{
|
||||
VulkanFormat vkFormat = vkFormatList[fIdx];
|
||||
@@ -915,15 +864,13 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
uint32_t elementSize = getVulkanFormatElementSize(vkFormat);
|
||||
ASSERT_LEQ(elementSize, (uint32_t)MAX_2D_IMAGE_ELEMENT_SIZE);
|
||||
log_info("elementSize= %d\n", elementSize);
|
||||
std::map<std::string, std::string> patternToSubstituteMap;
|
||||
patternToSubstituteMap[GLSL_FORMAT_STRING] =
|
||||
getVulkanFormatGLSLFormat(vkFormat);
|
||||
patternToSubstituteMap[GLSL_TYPE_PREFIX_STRING] =
|
||||
getVulkanFormatGLSLTypePrefix(vkFormat);
|
||||
|
||||
VulkanShaderModule vkImage2DShaderModule(
|
||||
vkDevice,
|
||||
prepareVulkanShader(vkImage2DShader, patternToSubstituteMap));
|
||||
std::string fileName = "image2D_"
|
||||
+ std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv";
|
||||
log_info("Load %s file", fileName.c_str());
|
||||
vkImage2DShader = readFile(fileName);
|
||||
VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader);
|
||||
|
||||
VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout,
|
||||
vkImage2DShaderModule);
|
||||
|
||||
@@ -931,13 +878,13 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
{
|
||||
uint32_t width = widthList[wIdx];
|
||||
log_info("Width: %d\n", width);
|
||||
ASSERT_LEQ(width, (uint32_t)MAX_2D_IMAGE_WIDTH);
|
||||
if (width > max_width) continue;
|
||||
region[0] = width;
|
||||
for (size_t hIdx = 0; hIdx < ARRAY_SIZE(heightList); hIdx++)
|
||||
{
|
||||
uint32_t height = heightList[hIdx];
|
||||
log_info("Height: %d\n", height);
|
||||
ASSERT_LEQ(height, (uint32_t)MAX_2D_IMAGE_HEIGHT);
|
||||
if (height > max_height) continue;
|
||||
region[1] = height;
|
||||
|
||||
uint32_t numMipLevels = 1;
|
||||
@@ -1016,14 +963,6 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
const VulkanMemoryTypeList &memoryTypeList =
|
||||
vkDummyImage2D.getMemoryTypeList();
|
||||
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory2;
|
||||
for (size_t mtIdx = 0; mtIdx < memoryTypeList.size();
|
||||
mtIdx++)
|
||||
{
|
||||
@@ -1368,6 +1307,7 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
}
|
||||
}
|
||||
}
|
||||
vkImage2DShader.clear();
|
||||
}
|
||||
CLEANUP:
|
||||
if (clVk2CLExternalSemaphore) delete clVk2CLExternalSemaphore;
|
||||
@@ -1494,6 +1434,14 @@ int test_image_common(cl_device_id device_, cl_context context_,
|
||||
goto CLEANUP;
|
||||
}
|
||||
deviceId = devices[device_no];
|
||||
err = setMaxImageDimensions(deviceId, max_width, max_height);
|
||||
if (CL_SUCCESS != err)
|
||||
{
|
||||
print_error(err, "error setting max image dimensions");
|
||||
goto CLEANUP;
|
||||
}
|
||||
log_info("Set max_width to %lu and max_height to %lu\n", max_width,
|
||||
max_height);
|
||||
context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU,
|
||||
NULL, NULL, &err);
|
||||
if (CL_SUCCESS != err)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#define ASSERT(x) assert((x))
|
||||
#define GB(x) ((unsigned long long)(x) << 30)
|
||||
|
||||
pfnclCreateSemaphoreWithPropertiesKHR clCreateSemaphoreWithPropertiesKHRptr;
|
||||
pfnclEnqueueWaitSemaphoresKHR clEnqueueWaitSemaphoresKHRptr;
|
||||
@@ -31,7 +32,7 @@ pfnclEnqueueAcquireExternalMemObjectsKHR
|
||||
clEnqueueAcquireExternalMemObjectsKHRptr;
|
||||
pfnclEnqueueReleaseExternalMemObjectsKHR
|
||||
clEnqueueReleaseExternalMemObjectsKHRptr;
|
||||
pfnclReleaseSemaphoreObjectKHR clReleaseSemaphoreObjectKHRptr;
|
||||
pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr;
|
||||
|
||||
void init_cl_vk_ext(cl_platform_id opencl_platform)
|
||||
{
|
||||
@@ -51,13 +52,13 @@ void init_cl_vk_ext(cl_platform_id opencl_platform)
|
||||
throw std::runtime_error("Failed to get the function pointer of "
|
||||
"clEnqueueSignalSemaphoresKHRptr!");
|
||||
}
|
||||
clReleaseSemaphoreObjectKHRptr = (pfnclReleaseSemaphoreObjectKHR)
|
||||
clGetExtensionFunctionAddressForPlatform(opencl_platform,
|
||||
"clReleaseSemaphoreObjectKHR");
|
||||
if (NULL == clReleaseSemaphoreObjectKHRptr)
|
||||
clReleaseSemaphoreKHRptr =
|
||||
(pfnclReleaseSemaphoreKHR)clGetExtensionFunctionAddressForPlatform(
|
||||
opencl_platform, "clReleaseSemaphoreKHR");
|
||||
if (NULL == clReleaseSemaphoreKHRptr)
|
||||
{
|
||||
throw std::runtime_error("Failed to get the function pointer of "
|
||||
"clReleaseSemaphoreObjectKHRptr!");
|
||||
"clReleaseSemaphoreKHRptr!");
|
||||
}
|
||||
clCreateSemaphoreWithPropertiesKHRptr =
|
||||
(pfnclCreateSemaphoreWithPropertiesKHR)
|
||||
@@ -70,6 +71,40 @@ void init_cl_vk_ext(cl_platform_id opencl_platform)
|
||||
}
|
||||
}
|
||||
|
||||
cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &max_width,
|
||||
size_t &max_height)
|
||||
{
|
||||
cl_int result = CL_SUCCESS;
|
||||
cl_ulong val;
|
||||
size_t paramSize;
|
||||
|
||||
result = clGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE,
|
||||
sizeof(cl_ulong), &val, ¶mSize);
|
||||
|
||||
if (result != CL_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (val < GB(4))
|
||||
{
|
||||
max_width = 256;
|
||||
max_height = 256;
|
||||
}
|
||||
else if (val < GB(8))
|
||||
{
|
||||
max_width = 512;
|
||||
max_height = 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_width = 1024;
|
||||
max_height = 512;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
cl_int getCLFormatFromVkFormat(VkFormat vkFormat,
|
||||
cl_image_format *clImageFormat)
|
||||
{
|
||||
@@ -798,10 +833,10 @@ clExternalSemaphore::clExternalSemaphore(
|
||||
|
||||
clExternalSemaphore::~clExternalSemaphore()
|
||||
{
|
||||
cl_int err = clReleaseSemaphoreObjectKHRptr(m_externalSemaphore);
|
||||
cl_int err = clReleaseSemaphoreKHRptr(m_externalSemaphore);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("clReleaseSemaphoreObjectKHR failed!");
|
||||
throw std::runtime_error("clReleaseSemaphoreKHR failed!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef cl_int (*pfnclEnqueueReleaseExternalMemObjectsKHR)(
|
||||
cl_command_queue command_queue, cl_uint num_mem_objects,
|
||||
const cl_mem *mem_objects, cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list, cl_event *event);
|
||||
typedef cl_int (*pfnclReleaseSemaphoreObjectKHR)(cl_semaphore_khr sema_object);
|
||||
typedef cl_int (*pfnclReleaseSemaphoreKHR)(cl_semaphore_khr sema_object);
|
||||
|
||||
extern pfnclCreateSemaphoreWithPropertiesKHR
|
||||
clCreateSemaphoreWithPropertiesKHRptr;
|
||||
@@ -59,7 +59,7 @@ extern pfnclEnqueueAcquireExternalMemObjectsKHR
|
||||
clEnqueueAcquireExternalMemObjectsKHRptr;
|
||||
extern pfnclEnqueueReleaseExternalMemObjectsKHR
|
||||
clEnqueueReleaseExternalMemObjectsKHRptr;
|
||||
extern pfnclReleaseSemaphoreObjectKHR clReleaseSemaphoreObjectKHRptr;
|
||||
extern pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr;
|
||||
|
||||
cl_int getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *, size_t,
|
||||
cl_image_format *, cl_image_desc *);
|
||||
@@ -69,6 +69,8 @@ cl_int check_external_memory_handle_type(
|
||||
cl_int check_external_semaphore_handle_type(
|
||||
cl_device_id deviceID,
|
||||
cl_external_semaphore_handle_type_khr requiredHandleType);
|
||||
cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &width,
|
||||
size_t &height);
|
||||
|
||||
class clExternalMemory {
|
||||
protected:
|
||||
|
||||
@@ -335,11 +335,8 @@ const VulkanWrapper &
|
||||
template <class VulkanWrapper, class VulkanNative>
|
||||
VulkanWrapper &VulkanList<VulkanWrapper, VulkanNative>::operator[](size_t idx)
|
||||
{
|
||||
if (idx < m_wrapperList.size())
|
||||
{
|
||||
// CHECK_LT(idx, m_wrapperList.size());
|
||||
return m_wrapperList[idx].get();
|
||||
}
|
||||
}
|
||||
|
||||
template <class VulkanWrapper, class VulkanNative>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "vulkan_wrapper.hpp"
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <CL/cl.h>
|
||||
@@ -541,59 +542,6 @@ const char *getVulkanFormatGLSLFormat(VulkanFormat format)
|
||||
return (const char *)size_t(0);
|
||||
}
|
||||
|
||||
const char *getVulkanFormatGLSLTypePrefix(VulkanFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case VULKAN_FORMAT_R8_UINT:
|
||||
case VULKAN_FORMAT_R8G8_UINT:
|
||||
case VULKAN_FORMAT_R8G8B8A8_UINT:
|
||||
case VULKAN_FORMAT_R16_UINT:
|
||||
case VULKAN_FORMAT_R16G16_UINT:
|
||||
case VULKAN_FORMAT_R16G16B16A16_UINT:
|
||||
case VULKAN_FORMAT_R32_UINT:
|
||||
case VULKAN_FORMAT_R32G32_UINT:
|
||||
case VULKAN_FORMAT_R32G32B32A32_UINT: return "u";
|
||||
|
||||
case VULKAN_FORMAT_R8_SINT:
|
||||
case VULKAN_FORMAT_R8G8_SINT:
|
||||
case VULKAN_FORMAT_R8G8B8A8_SINT:
|
||||
case VULKAN_FORMAT_R16_SINT:
|
||||
case VULKAN_FORMAT_R16G16_SINT:
|
||||
case VULKAN_FORMAT_R16G16B16A16_SINT:
|
||||
case VULKAN_FORMAT_R32_SINT:
|
||||
case VULKAN_FORMAT_R32G32_SINT:
|
||||
case VULKAN_FORMAT_R32G32B32A32_SINT: return "i";
|
||||
|
||||
case VULKAN_FORMAT_R32_SFLOAT:
|
||||
case VULKAN_FORMAT_R32G32_SFLOAT:
|
||||
case VULKAN_FORMAT_R32G32B32A32_SFLOAT: return "";
|
||||
|
||||
default: ASSERT(0); std::cout << "Unknown format";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string prepareVulkanShader(
|
||||
std::string shaderCode,
|
||||
const std::map<std::string, std::string> &patternToSubstituteMap)
|
||||
{
|
||||
for (std::map<std::string, std::string>::const_iterator psIt =
|
||||
patternToSubstituteMap.begin();
|
||||
psIt != patternToSubstituteMap.end(); ++psIt)
|
||||
{
|
||||
std::string::size_type pos = 0u;
|
||||
while ((pos = shaderCode.find(psIt->first, pos)) != std::string::npos)
|
||||
{
|
||||
shaderCode.replace(pos, psIt->first.length(), psIt->second);
|
||||
pos += psIt->second.length();
|
||||
}
|
||||
}
|
||||
|
||||
return shaderCode;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
VulkanMemoryTypeProperty memoryTypeProperty)
|
||||
{
|
||||
@@ -691,3 +639,54 @@ std::ostream &operator<<(std::ostream &os, VulkanFormat format)
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
static char *findFilePath(const std::string filename)
|
||||
{
|
||||
const char *searchPath[] = {
|
||||
"./", // Same dir
|
||||
"./shaders/", // In shaders folder in same dir
|
||||
"../test_conformance/vulkan/shaders/" // In src folder
|
||||
};
|
||||
for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i)
|
||||
{
|
||||
std::string path(searchPath[i]);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
// File not found
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<char> readFile(const std::string &filename)
|
||||
{
|
||||
char *file_path = findFilePath(filename);
|
||||
|
||||
std::ifstream file(file_path, std::ios::ate | std::ios::binary);
|
||||
|
||||
if (!file.is_open())
|
||||
{
|
||||
throw std::runtime_error("failed to open shader spv file!\n");
|
||||
}
|
||||
size_t fileSize = (size_t)file.tellg();
|
||||
std::vector<char> buffer(fileSize);
|
||||
file.seekg(0);
|
||||
file.read(buffer.data(), fileSize);
|
||||
file.close();
|
||||
printf("filesize is %d", fileSize);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -66,4 +66,5 @@ operator<<(std::ostream& os,
|
||||
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType);
|
||||
std::ostream& operator<<(std::ostream& os, VulkanFormat format);
|
||||
|
||||
std::vector<char> readFile(const std::string& filename);
|
||||
#endif // _vulkan_utility_hpp_
|
||||
|
||||
@@ -201,7 +201,8 @@ VulkanInstance::VulkanInstance(): m_vkInstance(VK_NULL_HANDLE)
|
||||
|
||||
if (physicalDeviceCount == uint32_t(0))
|
||||
{
|
||||
throw std::runtime_error("failed to find GPUs with Vulkan support!");
|
||||
std::cout << "failed to find GPUs with Vulkan support!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<VkPhysicalDevice> vkPhysicalDeviceList(physicalDeviceCount,
|
||||
@@ -846,23 +847,18 @@ VulkanShaderModule::VulkanShaderModule(const VulkanShaderModule &shaderModule)
|
||||
{}
|
||||
|
||||
VulkanShaderModule::VulkanShaderModule(const VulkanDevice &device,
|
||||
const std::string &code)
|
||||
const std::vector<char> &code)
|
||||
: m_device(device)
|
||||
{
|
||||
std::string paddedCode = code;
|
||||
while (paddedCode.size() % 4)
|
||||
{
|
||||
paddedCode += " ";
|
||||
}
|
||||
|
||||
VkShaderModuleCreateInfo vkShaderModuleCreateInfo = {};
|
||||
vkShaderModuleCreateInfo.sType =
|
||||
VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
vkShaderModuleCreateInfo.pNext = NULL;
|
||||
vkShaderModuleCreateInfo.flags = 0;
|
||||
vkShaderModuleCreateInfo.codeSize = paddedCode.size();
|
||||
vkShaderModuleCreateInfo.codeSize = code.size();
|
||||
vkShaderModuleCreateInfo.pCode =
|
||||
(const uint32_t *)(void *)paddedCode.c_str();
|
||||
reinterpret_cast<const uint32_t *>(code.data());
|
||||
|
||||
vkCreateShaderModule(m_device, &vkShaderModuleCreateInfo, NULL,
|
||||
&m_vkShaderModule);
|
||||
|
||||
@@ -240,7 +240,8 @@ protected:
|
||||
VulkanShaderModule(const VulkanShaderModule &shaderModule);
|
||||
|
||||
public:
|
||||
VulkanShaderModule(const VulkanDevice &device, const std::string &code);
|
||||
VulkanShaderModule(const VulkanDevice &device,
|
||||
const std::vector<char> &code);
|
||||
virtual ~VulkanShaderModule();
|
||||
operator VkShaderModule() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user