1 /// Copyright (C) 2019 The Android Open Source Project 2 // Copyright (C) 2019 Google Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 #pragma once 16 17 #include "HostVisibleMemoryVirtualization.h" 18 19 #include <vulkan/vulkan.h> 20 #include <vndk/hardware_buffer.h> 21 22 // Structure similar to 23 // https://github.com/mesa3d/mesa/blob/master/src/intel/vulkan/anv_android.c 24 25 class Gralloc; 26 27 namespace goldfish_vk { 28 29 uint64_t 30 getAndroidHardwareBufferUsageFromVkUsage( 31 const VkImageCreateFlags vk_create, 32 const VkImageUsageFlags vk_usage); 33 34 VkResult getAndroidHardwareBufferPropertiesANDROID( 35 Gralloc* grallocHelper, 36 const HostVisibleMemoryVirtualizationInfo* hostMemVirtInfo, 37 VkDevice device, 38 const AHardwareBuffer* buffer, 39 VkAndroidHardwareBufferPropertiesANDROID* pProperties); 40 41 VkResult getMemoryAndroidHardwareBufferANDROID( 42 struct AHardwareBuffer **pBuffer); 43 44 VkResult importAndroidHardwareBuffer( 45 Gralloc* grallocHelper, 46 const VkImportAndroidHardwareBufferInfoANDROID* info, 47 struct AHardwareBuffer **importOut); 48 49 VkResult createAndroidHardwareBuffer( 50 bool hasDedicatedImage, 51 bool hasDedicatedBuffer, 52 const VkExtent3D& imageExtent, 53 uint32_t imageLayers, 54 VkFormat imageFormat, 55 VkImageUsageFlags imageUsage, 56 VkImageCreateFlags imageCreateFlags, 57 VkDeviceSize bufferSize, 58 VkDeviceSize allocationInfoAllocSize, 59 struct AHardwareBuffer **out); 60 61 } // namespace goldfish_vk 62