diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp index 21db20dd..9fd3071c 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp @@ -477,12 +477,13 @@ getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *VulkanImageCreateInfo, throw std::runtime_error("get2DImageDimensions failed!!!"); } - img_desc->image_depth = 0; // VulkanImageCreateInfo->extent.depth; + img_desc->image_depth = + static_cast(VulkanImageCreateInfo->extent.depth); img_desc->image_array_size = 0; img_desc->image_row_pitch = 0; // Row pitch set to zero as host_ptr is NULL img_desc->image_slice_pitch = img_desc->image_row_pitch * img_desc->image_height; - img_desc->num_mip_levels = 1; + img_desc->num_mip_levels = 0; img_desc->num_samples = 0; img_desc->buffer = NULL; @@ -676,6 +677,14 @@ clExternalMemoryImage::clExternalMemoryImage( std::vector extMemProperties1; cl_device_id devList[] = { deviceId, NULL }; + VulkanImageTiling vulkanImageTiling = + vkClExternalMemoryHandleTilingAssumption( + deviceId, externalMemoryHandleType, &errcode_ret); + if (CL_SUCCESS != errcode_ret) + { + throw std::runtime_error("Failed to query OpenCL tiling mode"); + } + #ifdef _WIN32 if (!is_extension_available(devList[0], "cl_khr_external_memory_win32")) { @@ -747,6 +756,15 @@ clExternalMemoryImage::clExternalMemoryImage( throw std::runtime_error("getCLImageInfoFromVkImageInfo failed!!!"); } + // If OpenCL will assume linear, query the Vulkan image's row pitch, + // otherwise it may not match OpenCL's assumption of the row pitch. + if (vulkanImageTiling == VULKAN_IMAGE_TILING_LINEAR) + { + VkSubresourceLayout subresourceLayout = image2D.getSubresourceLayout(); + image_desc.image_row_pitch = subresourceLayout.rowPitch; + image_desc.image_slice_pitch = subresourceLayout.depthPitch; + } + extMemProperties1.push_back( (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR); extMemProperties1.push_back((cl_mem_properties)devList[0]); diff --git a/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp b/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp index 412aa0a9..ab4acb43 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp @@ -100,7 +100,8 @@ VK_FUNC_DECL(vkEnumerateDeviceExtensionProperties) \ VK_FUNC_DECL(vkGetPhysicalDeviceSurfaceSupportKHR) \ VK_FUNC_DECL(vkImportSemaphoreFdKHR) \ - VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) + VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) \ + VK_FUNC_DECL(vkGetImageSubresourceLayout) #define VK_WINDOWS_FUNC_LIST \ VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \ VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \ @@ -200,5 +201,6 @@ #define vkGetMemoryWin32HandleKHR _vkGetMemoryWin32HandleKHR #define vkGetSemaphoreWin32HandleKHR _vkGetSemaphoreWin32HandleKHR #define vkImportSemaphoreWin32HandleKHR _vkImportSemaphoreWin32HandleKHR +#define vkGetImageSubresourceLayout _vkGetImageSubresourceLayout #endif //_vulkan_api_list_hpp_ diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp index c8c60d83..116fb6e9 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp @@ -1870,6 +1870,16 @@ VulkanExtent3D VulkanImage2D::getExtent3D(uint32_t mipLevel) const return VulkanExtent3D(width, height, depth); } +VkSubresourceLayout VulkanImage2D::getSubresourceLayout() const +{ + VkImageSubresource subresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 }; + + VkSubresourceLayout subresourceLayout = { 0 }; + vkGetImageSubresourceLayout(m_device, m_vkImage, &subresource, + &subresourceLayout); + return subresourceLayout; +} + ////////////////////////////////// // VulkanImage3D implementation // ////////////////////////////////// diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp index f9f547b8..8f9fb980 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp @@ -552,6 +552,7 @@ public: VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE); virtual ~VulkanImage2D(); virtual VulkanExtent3D getExtent3D(uint32_t mipLevel = 0) const; + virtual VkSubresourceLayout getSubresourceLayout() const; VulkanImage2D(const VulkanImage2D &image2D); };