[vulkan] Implement vkGetMemoryZirconHandlePropertiesFUCHSIA am: 488704f3be
am: 7c6f389c23
Change-Id: I765288b3ffcd814edff55369a5a029b3c209ac9a
diff --git a/system/vulkan/goldfish_vulkan.cpp b/system/vulkan/goldfish_vulkan.cpp
index 1fb6fc9..18a9424 100644
--- a/system/vulkan/goldfish_vulkan.cpp
+++ b/system/vulkan/goldfish_vulkan.cpp
@@ -108,14 +108,25 @@
GetMemoryZirconHandleFUCHSIA(VkDevice /*device*/,
const VkMemoryGetZirconHandleInfoFUCHSIA* /*pInfo*/,
uint32_t* pHandle) {
+ AEMU_SCOPED_TRACE("vkstubhal::GetMemoryZirconHandleFUCHSIA");
*pHandle = 0;
return VK_SUCCESS;
}
VkResult
+GetMemoryZirconHandlePropertiesFUCHSIA(VkDevice /*device*/,
+ VkExternalMemoryHandleTypeFlagBits /*handleType*/,
+ uint32_t /*handle*/,
+ VkMemoryZirconHandlePropertiesFUCHSIA* /*pProperties*/) {
+ AEMU_SCOPED_TRACE("vkstubhal::GetMemoryZirconHandlePropertiesFUCHSIA");
+ return VK_SUCCESS;
+}
+
+VkResult
GetSemaphoreZirconHandleFUCHSIA(VkDevice /*device*/,
const VkSemaphoreGetZirconHandleInfoFUCHSIA* /*pInfo*/,
uint32_t* pHandle) {
+ AEMU_SCOPED_TRACE("vkstubhal::GetSemaphoreZirconHandleFUCHSIA");
*pHandle = 0;
return VK_SUCCESS;
}
@@ -123,6 +134,7 @@
VkResult
ImportSemaphoreZirconHandleFUCHSIA(VkDevice /*device*/,
const VkImportSemaphoreZirconHandleInfoFUCHSIA* /*pInfo*/) {
+ AEMU_SCOPED_TRACE("vkstubhal::ImportSemaphoreZirconHandleFUCHSIA");
return VK_SUCCESS;
}
@@ -131,18 +143,22 @@
const VkBufferCollectionCreateInfoFUCHSIA* /*pInfo*/,
const VkAllocationCallbacks* /*pAllocator*/,
VkBufferCollectionFUCHSIA* /*pCollection*/) {
+ AEMU_SCOPED_TRACE("vkstubhal::CreateBufferCollectionFUCHSIA");
return VK_SUCCESS;
}
-void DestroyBufferCollectionFUCHSIA(VkDevice /*device*/,
- VkBufferCollectionFUCHSIA /*collection*/,
- const VkAllocationCallbacks* /*pAllocator*/) {
+void
+DestroyBufferCollectionFUCHSIA(VkDevice /*device*/,
+ VkBufferCollectionFUCHSIA /*collection*/,
+ const VkAllocationCallbacks* /*pAllocator*/) {
+ AEMU_SCOPED_TRACE("vkstubhal::DestroyBufferCollectionFUCHSIA");
}
VkResult
SetBufferCollectionConstraintsFUCHSIA(VkDevice /*device*/,
VkBufferCollectionFUCHSIA /*collection*/,
const VkImageCreateInfo* /*pImageInfo*/) {
+ AEMU_SCOPED_TRACE("vkstubhal::SetBufferCollectionConstraintsFUCHSIA");
return VK_SUCCESS;
}
#endif
@@ -167,6 +183,8 @@
#ifdef VK_USE_PLATFORM_FUCHSIA
if (strcmp(name, "vkGetMemoryZirconHandleFUCHSIA") == 0)
return reinterpret_cast<PFN_vkVoidFunction>(GetMemoryZirconHandleFUCHSIA);
+ if (strcmp(name, "vkGetMemoryZirconHandlePropertiesFUCHSIA") == 0)
+ return reinterpret_cast<PFN_vkVoidFunction>(GetMemoryZirconHandlePropertiesFUCHSIA);
if (strcmp(name, "vkGetSemaphoreZirconHandleFUCHSIA") == 0)
return reinterpret_cast<PFN_vkVoidFunction>(GetSemaphoreZirconHandleFUCHSIA);
if (strcmp(name, "vkImportSemaphoreZirconHandleFUCHSIA") == 0)
@@ -299,6 +317,28 @@
}
VKAPI_ATTR
+VkResult GetMemoryZirconHandlePropertiesFUCHSIA(
+ VkDevice device,
+ VkExternalMemoryHandleTypeFlagBits handleType,
+ uint32_t handle,
+ VkMemoryZirconHandlePropertiesFUCHSIA* pProperties) {
+ AEMU_SCOPED_TRACE("goldfish_vulkan::GetMemoryZirconHandlePropertiesFUCHSIA");
+
+ VK_HOST_CONNECTION(VK_ERROR_DEVICE_LOST)
+
+ if (!hostSupportsVulkan) {
+ return vkstubhal::GetMemoryZirconHandlePropertiesFUCHSIA(
+ device, handleType, handle, pProperties);
+ }
+
+ VkResult res = goldfish_vk::ResourceTracker::get()->
+ on_vkGetMemoryZirconHandlePropertiesFUCHSIA(
+ vkEnc, VK_SUCCESS, device, handleType, handle, pProperties);
+
+ return res;
+}
+
+VKAPI_ATTR
VkResult GetSemaphoreZirconHandleFUCHSIA(
VkDevice device,
const VkSemaphoreGetZirconHandleInfoFUCHSIA* pInfo,
@@ -411,6 +451,9 @@
if (!strcmp(name, "vkGetMemoryZirconHandleFUCHSIA")) {
return (PFN_vkVoidFunction)GetMemoryZirconHandleFUCHSIA;
}
+ if (!strcmp(name, "vkGetMemoryZirconHandlePropertiesFUCHSIA")) {
+ return (PFN_vkVoidFunction)GetMemoryZirconHandlePropertiesFUCHSIA;
+ }
if (!strcmp(name, "vkGetSemaphoreZirconHandleFUCHSIA")) {
return (PFN_vkVoidFunction)GetSemaphoreZirconHandleFUCHSIA;
}
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index d000112..a26ed5b 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -26,12 +26,12 @@
void zx_handle_close(zx_handle_t) { }
void zx_event_create(int, zx_handle_t*) { }
-typedef struct VkImportMemoryFuchsiaHandleInfoKHR {
+typedef struct VkImportMemoryZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagBits handleType;
uint32_t handle;
-} VkImportMemoryFuchsiaHandleInfoKHR;
+} VkImportMemoryZirconHandleInfoFUCHSIA;
#define VK_STRUCTURE_TYPE_TEMP_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA \
((VkStructureType)1001000000)
@@ -1167,14 +1167,38 @@
return VK_SUCCESS;
}
- VkResult on_vkGetMemoryFuchsiaHandlePropertiesKHR(
+ VkResult on_vkGetMemoryZirconHandlePropertiesFUCHSIA(
void*, VkResult,
VkDevice device,
- VkExternalMemoryHandleTypeFlagBitsKHR handleType,
+ VkExternalMemoryHandleTypeFlagBits handleType,
uint32_t handle,
- VkMemoryFuchsiaHandlePropertiesKHR* pProperties) {
- ALOGW("%s", __FUNCTION__);
- return VK_ERROR_INITIALIZATION_FAILED;
+ VkMemoryZirconHandlePropertiesFUCHSIA* pProperties) {
+ if (handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA) {
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+ if (pProperties->sType != VK_STRUCTURE_TYPE_TEMP_MEMORY_ZIRCON_HANDLE_PROPERTIES_FUCHSIA) {
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+
+ AutoLock lock(mLock);
+
+ auto deviceIt = info_VkDevice.find(device);
+
+ if (deviceIt == info_VkDevice.end()) {
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+
+ auto& info = deviceIt->second;
+
+ // Device local memory type supported.
+ pProperties->memoryTypeBits = 0;
+ for (uint32_t i = 0; i < info.memProps.memoryTypeCount; ++i) {
+ if (info.memProps.memoryTypes[i].propertyFlags &
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
+ pProperties->memoryTypeBits = 1ull << i;
+ }
+ }
+ return VK_SUCCESS;
}
VkResult on_vkImportSemaphoreZirconHandleFUCHSIA(
@@ -1260,7 +1284,7 @@
}
auto sysmem_collection = new fuchsia::sysmem::BufferCollectionSyncPtr;
zx_status_t status = mSysmemAllocator->BindSharedCollection(
- token, sysmem_collection->NewRequest());
+ std::move(token), sysmem_collection->NewRequest());
if (status != ZX_OK) {
ALOGE("BindSharedCollection failed: %d", status);
return VK_ERROR_INITIALIZATION_FAILED;
@@ -1476,8 +1500,8 @@
(VkImportAndroidHardwareBufferInfoANDROID*)vk_find_struct((vk_struct_common*)pAllocateInfo,
VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID);
- VkImportMemoryFuchsiaHandleInfoKHR* importPhysAddrInfoPtr =
- (VkImportMemoryFuchsiaHandleInfoKHR*)vk_find_struct((vk_struct_common*)pAllocateInfo,
+ VkImportMemoryZirconHandleInfoFUCHSIA* importPhysAddrInfoPtr =
+ (VkImportMemoryZirconHandleInfoFUCHSIA*)vk_find_struct((vk_struct_common*)pAllocateInfo,
VK_STRUCTURE_TYPE_TEMP_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA);
VkMemoryDedicatedAllocateInfo* dedicatedAllocInfoPtr =
@@ -3502,13 +3526,13 @@
context, input_result, device, pInfo, pHandle);
}
-VkResult ResourceTracker::on_vkGetMemoryFuchsiaHandlePropertiesKHR(
+VkResult ResourceTracker::on_vkGetMemoryZirconHandlePropertiesFUCHSIA(
void* context, VkResult input_result,
VkDevice device,
- VkExternalMemoryHandleTypeFlagBitsKHR handleType,
+ VkExternalMemoryHandleTypeFlagBits handleType,
uint32_t handle,
- VkMemoryFuchsiaHandlePropertiesKHR* pProperties) {
- return mImpl->on_vkGetMemoryFuchsiaHandlePropertiesKHR(
+ VkMemoryZirconHandlePropertiesFUCHSIA* pProperties) {
+ return mImpl->on_vkGetMemoryZirconHandlePropertiesFUCHSIA(
context, input_result, device, handleType, handle, pProperties);
}
diff --git a/system/vulkan_enc/ResourceTracker.h b/system/vulkan_enc/ResourceTracker.h
index a194e9f..3217f45 100644
--- a/system/vulkan_enc/ResourceTracker.h
+++ b/system/vulkan_enc/ResourceTracker.h
@@ -218,12 +218,12 @@
VkDevice device,
const VkMemoryGetZirconHandleInfoFUCHSIA* pInfo,
uint32_t* pHandle);
- VkResult on_vkGetMemoryFuchsiaHandlePropertiesKHR(
+ VkResult on_vkGetMemoryZirconHandlePropertiesFUCHSIA(
void* context, VkResult input_result,
VkDevice device,
- VkExternalMemoryHandleTypeFlagBitsKHR handleType,
+ VkExternalMemoryHandleTypeFlagBits handleType,
uint32_t handle,
- VkMemoryFuchsiaHandlePropertiesKHR* pProperties);
+ VkMemoryZirconHandlePropertiesFUCHSIA* pProperties);
VkResult on_vkGetSemaphoreZirconHandleFUCHSIA(
void* context, VkResult input_result,
VkDevice device,