vulkan: Set platform-specific external semaphore properties.
Guest devices may query device external semaphore properties
before creating the semaphore, and we should include the
guest-system specific semaphore types in the returned result.
For example, for Fuchsia guests, we should include
TEMP_ZIRCON_EVENT_BIT_FUCHSIA as a compatible handle type if
the target external sempahore has the same type.
TEST=vkext_unprotected
Bug: fuchsia:69211
Change-Id: I4b59f46c21204b2e33c5b9e77cd477b2922346bc
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index 13d2643..e18e522 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -5921,6 +5921,39 @@
physicalDevice, pImageFormatInfo, pImageFormatProperties);
}
+ void on_vkGetPhysicalDeviceExternalSemaphoreProperties(
+ void*,
+ VkPhysicalDevice,
+ const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
+ VkExternalSemaphoreProperties* pExternalSemaphoreProperties) {
+ (void)pExternalSemaphoreInfo;
+ (void)pExternalSemaphoreProperties;
+#ifdef VK_USE_PLATFORM_FUCHSIA
+ if (pExternalSemaphoreInfo->handleType ==
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA) {
+ pExternalSemaphoreProperties->compatibleHandleTypes |=
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA;
+ pExternalSemaphoreProperties->exportFromImportedHandleTypes |=
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA;
+ pExternalSemaphoreProperties->externalSemaphoreFeatures |=
+ VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT |
+ VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT;
+ }
+#endif // VK_USE_PLATFORM_FUCHSIA
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ if (pExternalSemaphoreInfo->handleType ==
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT) {
+ pExternalSemaphoreProperties->compatibleHandleTypes |=
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
+ pExternalSemaphoreProperties->exportFromImportedHandleTypes |=
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
+ pExternalSemaphoreProperties->externalSemaphoreFeatures |=
+ VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT |
+ VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT;
+ }
+#endif // VK_USE_PLATFORM_ANDROID_KHR
+ }
+
void registerEncoderCleanupCallback(const VkEncoder* encoder, void* object, CleanupCallback callback) {
AutoLock lock(mLock);
auto& callbacks = mEncoderCleanupCallbacks[encoder];
@@ -7108,6 +7141,26 @@
pImageFormatProperties);
}
+void ResourceTracker::on_vkGetPhysicalDeviceExternalSemaphoreProperties(
+ void* context,
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
+ VkExternalSemaphoreProperties* pExternalSemaphoreProperties) {
+ mImpl->on_vkGetPhysicalDeviceExternalSemaphoreProperties(
+ context, physicalDevice, pExternalSemaphoreInfo,
+ pExternalSemaphoreProperties);
+}
+
+void ResourceTracker::on_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(
+ void* context,
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
+ VkExternalSemaphoreProperties* pExternalSemaphoreProperties) {
+ mImpl->on_vkGetPhysicalDeviceExternalSemaphoreProperties(
+ context, physicalDevice, pExternalSemaphoreInfo,
+ pExternalSemaphoreProperties);
+}
+
void ResourceTracker::registerEncoderCleanupCallback(const VkEncoder* encoder, void* handle, ResourceTracker::CleanupCallback callback) {
mImpl->registerEncoderCleanupCallback(encoder, handle, callback);
}