• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 gfxstream {
28 namespace vk {
29 
30 uint64_t
31 getAndroidHardwareBufferUsageFromVkUsage(
32     const VkImageCreateFlags vk_create,
33     const VkImageUsageFlags vk_usage);
34 
35 void updateMemoryTypeBits(uint32_t* memoryTypeBits, uint32_t colorBufferMemoryIndex);
36 
37 VkResult getAndroidHardwareBufferPropertiesANDROID(
38     Gralloc* grallocHelper,
39     const AHardwareBuffer* buffer,
40     VkAndroidHardwareBufferPropertiesANDROID* pProperties);
41 
42 VkResult getMemoryAndroidHardwareBufferANDROID(
43     struct AHardwareBuffer **pBuffer);
44 
45 VkResult importAndroidHardwareBuffer(
46     Gralloc* grallocHelper,
47     const VkImportAndroidHardwareBufferInfoANDROID* info,
48     struct AHardwareBuffer **importOut);
49 
50 VkResult createAndroidHardwareBuffer(
51     bool hasDedicatedImage,
52     bool hasDedicatedBuffer,
53     const VkExtent3D& imageExtent,
54     uint32_t imageLayers,
55     VkFormat imageFormat,
56     VkImageUsageFlags imageUsage,
57     VkImageCreateFlags imageCreateFlags,
58     VkDeviceSize bufferSize,
59     VkDeviceSize allocationInfoAllocSize,
60     struct AHardwareBuffer **out);
61 
62 }  // namespace vk
63 }  // namespace gfxstream
64