blob: 5b2bef5271769d4c4752b6d76217a12b19f4c0f6 [file] [log] [blame]
Lingfeng Yang9b82e332019-02-13 17:53:57 -08001/// 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 Yang9b82e332019-02-13 17:53:57 -080017#include <vulkan/vulkan.h>
Lingfeng Yang9b82e332019-02-13 17:53:57 -080018
Jason Macnakabe57a82024-02-02 17:02:21 -080019#include "gfxstream/guest/Gralloc.h"
Gurchetan Singhfa4dfda2023-09-18 17:11:24 -070020#include "HostVisibleMemoryVirtualization.h"
21
Lingfeng Yang9b82e332019-02-13 17:53:57 -080022// Structure similar to
23// https://github.com/mesa3d/mesa/blob/master/src/intel/vulkan/anv_android.c
24
Jason Macnak3d664002023-03-30 16:00:50 -070025namespace gfxstream {
26namespace vk {
Lingfeng Yang9b82e332019-02-13 17:53:57 -080027
Gurchetan Singhc4444b82023-09-19 08:06:20 -070028uint64_t getAndroidHardwareBufferUsageFromVkUsage(const VkImageCreateFlags vk_create,
29 const VkImageUsageFlags vk_usage);
Lingfeng Yange517d1e2019-03-25 18:02:49 -070030
Gurchetan Singhd56274b2023-04-10 10:34:16 -070031void updateMemoryTypeBits(uint32_t* memoryTypeBits, uint32_t colorBufferMemoryIndex);
Jason Macnak66e397b2023-03-15 12:11:22 -070032
Lingfeng Yang9b82e332019-02-13 17:53:57 -080033VkResult getAndroidHardwareBufferPropertiesANDROID(
Gurchetan Singhfa4dfda2023-09-18 17:11:24 -070034 gfxstream::Gralloc* grallocHelper, const AHardwareBuffer* buffer,
Lingfeng Yang9b82e332019-02-13 17:53:57 -080035 VkAndroidHardwareBufferPropertiesANDROID* pProperties);
36
Gurchetan Singhfa4dfda2023-09-18 17:11:24 -070037VkResult getMemoryAndroidHardwareBufferANDROID(gfxstream::Gralloc* grallocHelper,
38 struct AHardwareBuffer** pBuffer);
Lingfeng Yang9b82e332019-02-13 17:53:57 -080039
Gurchetan Singhfa4dfda2023-09-18 17:11:24 -070040VkResult importAndroidHardwareBuffer(gfxstream::Gralloc* grallocHelper,
41 const VkImportAndroidHardwareBufferInfoANDROID* info,
42 struct AHardwareBuffer** importOut);
Lingfeng Yang9b82e332019-02-13 17:53:57 -080043
Gurchetan Singhfa4dfda2023-09-18 17:11:24 -070044VkResult 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 Yang9b82e332019-02-13 17:53:57 -080051
Jason Macnak3d664002023-03-30 16:00:50 -070052} // namespace vk
53} // namespace gfxstream