aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Macnak <natsu@google.com>2020-06-01 17:34:47 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-01 17:34:47 +0000
commitf5c5d50a2e69e7c66715eff7c53c6abb07acc827 (patch)
treea00c94cd5e7378ab4a6c72aeebe070d3b3d3d735
parent31c0fadbc7b49262f0047d1f7b2a109aaae6dbdf (diff)
parent56412c960f4838173c8a1b0c92b1307ffe6c0efd (diff)
downloadswiftshader-android11-qpr1-s2-release.tar.gz
Change-Id: I6f38e506e607436248b1e132ddf8dae2573c1356
-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;
}