Skip to content

Commit f25cbb1

Browse files
committed
Harmony port: video vulkan library & disable version test
1 parent 845ba7d commit f25cbb1

File tree

4 files changed

+132
-9
lines changed

4 files changed

+132
-9
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright (c) 2023 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_H
17+
#define VULKAN_OHOS_H 1
18+
19+
#include <vulkan/vulkan_core.h>
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
#define VK_KHR_OHOS_XCOMPONENT 1
26+
struct ONativeWindow;
27+
28+
#define VK_KHR_OHOS_XCOMPONENT_SPEC_VERSION 6
29+
#define VK_KHR_OHOS_XCOMPONENT_EXTENSION_NAME "VK_OHOS_surface"
30+
31+
typedef VkFlags VkOHOSXComponentCreateFlagsKHR;
32+
33+
typedef struct VkOHOSXComponentCreateInfoKHR {
34+
VkStructureType sType;
35+
const void* pNext;
36+
VkOHOSXComponentCreateFlagsKHR flags;
37+
struct OHNativeWindow* window;
38+
} VkOHOSXComponentCreateInfoKHR;
39+
40+
typedef VkResult (VKAPI_PTR *PFN_vkCreateOHOSXComponentKHR)(VkInstance instance,
41+
const VkOHOSXComponentCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator,
42+
VkSurfaceKHR* pXComponent);
43+
44+
#ifndef VK_NO_PROTOTYPES
45+
VKAPI_ATTR VkResult VKAPI_CALL vkCreateOHOSXComponentKHR(
46+
VkInstance instance,
47+
const VkOHOSXComponentCreateInfoKHR* pCreateInfo,
48+
const VkAllocationCallbacks* pAllocator,
49+
VkSurfaceKHR* pSurface);
50+
#endif
51+
52+
#define VK_OHOS_EXTERNAL_MEMORY_OHOS_HARDWARE_BUFFER 1
53+
struct OHardwareBuffer;
54+
55+
#define VK_OHOS_EXTERNAL_MEMORY_OHOS_HARDWARE_BUFFER_SPEC_VERSION 3
56+
#define VK_OHOS_EXTERNAL_MEMORY_OHOS_HARDWARE_BUFFER_EXTENSION_NAME "VK_OHOS_EXTERNAL_MEMORY_OHOS_HARDWARE_BUFFER"
57+
58+
typedef struct VkOHOSHardwareBufferUsageOHOS {
59+
VkStructureType sType;
60+
void* pNext;
61+
uint64_t ohosHardwareBufferUsage;
62+
} VkOHOSHardwareBufferUsageOHOS;
63+
64+
typedef struct VkOHOSHardwareBufferPropertiesOHOS {
65+
VkStructureType sType;
66+
void* pNext;
67+
VkDeviceSize allocationSize;
68+
uint32_t memoryTypeBits;
69+
} VkOHOSHardwareBufferPropertiesOHOS;
70+
71+
typedef struct VkOHOSHardwareBufferFormatPropertiesOHOS {
72+
VkStructureType sType;
73+
void* pNext;
74+
VkFormat format;
75+
uint64_t externalFormat;
76+
VkFormatFeatureFlags formatFeatures;
77+
VkComponentMapping samplerYcbcrConversionComponents;
78+
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
79+
VkSamplerYcbcrRange suggestedYcbcrRange;
80+
VkChromaLocation suggestedXChromaOffset;
81+
VkChromaLocation suggestedYChromaOffset;
82+
} VkOHOSHardwareBufferFormatPropertiesOHOS;
83+
84+
typedef struct VkImportOHOSHardwareBufferInfoOHOS {
85+
VkStructureType sType;
86+
const void* pNext;
87+
struct OHardwareBuffer* buffer;
88+
} VkImportOHOSHardwareBufferInfoOHOS;
89+
90+
typedef struct VkMemoryGetOHOSHardwareBufferInfoOHOS {
91+
VkStructureType sType;
92+
const void* pNext;
93+
VkDeviceMemory memory;
94+
} VkMemoryGetOHOSHardwareBufferInfoOHOS;
95+
96+
typedef struct VkExternalFormatOHOS {
97+
VkStructureType sType;
98+
void* pNext;
99+
uint64_t externalFormat;
100+
} VkExternalFormatOHOS;
101+
102+
103+
typedef VkResult (VKAPI_PTR *PFN_vkGetOHOSHardwareBufferPropertiesOHOS)(VkDevice device,
104+
const struct OHardwareBuffer* buffer, VkOHOSHardwareBufferPropertiesOHOS* pProperties);
105+
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryOHOSHardwareBufferOHOS)(VkDevice device,
106+
const VkMemoryGetOHOSHardwareBufferInfoOHOS* pInfo, struct OHardwareBuffer** pBuffer);
107+
108+
#ifndef VK_NO_PROTOTYPES
109+
VKAPI_ATTR VkResult VKAPI_CALL vkGetOHOSHardwareBufferPropertiesOHOS(
110+
VkDevice device,
111+
const struct OHardwareBuffer* buffer,
112+
VkOHOSHardwareBufferPropertiesOHOS* pProperties);
113+
114+
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryOHOSHardwareBufferOHOS(
115+
VkDevice device,
116+
const VkMemoryGetOHOSHardwareBufferInfoOHOS* pInfo,
117+
struct OHardwareBuffer** pBuffer);
118+
#endif
119+
120+
#ifdef __cplusplus
121+
}
122+
#endif
123+
124+
#endif

src/video/ohos/SDL_ohosvideo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static SDL_VideoDevice *OHOS_CreateDevice(void)
2525
#ifdef SDL_VIDEO_VULKAN
2626
device->Vulkan_LoadLibrary = OHOS_Vulkan_LoadLibrary;
2727
device->Vulkan_UnloadLibrary = OHOS_Vulkan_UnloadLibrary;
28+
device->Vulkan_GetInstanceExtensions = OHOS_Vulkan_GetInstanceExtensions;
2829
#endif
2930

3031

src/video/ohos/SDL_ohosvulkan.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "SDL_ohosvulkan.h"
22
#include "SDL_internal.h"
3-
#include "../khronos/vulkan/vulkan.h"
3+
#include "../khronos/vulkan/vulkan_ohos.h"
44

55
#ifdef SDL_VIDEO_DRIVER_OHOS
66

@@ -65,18 +65,15 @@ void OHOS_Vulkan_UnloadLibrary(SDL_VideoDevice *_this)
6565
}
6666
}
6767

68-
/*bool OHOS_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, SDL_Window *window, unsigned *count,
69-
const char **names)
68+
char const* const* OHOS_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count)
7069
{
7170
static const char *const extensionsForOHOS[] = {
7271
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_OHOS_XCOMPONENT_EXTENSION_NAME
7372
};
74-
if (!_this->vulkan_config.loader_handle) {
75-
SDL_SetError("Vulkan is not loaded");
76-
return false;
73+
if (count) {
74+
*count = SDL_arraysize(extensionsForOHOS);
7775
}
78-
return SDL_Vulkan_GetInstanceExtensions_Helper(
79-
count, names, SDL_arraysize(extensionsForOHOS), extensionsForOHOS);
80-
}*/
76+
return extensionsForOHOS;
77+
}
8178

8279
#endif

src/video/ohos/SDL_ohosvulkan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
bool OHOS_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
88
void OHOS_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
9+
char const* const* OHOS_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
910
#endif
1011

1112
#endif

0 commit comments

Comments
 (0)