aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Macnak <natsu@google.com>2020-06-01 17:17:00 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-01 17:17:00 +0000
commitf7c290dd33da2853bb0e297f039ebd6f4f40bdd7 (patch)
treea00c94cd5e7378ab4a6c72aeebe070d3b3d3d735
parent8936aadbb92ce43b79ac1682f9a87a05f6c7d7bd (diff)
parent7288081543522bc03893d1e47cca5950f607d9c4 (diff)
downloadswiftshader-android11-mainline-conscrypt-release.tar.gz
Change-Id: Ie401cd7e6563be93862a4f4f40b6985219fbff33
-rw-r--r--src/Common/GrallocAndroid.cpp2
-rw-r--r--src/System/GrallocAndroid.cpp2
-rw-r--r--src/Vulkan/VkImage.cpp19
3 files changed, 19 insertions, 4 deletions
diff --git a/src/Common/GrallocAndroid.cpp b/src/Common/GrallocAndroid.cpp
index 08c2ece2e..963085c59 100644
--- a/src/Common/GrallocAndroid.cpp
+++ b/src/Common/GrallocAndroid.cpp
@@ -90,7 +90,7 @@ int GrallocModule::release(buffer_handle_t handle)
if (m_gralloc4_mapper != nullptr)
{
native_handle_t* native_handle = const_cast<native_handle_t*>(handle);
- return m_gralloc4_mapper->freeBuffer(native_handle).isOk();
+ return m_gralloc4_mapper->freeBuffer(native_handle).isOk() ? 0 : 1;
}
#endif
diff --git a/src/System/GrallocAndroid.cpp b/src/System/GrallocAndroid.cpp
index 08c2ece2e..963085c59 100644
--- a/src/System/GrallocAndroid.cpp
+++ b/src/System/GrallocAndroid.cpp
@@ -90,7 +90,7 @@ int GrallocModule::release(buffer_handle_t handle)
if (m_gralloc4_mapper != nullptr)
{
native_handle_t* native_handle = const_cast<native_handle_t*>(handle);
- return m_gralloc4_mapper->freeBuffer(native_handle).isOk();
+ return m_gralloc4_mapper->freeBuffer(native_handle).isOk() ? 0 : 1;
}
#endif
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index 7c2872a63..1b287b6a5 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -190,7 +190,17 @@ VkResult Image::prepareForExternalUseANDROID() const
void *nativeBuffer = nullptr;
VkExtent3D extent = getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
- if(GrallocModule::getInstance()->lock(backingMemory.nativeHandle, GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, extent.width, extent.height, &nativeBuffer) != 0)
+ buffer_handle_t importedBufferHandle = nullptr;
+ if(GrallocModule::getInstance()->import(backingMemory.nativeHandle, &importedBufferHandle) != 0)
+ {
+ return VK_ERROR_OUT_OF_DATE_KHR;
+ }
+ if(!importedBufferHandle)
+ {
+ return VK_ERROR_OUT_OF_DATE_KHR;
+ }
+
+ if(GrallocModule::getInstance()->lock(importedBufferHandle, GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, extent.width, extent.height, &nativeBuffer) != 0)
{
return VK_ERROR_OUT_OF_DATE_KHR;
}
@@ -211,7 +221,12 @@ VkResult Image::prepareForExternalUseANDROID() const
memcpy(dstBuffer + (i * bufferRowBytes), srcBuffer + (i * imageRowBytes), imageRowBytes);
}
- if(GrallocModule::getInstance()->unlock(backingMemory.nativeHandle) != 0)
+ if(GrallocModule::getInstance()->unlock(importedBufferHandle) != 0)
+ {
+ return VK_ERROR_OUT_OF_DATE_KHR;
+ }
+
+ if (GrallocModule::getInstance()->release(importedBufferHandle) != 0)
{
return VK_ERROR_OUT_OF_DATE_KHR;
}