Added some fixes for zircon tests in the Android CTS.

We shouldn't have been trying to run the tests in the first place
but vkGetPhysicalDevice*Properties was returning true for these
handles even on Android.

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Andrew Woloszyn
2023-10-04 17:02:19 -04:00
committed by Marge Bot
parent d9e47cb1e0
commit 1019e5d4d8
2 changed files with 85 additions and 5 deletions
@@ -5294,6 +5294,7 @@ VkResult ResourceTracker::on_vkCreateSemaphore(void* context, VkResult input_res
const VkSemaphoreCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSemaphore* pSemaphore) {
(void)input_result;
VkEncoder* enc = (VkEncoder*)context;
VkSemaphoreCreateInfo finalCreateInfo = *pCreateInfo;
@@ -6245,6 +6246,10 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
VkEncoder* enc = (VkEncoder*)context;
(void)input_result;
uint32_t supportedHandleType = 0;
VkExternalImageFormatProperties* ext_img_properties =
vk_find_struct<VkExternalImageFormatProperties>(pImageFormatProperties);
#ifdef VK_USE_PLATFORM_FUCHSIA
constexpr VkFormat kExternalImageSupportedFormats[] = {
@@ -6259,8 +6264,6 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
VK_FORMAT_R8G8_SSCALED, VK_FORMAT_R8G8_SRGB,
};
VkExternalImageFormatProperties* ext_img_properties =
vk_find_struct<VkExternalImageFormatProperties>(pImageFormatProperties);
if (ext_img_properties) {
if (std::find(std::begin(kExternalImageSupportedFormats),
@@ -6269,12 +6272,23 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}
}
supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VM_BIT_FUCHSIA;
#endif
#ifdef VK_USE_PLATFORM_ANDROID_KHR
VkAndroidHardwareBufferUsageANDROID* output_ahw_usage =
vk_find_struct<VkAndroidHardwareBufferUsageANDROID>(pImageFormatProperties);
supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
#endif
const VkPhysicalDeviceExternalImageFormatInfo* ext_img_info =
vk_find_struct<VkPhysicalDeviceExternalImageFormatInfo>(pImageFormatInfo);
if (supportedHandleType && ext_img_info) {
// 0 is a valid handleType so we don't check against 0
if (ext_img_info->handleType != (ext_img_info->handleType & supportedHandleType)) {
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}
}
VkResult hostRes;
@@ -6290,8 +6304,6 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
#ifdef VK_USE_PLATFORM_FUCHSIA
if (ext_img_properties) {
const VkPhysicalDeviceExternalImageFormatInfo* ext_img_info =
vk_find_struct<VkPhysicalDeviceExternalImageFormatInfo>(pImageFormatInfo);
if (ext_img_info) {
if (static_cast<uint32_t>(ext_img_info->handleType) ==
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA) {
@@ -6313,7 +6325,9 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
pImageFormatInfo->flags, pImageFormatInfo->usage);
}
#endif
if (ext_img_properties) {
transformImpl_VkExternalMemoryProperties_fromhost(&ext_img_properties->externalMemoryProperties, 0);
}
return hostRes;
}
@@ -6335,6 +6349,57 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2KHR(
pImageFormatProperties);
}
void ResourceTracker::on_vkGetPhysicalDeviceExternalBufferProperties_common(
bool isKhr, void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties) {
VkEncoder* enc = (VkEncoder*)context;
uint32_t supportedHandleType = 0;
#ifdef VK_USE_PLATFORM_FUCHSIA
supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VM_BIT_FUCHSIA;
#endif
#ifdef VK_USE_PLATFORM_ANDROID_KHR
supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
#endif
if (supportedHandleType) {
// 0 is a valid handleType so we can't check against 0
if (pExternalBufferInfo->handleType != (pExternalBufferInfo->handleType & supportedHandleType)) {
return;
}
}
if (isKhr) {
enc->vkGetPhysicalDeviceExternalBufferPropertiesKHR(
physicalDevice, pExternalBufferInfo, pExternalBufferProperties, true /* do lock */);
} else {
enc->vkGetPhysicalDeviceExternalBufferProperties(
physicalDevice, pExternalBufferInfo, pExternalBufferProperties, true /* do lock */);
}
transformImpl_VkExternalMemoryProperties_fromhost(&pExternalBufferProperties->externalMemoryProperties, 0);
}
void ResourceTracker::on_vkGetPhysicalDeviceExternalBufferProperties(
void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties) {
return on_vkGetPhysicalDeviceExternalBufferProperties_common(
false /* not KHR */, context, physicalDevice, pExternalBufferInfo,
pExternalBufferProperties
);
}
void ResourceTracker::on_vkGetPhysicalDeviceExternalBufferPropertiesKHR(
void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo,
VkExternalBufferPropertiesKHR* pExternalBufferProperties) {
return on_vkGetPhysicalDeviceExternalBufferProperties_common(
true /* is KHR */, context, physicalDevice, pExternalBufferInfo,
pExternalBufferProperties
);
}
void ResourceTracker::on_vkGetPhysicalDeviceExternalSemaphoreProperties(
void*, VkPhysicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
VkExternalSemaphoreProperties* pExternalSemaphoreProperties) {
@@ -417,6 +417,16 @@ class ResourceTracker {
const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo,
VkImageFormatProperties2* pImageFormatProperties);
void on_vkGetPhysicalDeviceExternalBufferProperties(
void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties);
void on_vkGetPhysicalDeviceExternalBufferPropertiesKHR(
void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo,
VkExternalBufferPropertiesKHR* pExternalBufferProperties);
void on_vkGetPhysicalDeviceExternalSemaphoreProperties(
void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
@@ -560,6 +570,11 @@ class ResourceTracker {
const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo,
VkImageFormatProperties2* pImageFormatProperties);
void on_vkGetPhysicalDeviceExternalBufferProperties_common(
bool isKhr, void* context, VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
VkExternalBufferProperties* pExternalBufferProperties);
template <typename VkSubmitInfoType>
VkResult on_vkQueueSubmitTemplate(void* context, VkResult input_result, VkQueue queue,
uint32_t submitCount, const VkSubmitInfoType* pSubmits,