1 /* 2 * Copyright 2019 Google LLC 3 * SPDX-License-Identifier: MIT 4 */ 5 #pragma once 6 7 #if defined(ANDROID) 8 9 #include <vulkan/vulkan.h> 10 11 #include "gfxstream/guest/GfxStreamGralloc.h" 12 #include "HostVisibleMemoryVirtualization.h" 13 14 // Structure similar to 15 // https://github.com/mesa3d/mesa/blob/master/src/intel/vulkan/anv_android.c 16 17 namespace gfxstream { 18 namespace vk { 19 20 uint64_t getAndroidHardwareBufferUsageFromVkUsage(const VkImageCreateFlags vk_create, 21 const VkImageUsageFlags vk_usage); 22 23 void updateMemoryTypeBits(uint32_t* memoryTypeBits, uint32_t colorBufferMemoryIndex); 24 25 VkResult getAndroidHardwareBufferPropertiesANDROID( 26 gfxstream::Gralloc* grallocHelper, const AHardwareBuffer* buffer, 27 VkAndroidHardwareBufferPropertiesANDROID* pProperties); 28 29 VkResult getMemoryAndroidHardwareBufferANDROID(gfxstream::Gralloc* grallocHelper, 30 struct AHardwareBuffer** pBuffer); 31 32 VkResult importAndroidHardwareBuffer(gfxstream::Gralloc* grallocHelper, 33 const VkImportAndroidHardwareBufferInfoANDROID* info, 34 struct AHardwareBuffer** importOut); 35 36 VkResult createAndroidHardwareBuffer(gfxstream::Gralloc* grallocHelper, bool hasDedicatedImage, 37 bool hasDedicatedBuffer, const VkExtent3D& imageExtent, 38 uint32_t imageLayers, VkFormat imageFormat, 39 VkImageUsageFlags imageUsage, 40 VkImageCreateFlags imageCreateFlags, VkDeviceSize bufferSize, 41 VkDeviceSize allocationInfoAllocSize, 42 struct AHardwareBuffer** out); 43 44 } // namespace vk 45 } // namespace gfxstream 46 47 #endif // ANDROID 48