• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __VK_OHOS_NATIVE_BUFFER_H__
16 #define __VK_OHOS_NATIVE_BUFFER_H__
17 
18 #include <buffer_handle.h>
19 #include <vulkan/vulkan.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define VK_OHOS_native_buffer 1
26 
27 #define VK_OHOS_NATIVE_BUFFER_SPEC_VERSION 1
28 #define VK_OHOS_NATIVE_BUFFER_EXTENSION_NAME "VK_OHOS_native_buffer"
29 
30 typedef VkFlags VkSwapchainImageUsageFlagsOpenHarmony;
31 typedef enum VkSwapchainImageUsageFlagBitsOpenHarmony {
32     VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_OPENHARMONY = 0x00000001,
33     VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
34 } VkSwapchainImageUsageFlagBitsOHOS;
35 
36 typedef struct {
37     VkStructureType                   sType;
38     const void*                       pNext;
39     BufferHandle*                     handle;
40 } VkNativeBufferOpenHarmony;
41 
42 typedef struct {
43     VkStructureType                   sType;
44     const void*                       pNext;
45     VkSwapchainImageUsageFlagsOpenHarmony    usage;
46 } VkSwapchainImageCreateInfoOpenHarmony;
47 
48 typedef struct {
49     VkStructureType                   sType;
50     const void*                       pNext;
51     VkBool32                          sharedImage;
52 } VkPhysicalDevicePresentationPropertiesOpenHarmony;
53 
54 typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageOpenHarmony)(
55     VkDevice                          device,
56     VkFormat                          format,
57     VkImageUsageFlags                 imageUsage,
58     uint64_t*                         grallocUsage);
59 
60 typedef VkResult (VKAPI_PTR *PFN_vkSetNativeFenceFdOpenHarmony)(
61     VkDevice                          device,
62     int32_t                           nativeFenceFd,
63     VkSemaphore                       semaphore,
64     VkFence                           fence);
65 
66 typedef VkResult (VKAPI_PTR *PFN_vkGetNativeFenceFdOpenHarmony)(
67     VkQueue                           queue,
68     uint32_t                          waitSemaphoreCount,
69     const VkSemaphore*                pWaitSemaphores,
70     VkImage                           image,
71     int32_t*                          pNativeFenceFd);
72 
73 #ifndef VK_NO_PROTOTYPES
74 
75 VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageOpenHarmony(
76     VkDevice                          device,
77     VkFormat                          format,
78     VkImageUsageFlags                 imageUsage,
79     uint64_t*                         grallocUsage
80 );
81 
82 VKAPI_ATTR VkResult VKAPI_CALL vkSetNativeFenceFdOpenHarmony(
83     VkDevice                          device,
84     int32_t                           nativeFenceFd,
85     VkSemaphore                       semaphore,
86     VkFence                           fence
87 );
88 
89 VKAPI_ATTR VkResult VKAPI_CALL vkGetNativeFenceFdOpenHarmony(
90     VkQueue                           queue,
91     uint32_t                          waitSemaphoreCount,
92     const VkSemaphore*                pWaitSemaphores,
93     VkImage                           image,
94     int32_t*                          pNativeFenceFd
95 );
96 
97 #endif
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* __VK_OHOS_NATIVE_BUFFER_H__ */
104