diff options
author | Yahan Zhou <yahan@google.com> | 2023-09-14 16:24:26 -0700 |
---|---|---|
committer | Yahan Zhou <yahan@google.com> | 2024-01-23 23:45:50 +0000 |
commit | 5af28d489a715b4b07b55324ff2bc3968dc652ff (patch) | |
tree | 0d31979d459a03f3e13d9e87176addd0df4e7d48 | |
parent | 247fe730e52f757de17d935ce3be3463c0e121c6 (diff) | |
download | gfxstream-5af28d489a715b4b07b55324ff2bc3968dc652ff.tar.gz |
Declare AHB blob unsupported in Vulkan
It diverged between old gralloc and minigbm.
Test: dEQP-VK.api.external.memory.android_hardware_buffer.*
Bug: 299520213
Merged-In: If0c1896c6acef97db9ec3ae3abfe88eea333b42f
Change-Id: I029cfb0765b0265409c71d4a6732275b385a4901
(cherry picked from commit 79ab57ae3c380a1aef8f3c216e162a2947f027fa)
-rw-r--r-- | guest/OpenglSystemCommon/Gralloc.h | 2 | ||||
-rw-r--r-- | guest/OpenglSystemCommon/GrallocGoldfish.cpp | 2 | ||||
-rw-r--r-- | guest/OpenglSystemCommon/GrallocGoldfish.h | 2 | ||||
-rw-r--r-- | guest/vulkan_enc/ResourceTracker.cpp | 16 |
4 files changed, 21 insertions, 1 deletions
diff --git a/guest/OpenglSystemCommon/Gralloc.h b/guest/OpenglSystemCommon/Gralloc.h index f5c99cfa..8d59f0b2 100644 --- a/guest/OpenglSystemCommon/Gralloc.h +++ b/guest/OpenglSystemCommon/Gralloc.h @@ -61,6 +61,8 @@ class Gralloc { virtual size_t getAllocatedSize(const native_handle_t* handle) = 0; virtual size_t getAllocatedSize(const AHardwareBuffer* handle) = 0; + + virtual bool treatBlobAsImage() { return false; }; }; } // namespace gfxstream diff --git a/guest/OpenglSystemCommon/GrallocGoldfish.cpp b/guest/OpenglSystemCommon/GrallocGoldfish.cpp index eac99ca5..b32562a6 100644 --- a/guest/OpenglSystemCommon/GrallocGoldfish.cpp +++ b/guest/OpenglSystemCommon/GrallocGoldfish.cpp @@ -79,4 +79,6 @@ size_t GoldfishGralloc::getAllocatedSize(const AHardwareBuffer* ahb) { return getAllocatedSize(handle); } +bool GoldfishGralloc::treatBlobAsImage() { return true; } + } // namespace gfxstream diff --git a/guest/OpenglSystemCommon/GrallocGoldfish.h b/guest/OpenglSystemCommon/GrallocGoldfish.h index 16fa8e5b..2d7b9faf 100644 --- a/guest/OpenglSystemCommon/GrallocGoldfish.h +++ b/guest/OpenglSystemCommon/GrallocGoldfish.h @@ -40,6 +40,8 @@ class GoldfishGralloc : public Gralloc { size_t getAllocatedSize(const native_handle_t* handle) override; size_t getAllocatedSize(const AHardwareBuffer* handle) override; + + bool treatBlobAsImage() override; }; diff --git a/guest/vulkan_enc/ResourceTracker.cpp b/guest/vulkan_enc/ResourceTracker.cpp index 202090ae..b2affa9c 100644 --- a/guest/vulkan_enc/ResourceTracker.cpp +++ b/guest/vulkan_enc/ResourceTracker.cpp @@ -3444,7 +3444,8 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper(); const uint32_t hostHandle = gralloc->getHostHandle(ahw); - if (gralloc->getFormat(ahw) == AHARDWAREBUFFER_FORMAT_BLOB) { + if (gralloc->getFormat(ahw) == AHARDWAREBUFFER_FORMAT_BLOB && + !gralloc->treatBlobAsImage()) { importBufferInfo.buffer = hostHandle; vk_append_struct(&structChainIter, &importBufferInfo); } else { @@ -6496,6 +6497,19 @@ void ResourceTracker::on_vkGetPhysicalDeviceExternalBufferProperties_common( VkExternalBufferProperties* pExternalBufferProperties) { VkEncoder* enc = (VkEncoder*)context; + // Older versions of Goldfish's Gralloc did not support allocating AHARDWAREBUFFER_FORMAT_BLOB + // with GPU usage (b/299520213). + if (ResourceTracker::threadingCallbacks.hostConnectionGetFunc() + ->grallocHelper() + ->treatBlobAsImage() && + pExternalBufferInfo->handleType == + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) { + pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0; + pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = 0; + pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = 0; + return; + } + uint32_t supportedHandleType = 0; #ifdef VK_USE_PLATFORM_FUCHSIA supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA; |