1 /*
2  * Copyright (c) 2024 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 
16 #ifndef VULKAN_OHOS_PLATFORM_VK_H
17 #define VULKAN_OHOS_PLATFORM_VK_H
18 
19 #include <vulkan/vulkan.h>
20 #include <vulkan/vulkan_ohos.h>
21 
22 #include <base/containers/string_view.h>
23 #include <base/containers/unordered_map.h>
24 #include <base/containers/vector.h>
25 #include <render/namespace.h>
26 
27 RENDER_BEGIN_NAMESPACE()
28 struct PlatformDeviceExtensions {
29     // hardware buffers supported
30     bool externalMemoryHardwareBuffer { false };
31 };
32 
33 struct PlatformExtFunctions {
34     // VK_OpenHarmony_external_memory_OHOS_native_buffer
35     PFN_vkGetNativeBufferPropertiesOHOS vkGetNativeBufferPropertiesOHOS { nullptr };
36     PFN_vkGetMemoryNativeBufferOHOS vkGetMemoryNativeBufferOHOS { nullptr };
37 };
38 
39 void GetPlatformDeviceExtensions(BASE_NS::vector<BASE_NS::string_view>& extensions);
40 
41 PlatformDeviceExtensions GetEnabledPlatformDeviceExtensions(
42     const BASE_NS::unordered_map<BASE_NS::string, uint32_t>& enabledDeviceExtensions);
43 
GetPlatformSurfaceName()44 inline const char* GetPlatformSurfaceName()
45 {
46     return VK_OHOS_SURFACE_EXTENSION_NAME;
47 }
48 
CanDevicePresent(VkInstance instance,VkPhysicalDevice device,uint32_t queuefamily)49 inline bool CanDevicePresent(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily)
50 {
51     return true;
52 }
53 RENDER_END_NAMESPACE()
54 #endif // VULKAN_OHOS_PLATFORM_VK_H
55