Skip to content

Commit c4cea73

Browse files
committed
ash-window: Support OpenHarmony handles through VK_OHOS_surface
1 parent f4441d9 commit c4cea73

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ash-window/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ rust-version = "1.69.0"
2020

2121
[dependencies]
2222
ash = { path = "../ash", version = "0.38", default-features = false, features = ["std"] }
23-
raw-window-handle = "0.6"
23+
raw-window-handle = "0.6.2"
2424

2525
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
2626
raw-window-metal = "0.4"

ash-window/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
- Added support for `VK_OHOS_surface` (#xxx)
4+
35
## [0.13.0] - 2024-03-31
46

57
- Bumped MSRV from 1.59 to 1.69 for `winit 0.28` and `raw-window-handle 0.5.1`, and `CStr::from_bytes_until_nul`. (#709, #716, #746)

ash-window/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::os::raw::c_char;
55
use ash::{
66
ext::metal_surface,
77
khr::{android_surface, surface, wayland_surface, win32_surface, xcb_surface, xlib_surface},
8+
ohos::surface as ohos_surface,
89
vk, Entry, Instance, VkResult,
910
};
1011
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
@@ -94,6 +95,13 @@ pub unsafe fn create_surface(
9495
surface_fn.create_android_surface(&surface_desc, allocation_callbacks)
9596
}
9697

98+
(RawDisplayHandle::Ohos(_), RawWindowHandle::OhosNdk(window)) => {
99+
let surface_desc =
100+
vk::SurfaceCreateInfoOHOS::default().window(window.native_window.as_ptr());
101+
let surface_fn = ohos_surface::Instance::new(entry, instance);
102+
surface_fn.create_surface(&surface_desc, allocation_callbacks)
103+
}
104+
97105
#[cfg(target_os = "macos")]
98106
(RawDisplayHandle::AppKit(_), RawWindowHandle::AppKit(window)) => {
99107
use raw_window_metal::{appkit, Layer};
@@ -165,6 +173,12 @@ pub fn enumerate_required_extensions(
165173
&ANDROID_EXTS
166174
}
167175

176+
RawDisplayHandle::Ohos(_) => {
177+
const OHOS_EXTS: [*const c_char; 2] =
178+
[surface::NAME.as_ptr(), ohos_surface::NAME.as_ptr()];
179+
&OHOS_EXTS
180+
}
181+
168182
RawDisplayHandle::AppKit(_) | RawDisplayHandle::UiKit(_) => {
169183
const METAL_EXTS: [*const c_char; 2] =
170184
[surface::NAME.as_ptr(), metal_surface::NAME.as_ptr()];

0 commit comments

Comments
 (0)