Skip to content

Commit

Permalink
feat(gles): support gles backend on openharmony (#7085)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
richerfu and cwfitzgerald authored Feb 13, 2025
1 parent 0f5d575 commit ff90773
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 13 additions & 7 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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> =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff90773

Please sign in to comment.