feat(gles): support gles backend on openharmony (#7085)

* fix(gles): fix gles backend crash on openharmony

* docs: add changelog

* ci: add OpenHarmony to CI

* Update .github/workflows/ci.yml

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
richerfu 2025-02-13 11:01:50 +08:00 committed by GitHub
parent 0f5d575ef3
commit ff907736ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 7 deletions

View File

@ -145,6 +145,13 @@ jobs:
tier: 2
kind: native
# OpenHarmony
- name: OpenHarmony aarch64
os: ubuntu-22.04
target: aarch64-unknown-linux-ohos
tier: 2
kind: native
# WebGPU/WebGL
- name: WebAssembly
os: ubuntu-22.04

View File

@ -103,6 +103,10 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).
- Stop naga causing undefined behavior when a ray query misses. By @Vecvec in [#6752](https://github.com/gfx-rs/wgpu/pull/6752).
#### Gles
- Support OpenHarmony render with `gles`. By @richerfu in [#7085](https://github.com/gfx-rs/wgpu/pull/7085)
#### Dx12
- Fix HLSL storage format generation. By @Vecvec in [#6993](https://github.com/gfx-rs/wgpu/pull/6993) and [#7104](https://github.com/gfx-rs/wgpu/pull/7104)

View File

@ -259,11 +259,12 @@ fn choose_config(
log::warn!("EGL says it can present to the window but not natively",);
}
// Android emulator can't natively present either.
let tier_threshold = if cfg!(target_os = "android") || cfg!(windows) {
1
} else {
2
};
let tier_threshold =
if cfg!(target_os = "android") || cfg!(windows) || cfg!(target_env = "ohos") {
1
} else {
2
};
return Ok((config, tier_max >= tier_threshold));
}
Ok(None) => {
@ -956,6 +957,7 @@ impl crate::Instance for Instance {
(Rwh::Xcb(_), _) => {}
(Rwh::Win32(_), _) => {}
(Rwh::AppKit(_), _) => {}
(Rwh::OhosNdk(_), _) => {}
#[cfg(target_os = "android")]
(Rwh::AndroidNdk(handle), _) => {
let format = inner
@ -1306,6 +1308,7 @@ impl crate::Surface for Surface {
(WindowKind::Unknown, Rwh::AndroidNdk(handle)) => {
handle.a_native_window.as_ptr()
}
(WindowKind::Unknown, Rwh::OhosNdk(handle)) => handle.native_window.as_ptr(),
(WindowKind::Wayland, Rwh::Wayland(handle)) => {
let library = &self.wsi.display_owner.as_ref().unwrap().library;
let wl_egl_window_create: libloading::Symbol<WlEglWindowCreateFun> =
@ -1349,8 +1352,11 @@ impl crate::Surface for Surface {
// We don't want any of the buffering done by the driver, because we
// manage a swapchain on our side.
// Some drivers just fail on surface creation seeing `EGL_SINGLE_BUFFER`.
if cfg!(any(target_os = "android", target_os = "macos"))
|| cfg!(windows)
if cfg!(any(
target_os = "android",
target_os = "macos",
target_env = "ohos"
)) || cfg!(windows)
|| self.wsi.kind == WindowKind::AngleX11
{
khronos_egl::BACK_BUFFER