Always pass through VkMemoryDedicatedAllocateInfo to host
... as the host may use dedicated allocs to back the external
memory for Buffer/ColorBuffer.
Bug: b/265186355
Test: cvd start --gpu_mode=gfxstream (with AMD GPU)
Test: cvd start --gpu_mode=gfxstream (with Nvidia GPU)
Change-Id: Iba62717323d1066c5afbae32aa19961e5cf0831b
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index aebcdc0..195cb16 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -3188,8 +3188,20 @@
const VkMemoryDedicatedAllocateInfo* dedicatedAllocInfoPtr =
vk_find_struct<VkMemoryDedicatedAllocateInfo>(pAllocateInfo);
+ // Note for AHardwareBuffers, the Vulkan spec states:
+ //
+ // Android hardware buffers have intrinsic width, height, format, and usage
+ // properties, so Vulkan images bound to memory imported from an Android
+ // hardware buffer must use dedicated allocations
+ //
+ // so any allocation requests with a VkImportAndroidHardwareBufferInfoANDROID
+ // will necessarily have a VkMemoryDedicatedAllocateInfo. However, the host
+ // may or may not actually use a dedicated allocation to emulate
+ // AHardwareBuffers. As such, the VkMemoryDedicatedAllocateInfo is passed to the
+ // host and the host will decide whether or not to use it.
+
bool shouldPassThroughDedicatedAllocInfo =
- !exportAllocateInfoPtr && !importAhbInfoPtr &&
+ !exportAllocateInfoPtr &&
!importBufferCollectionInfoPtr &&
!importVmoInfoPtr;