(Reland) Always pass through VkMemoryDedicatedAllocateInfo to host
... as the host may use dedicated allocs to back the external
memory for Buffer/ColorBuffer.
Reland note: no changes versus previous aosp/2394632
Bug: b/265186355
Test: cvd start --gpu_mode=gfxstream (with AMD GPU)
Test: cvd start --gpu_mode=gfxstream (with Nvidia GPU)
Change-Id: Ic2fff6a1ac17b5d8766602d25d336da375cfaee2
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index c5f1985..5c1bd72 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -3204,8 +3204,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;