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 namespace goldfish_vk { 26 27 uint64_t 28 getAndroidHardwareBufferUsageFromVkUsage( 29 const VkImageCreateFlags vk_create, 30 const VkImageUsageFlags vk_usage); 31 32 VkResult getAndroidHardwareBufferPropertiesANDROID( 33 const HostVisibleMemoryVirtualizationInfo* hostMemVirtInfo, 34 VkDevice device, 35 const AHardwareBuffer* buffer, 36 VkAndroidHardwareBufferPropertiesANDROID* pProperties); 37 38 VkResult getMemoryAndroidHardwareBufferANDROID( 39 struct AHardwareBuffer **pBuffer); 40 41 VkResult importAndroidHardwareBuffer( 42 const VkImportAndroidHardwareBufferInfoANDROID* info, 43 struct AHardwareBuffer **importOut); 44 45 VkResult createAndroidHardwareBuffer( 46 bool hasDedicatedImage, 47 bool hasDedicatedBuffer, 48 const VkExtent3D& imageExtent, 49 uint32_t imageLayers, 50 VkFormat imageFormat, 51 VkImageUsageFlags imageUsage, 52 VkImageCreateFlags imageCreateFlags, 53 VkDeviceSize bufferSize, 54 VkDeviceSize allocationInfoAllocSize, 55 struct AHardwareBuffer **out); 56 57 } // namespace goldfish_vk 58