From 01ad5e6ce119e180e72cf929ebe0f075c5a6eb28 Mon Sep 17 00:00:00 2001 From: Eshed Shaham Date: Fri, 1 Mar 2024 11:48:42 +0100 Subject: [PATCH] wgpu-hal: add ndk-sys dependency to fix linking error. This issue is invisible in the tests, since the dev dependencies include winit which itself depends on ndk-sys when using android. --- CHANGELOG.md | 1 + Cargo.lock | 1 + wgpu-hal/Cargo.toml | 1 + wgpu-hal/src/gles/egl.rs | 17 ++++++----------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e445ef1f2..9d62244cb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ Bottom level categories: - Fix registry leaks with de-duplicated resources. By @nical in [#5244](https://github.com/gfx-rs/wgpu/pull/5244) - Fix behavior of integer `clamp` when `min` argument > `max` argument. By @cwfitzgerald in [#5300](https://github.com/gfx-rs/wgpu/pull/5300). - Fix missing validation for `Device::clear_buffer` where `offset + size buffer.size` was not checked when `size` was omitted. By @ErichDonGubler in [#5282](https://github.com/gfx-rs/wgpu/pull/5282). +- Fix linking when targeting android. By @ashdnazg in [#5326](https://github.com/gfx-rs/wgpu/pull/5326). #### glsl-in diff --git a/Cargo.lock b/Cargo.lock index 2da12e75b9..e31c719935 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4074,6 +4074,7 @@ dependencies = [ "log", "metal", "naga", + "ndk-sys 0.5.0+25.2.9519653", "objc", "once_cell", "parking_lot", diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index b996871363..ab4bb61a85 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -166,6 +166,7 @@ libc = "0.2" [target.'cfg(target_os = "android")'.dependencies] android_system_properties = "0.1.1" +ndk-sys = "0.5.0" [dependencies.naga] path = "../naga" diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 9eb5fa66a4..874ad1729f 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -50,16 +50,6 @@ type WlEglWindowResizeFun = unsafe extern "system" fn( type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const raw::c_void); -#[cfg(target_os = "android")] -extern "C" { - pub fn ANativeWindow_setBuffersGeometry( - window: *mut raw::c_void, - width: i32, - height: i32, - format: i32, - ) -> i32; -} - type EglLabel = *const raw::c_void; #[allow(clippy::upper_case_acronyms)] @@ -864,7 +854,12 @@ impl crate::Instance for Instance { .unwrap(); let ret = unsafe { - ANativeWindow_setBuffersGeometry(handle.a_native_window.as_ptr(), 0, 0, format) + ndk_sys::ANativeWindow_setBuffersGeometry( + handle.a_native_window.as_ptr() as *mut ndk_sys::ANativeWindow, + 0, + 0, + format, + ) }; if ret != 0 {