• 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 <vulkan/vulkan.h>
18 
19 #include "gfxstream/guest/Gralloc.h"
20 #include "HostVisibleMemoryVirtualization.h"
21 
22 // Structure similar to
23 // https://github.com/mesa3d/mesa/blob/master/src/intel/vulkan/anv_android.c
24 
25 namespace gfxstream {
26 namespace vk {
27 
28 uint64_t getAndroidHardwareBufferUsageFromVkUsage(const VkImageCreateFlags vk_create,
29                                                   const VkImageUsageFlags vk_usage);
30 
31 void updateMemoryTypeBits(uint32_t* memoryTypeBits, uint32_t colorBufferMemoryIndex);
32 
33 VkResult getAndroidHardwareBufferPropertiesANDROID(
34     gfxstream::Gralloc* grallocHelper, const AHardwareBuffer* buffer,
35     VkAndroidHardwareBufferPropertiesANDROID* pProperties);
36 
37 VkResult getMemoryAndroidHardwareBufferANDROID(gfxstream::Gralloc* grallocHelper,
38                                                struct AHardwareBuffer** pBuffer);
39 
40 VkResult importAndroidHardwareBuffer(gfxstream::Gralloc* grallocHelper,
41                                      const VkImportAndroidHardwareBufferInfoANDROID* info,
42                                      struct AHardwareBuffer** importOut);
43 
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);
51 
52 }  // namespace vk
53 }  // namespace gfxstream
54