diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp index f295387a1f..0209ca1069 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp @@ -96,6 +96,26 @@ void init_cl_vk_ext(cl_platform_id opencl_platform, cl_uint num_devices, "clReImportSemaphoreSyncFdKHR!"); } } + + clEnqueueAcquireExternalMemObjectsKHRptr = + (pfnclEnqueueAcquireExternalMemObjectsKHR) + clGetExtensionFunctionAddressForPlatform( + opencl_platform, "clEnqueueAcquireExternalMemObjectsKHR"); + if (nullptr == clEnqueueAcquireExternalMemObjectsKHRptr) + { + throw std::runtime_error("Failed to get the function pointer of " + "clEnqueueAcquireExternalMemObjectsKHR!"); + } + + clEnqueueReleaseExternalMemObjectsKHRptr = + (pfnclEnqueueReleaseExternalMemObjectsKHR) + clGetExtensionFunctionAddressForPlatform( + opencl_platform, "clEnqueueReleaseExternalMemObjectsKHR"); + if (nullptr == clEnqueueReleaseExternalMemObjectsKHRptr) + { + throw std::runtime_error("Failed to get the function pointer of " + "clEnqueueReleaseExternalMemObjectsKHR!"); + } } cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &max_width, diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index 2787c17189..0cc31e5a04 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -281,9 +281,16 @@ int run_test_with_two_queue( cl_event first_launch; + cl_event acquire_event = nullptr; + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, vkBufferList.size(), buffers, 0, nullptr, + &acquire_event); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); + err = clEnqueueNDRangeKernel(cmd_queue1, update_buffer_kernel, - 1, NULL, global_work_size, NULL, 0, - NULL, &first_launch); + 1, NULL, global_work_size, NULL, 1, + &acquire_event, &first_launch); test_error_and_cleanup( err, CLEANUP, "Error: Failed to launch update_buffer_kernel," @@ -297,6 +304,12 @@ int run_test_with_two_queue( "Error: Failed to launch update_buffer_kernel," "error\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue2, vkBufferList.size(), buffers, 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); + if (use_fence) { clFlush(cmd_queue1); @@ -310,6 +323,9 @@ int run_test_with_two_queue( test_error_and_cleanup(err, CLEANUP, "Failed to signal CL semaphore\n"); } + err = clReleaseEvent(acquire_event); + test_error_and_cleanup(err, CLEANUP, + "Failed to release acquire event\n"); } error_2 = (uint8_t *)malloc(sizeof(uint8_t)); if (NULL == error_2) @@ -585,6 +601,12 @@ int run_test_with_one_queue( err, CLEANUP, "Error: Failed to set arg values for kernel\n"); + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, vkBufferList.size(), buffers, 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); + err = clEnqueueNDRangeKernel(cmd_queue1, update_buffer_kernel, 1, NULL, global_work_size, NULL, 0, NULL, NULL); @@ -593,6 +615,12 @@ int run_test_with_one_queue( "Error: Failed to launch update_buffer_kernel," " error\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, vkBufferList.size(), buffers, 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); + if (use_fence) { clFlush(cmd_queue1); @@ -883,6 +911,11 @@ int run_test_with_multi_import_same_ctx( err |= clSetKernelArg( update_buffer_kernel, i + 1, sizeof(cl_mem), (void *)&(buffers[i][launchIter])); + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers[i][launchIter], 0, + nullptr, nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); } test_error_and_cleanup( err, CLEANUP, @@ -896,6 +929,15 @@ int run_test_with_multi_import_same_ctx( err, CLEANUP, "Error: Failed to launch " "update_buffer_kernel, error\n "); + + for (int i = 0; i < numBuffers; i++) + { + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers[i][launchIter], 0, + nullptr, nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); + } } if (use_fence) { @@ -1229,11 +1271,22 @@ int run_test_with_multi_import_diff_ctx( err = clSetKernelArg(update_buffer_kernel1[launchIter], 0, sizeof(uint32_t), (void *)&pBufferSize); + test_error_and_cleanup(err, CLEANUP, + "Failed to set kernel arg"); + for (int i = 0; i < numBuffers; i++) { - err |= clSetKernelArg( + err = clSetKernelArg( update_buffer_kernel1[launchIter], i + 1, sizeof(cl_mem), (void *)&(buffers1[i][launchIter])); + test_error_and_cleanup(err, CLEANUP, + "Failed to set kernel arg"); + + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers1[i][launchIter], 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); } test_error_and_cleanup( err, CLEANUP, @@ -1246,6 +1299,14 @@ int run_test_with_multi_import_diff_ctx( test_error_and_cleanup(err, CLEANUP, "Error: Failed to launch " "update_buffer_kernel, error\n"); + for (int i = 0; i < numBuffers; i++) + { + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers1[i][launchIter], 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); + } } if (use_fence) { @@ -1298,12 +1359,23 @@ int run_test_with_multi_import_diff_ctx( err = clSetKernelArg(update_buffer_kernel2[launchIter], 0, sizeof(uint32_t), (void *)&bufferSize); + test_error_and_cleanup(err, CLEANUP, + "Failed to set kernel arg"); + for (int i = 0; i < numBuffers; i++) { - err |= clSetKernelArg( + err = clSetKernelArg( update_buffer_kernel2[launchIter], i + 1, sizeof(cl_mem), (void *)&(buffers2[i][launchIter])); + test_error_and_cleanup(err, CLEANUP, + "Failed to set kernel arg"); + + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers2[i][launchIter], 0, + nullptr, nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); } test_error_and_cleanup( err, CLEANUP, @@ -1317,6 +1389,14 @@ int run_test_with_multi_import_diff_ctx( err, CLEANUP, "Error: Failed to launch " "update_buffer_kernel, error\n "); + for (int i = 0; i < numBuffers; i++) + { + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers2[i][launchIter], 0, + nullptr, nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); + } } if (use_fence) { @@ -1757,4 +1837,4 @@ int test_buffer_common(cl_device_id device_, cl_context context_, if (extensions) free(extensions); return errNum; -} +} \ No newline at end of file diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index 7ca7b7f321..30ad043f18 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -644,7 +644,18 @@ int run_test_with_two_queue( err, CLEANUP, "Error: Failed to set arg values \n"); - // clVk2CLExternalSemaphore->wait(cmd_queue1); + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image1, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to acquire images"); + + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image2, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to acquire images"); + size_t global_work_size[3] = { width, height, 1 }; cl_event first_launch; @@ -656,6 +667,30 @@ int run_test_with_two_queue( err, CLEANUP, "Failed to enqueue updateKernelCQ1\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image1, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to release images"); + + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image2, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to release images"); + + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue2, num2DImages, + external_mem_image1, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to acquire images"); + + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue2, num2DImages, + external_mem_image2, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to acquire images"); + err = clEnqueueNDRangeKernel( cmd_queue2, updateKernelCQ2, 2, NULL, global_work_size, NULL, 1, &first_launch, @@ -664,6 +699,18 @@ int run_test_with_two_queue( err, CLEANUP, "Failed to enqueue updateKernelCQ2\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue2, num2DImages, + external_mem_image1, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to release images"); + + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue2, num2DImages, + external_mem_image2, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to release images"); + clFinish(cmd_queue2); err = clCl2VkExternalSemaphore->signal( cmd_queue2); @@ -1182,6 +1229,18 @@ int run_test_with_one_queue( "Error: Failed to set arg " "values for kernel-1\n"); + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image1, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to acquire images"); + + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image2, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to acquire images"); + size_t global_work_size[3] = { width, height, 1 }; err = clEnqueueNDRangeKernel( @@ -1191,6 +1250,18 @@ int run_test_with_one_queue( err, CLEANUP, "Failed to enqueue updateKernelCQ1\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image1, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to release images"); + + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, num2DImages, + external_mem_image2, 0, nullptr, nullptr); + test_error_and_cleanup( + err, CLEANUP, "Failed to release images"); + err = clCl2VkExternalSemaphore->signal( cmd_queue1); test_error_and_cleanup( @@ -1538,4 +1609,4 @@ int test_image_common(cl_device_id device_, cl_context context_, if (devices) free(devices); return err; -} +} \ No newline at end of file