Snap for 5413448 from 7cb64767fdf30b8f6efd71392a671f01a60a9e72 to qt-release
Change-Id: I1d776d956ccd3180e98f89f0a1e48e827b6e4ca8
diff --git a/shared/OpenglCodecCommon/gralloc_cb.h b/shared/OpenglCodecCommon/gralloc_cb.h
index f874c12..979d8e5 100644
--- a/shared/OpenglCodecCommon/gralloc_cb.h
+++ b/shared/OpenglCodecCommon/gralloc_cb.h
@@ -21,7 +21,6 @@
#include <hardware/gralloc.h>
#include <cutils/native_handle.h>
-#include "goldfish_dma.h"
#include "qemu_pipe.h"
#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab)
@@ -64,7 +63,6 @@
hostHandle(0),
emuFrameworkFormat(p_emuFrameworkFormat)
{
- goldfish_dma.fd = -1;
refcount_pipe_fd = QEMU_PIPE_INVALID_HANDLE;
version = sizeof(native_handle);
numFds = 0;
@@ -134,7 +132,6 @@
int lockedHeight;
uint32_t hostHandle;
- goldfish_dma_context goldfish_dma;
uint32_t goldfish_dma_buf_size;
EmulatorFrameworkFormat emuFrameworkFormat;
};
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 812ee04..57a9e9e 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -709,19 +709,6 @@
}
cb->setFd(fd);
-
- hostCon->lock();
-
- if (rcEnc->getDmaVersion() > 0) {
- D("%s: creating goldfish dma region of size %lu (cb fd %d)\n", __FUNCTION__, ashmem_size, cb->fd);
- init_gralloc_dmaregion();
- get_gralloc_dmaregion();
- } else {
- cb->goldfish_dma.fd = -1;
- }
- hostCon->unlock();
- } else {
- cb->goldfish_dma.fd = -1;
}
if (needHostCb) {
@@ -780,6 +767,14 @@
*pStride = stride;
break;
}
+
+ hostCon->lock();
+ if (rcEnc->getDmaVersion() > 0) {
+ init_gralloc_dmaregion();
+ get_gralloc_dmaregion();
+ }
+ hostCon->unlock();
+
return 0;
}
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,