Merge "remove ahb buffer host not visiable limitation." am: c25f7c9cbf am: 70cb828511
Original change: https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/2333788
Change-Id: Ie381da2b870c0da9a8ccb04f7dd3bbb8d0da3b9b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/system/vulkan_enc/AndroidHardwareBuffer.cpp b/system/vulkan_enc/AndroidHardwareBuffer.cpp
index 48dfc57..057b7e7 100644
--- a/system/vulkan_enc/AndroidHardwareBuffer.cpp
+++ b/system/vulkan_enc/AndroidHardwareBuffer.cpp
@@ -25,6 +25,7 @@
#include "vk_format_info.h"
#include "vk_util.h"
+#include <assert.h>
namespace goldfish_vk {
@@ -230,17 +231,8 @@
if (!colorBufferHandle) {
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
-
- // Disallow host visible (hard to make actual dedicated allocs)
- uint32_t memoryTypeBits = 0;
- for (uint32_t i = 0; i < memProps->memoryTypeCount; ++i) {
- if (isHostVisible(memProps, i))
- continue;
-
- memoryTypeBits |= (1 << i);
- }
-
- pProperties->memoryTypeBits = memoryTypeBits;
+ assert(memProps->memoryTypeCount < VK_MAX_MEMORY_TYPES);
+ pProperties->memoryTypeBits = (1u << memProps->memoryTypeCount) - 1;
pProperties->allocationSize =
grallocHelper->getAllocatedSize(handle);
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index 7a6a6b9..aebcdc0 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -3198,8 +3198,7 @@
!isHostVisible(&mMemoryProps, pAllocateInfo->memoryTypeIndex);
if (!exportAllocateInfoPtr &&
- (importAhbInfoPtr || importBufferCollectionInfoPtr ||
- importVmoInfoPtr) &&
+ ( importBufferCollectionInfoPtr || importVmoInfoPtr) &&
dedicatedAllocInfoPtr &&
isHostVisible(&mMemoryProps, pAllocateInfo->memoryTypeIndex)) {
ALOGE(
@@ -3660,7 +3659,7 @@
}
#endif
- if (!isHostVisible(&mMemoryProps, finalAllocInfo.memoryTypeIndex)) {
+ if (ahw || !isHostVisible(&mMemoryProps, finalAllocInfo.memoryTypeIndex)) {
input_result =
enc->vkAllocateMemory(
device, &finalAllocInfo, pAllocator, pMemory, true /* do lock */);
@@ -3864,10 +3863,6 @@
uint32_t res = 0;
for (uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; ++i) {
bool shouldAcceptMemoryIndex = normalBits & (1 << i);
-#if defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(__linux__)
- shouldAcceptMemoryIndex &= !isHostVisible(&mMemoryProps, i);
-#endif // VK_USE_PLATFORM_FUCHSIA
-
if (shouldAcceptMemoryIndex) {
res |= (1 << i);
}