Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 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 | |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 17 | #include <vulkan/vulkan.h> |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 18 | |
Jason Macnak | abe57a8 | 2024-02-02 17:02:21 -0800 | [diff] [blame] | 19 | #include "gfxstream/guest/Gralloc.h" |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 20 | #include "HostVisibleMemoryVirtualization.h" |
| 21 | |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 22 | // Structure similar to |
| 23 | // https://github.com/mesa3d/mesa/blob/master/src/intel/vulkan/anv_android.c |
| 24 | |
Jason Macnak | 3d66400 | 2023-03-30 16:00:50 -0700 | [diff] [blame] | 25 | namespace gfxstream { |
| 26 | namespace vk { |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 27 | |
Gurchetan Singh | c4444b8 | 2023-09-19 08:06:20 -0700 | [diff] [blame] | 28 | uint64_t getAndroidHardwareBufferUsageFromVkUsage(const VkImageCreateFlags vk_create, |
| 29 | const VkImageUsageFlags vk_usage); |
Lingfeng Yang | e517d1e | 2019-03-25 18:02:49 -0700 | [diff] [blame] | 30 | |
Gurchetan Singh | d56274b | 2023-04-10 10:34:16 -0700 | [diff] [blame] | 31 | void updateMemoryTypeBits(uint32_t* memoryTypeBits, uint32_t colorBufferMemoryIndex); |
Jason Macnak | 66e397b | 2023-03-15 12:11:22 -0700 | [diff] [blame] | 32 | |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 33 | VkResult getAndroidHardwareBufferPropertiesANDROID( |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 34 | gfxstream::Gralloc* grallocHelper, const AHardwareBuffer* buffer, |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 35 | VkAndroidHardwareBufferPropertiesANDROID* pProperties); |
| 36 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 37 | VkResult getMemoryAndroidHardwareBufferANDROID(gfxstream::Gralloc* grallocHelper, |
| 38 | struct AHardwareBuffer** pBuffer); |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 39 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 40 | VkResult importAndroidHardwareBuffer(gfxstream::Gralloc* grallocHelper, |
| 41 | const VkImportAndroidHardwareBufferInfoANDROID* info, |
| 42 | struct AHardwareBuffer** importOut); |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 43 | |
Gurchetan Singh | fa4dfda | 2023-09-18 17:11:24 -0700 | [diff] [blame] | 44 | VkResult createAndroidHardwareBuffer(gfxstream::Gralloc* grallocHelper, bool hasDedicatedImage, |
| 45 | bool hasDedicatedBuffer, const VkExtent3D& imageExtent, |
| 46 | uint32_t imageLayers, VkFormat imageFormat, |
| 47 | VkImageUsageFlags imageUsage, |
| 48 | VkImageCreateFlags imageCreateFlags, VkDeviceSize bufferSize, |
| 49 | VkDeviceSize allocationInfoAllocSize, |
| 50 | struct AHardwareBuffer** out); |
Lingfeng Yang | 9b82e33 | 2019-02-13 17:53:57 -0800 | [diff] [blame] | 51 | |
Jason Macnak | 3d66400 | 2023-03-30 16:00:50 -0700 | [diff] [blame] | 52 | } // namespace vk |
| 53 | } // namespace gfxstream |