diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-02 01:00:49 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-02 01:00:49 +0000 |
commit | 8f231bbdc550295c99e8314b96d4d9507b2299b7 (patch) | |
tree | a00c94cd5e7378ab4a6c72aeebe070d3b3d3d735 | |
parent | e7edcd798fc6272d0c6eaae3f61980122d7d9562 (diff) | |
parent | 56412c960f4838173c8a1b0c92b1307ffe6c0efd (diff) | |
download | swiftshader-android11-d1-s7-release.tar.gz |
Snap for 6548979 from 56412c960f4838173c8a1b0c92b1307ffe6c0efd to rvc-d1-releaseandroid-11.0.0_r9android-11.0.0_r8android-11.0.0_r7android-11.0.0_r15android-11.0.0_r14android-11.0.0_r13android-11.0.0_r12android-11.0.0_r11android-11.0.0_r10android11-d1-s7-releaseandroid11-d1-s6-releaseandroid11-d1-s5-releaseandroid11-d1-s1-releaseandroid11-d1-release
Change-Id: Idbd63f45ff546ef6ae69beee84205f8bf85a5dac
-rw-r--r-- | src/Common/GrallocAndroid.cpp | 2 | ||||
-rw-r--r-- | src/System/GrallocAndroid.cpp | 2 | ||||
-rw-r--r-- | src/Vulkan/VkImage.cpp | 19 |
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; } |