From fc85128c411af240476b085ec25ca8ad5d440bd6 Mon Sep 17 00:00:00 2001 From: Park Joon-Kyu Date: Thu, 2 Jan 2020 17:10:04 +0900 Subject: [PATCH] Expose FFI for Wayland --- ffi/wgpu.h | 6 ++++-- wgpu-native/src/device.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 5b40400fdf..82864978ce 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* Generated with cbindgen:0.11.1 */ +/* Generated with cbindgen:0.12.1 */ /* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. * To generate this file: @@ -741,9 +741,11 @@ void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipeli WGPUSurfaceId wgpu_create_surface_from_metal_layer(void *layer); +WGPUSurfaceId wgpu_create_surface_from_wayland(void *surface, void *display); + WGPUSurfaceId wgpu_create_surface_from_windows_hwnd(void *_hinstance, void *hwnd); -WGPUSurfaceId wgpu_create_surface_from_xlib(const void **display, uint64_t window); +WGPUSurfaceId wgpu_create_surface_from_xlib(const void **display, unsigned long window); WGPUBindGroupId wgpu_device_create_bind_group(WGPUDeviceId device_id, const WGPUBindGroupDescriptor *desc); diff --git a/wgpu-native/src/device.rs b/wgpu-native/src/device.rs index 32553b1fb3..7ad656bd73 100644 --- a/wgpu-native/src/device.rs +++ b/wgpu-native/src/device.rs @@ -90,6 +90,19 @@ pub extern "C" fn wgpu_create_surface_from_xlib( })) } +#[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))] +#[no_mangle] +pub extern "C" fn wgpu_create_surface_from_wayland( + surface: *mut std::ffi::c_void, + display: *mut std::ffi::c_void, +) -> id::SurfaceId { + use raw_window_handle::unix::WaylandHandle; + wgpu_create_surface(raw_window_handle::RawWindowHandle::Wayland(WaylandHandle { + surface, display, + ..WaylandHandle::empty() + })) +} + #[cfg(any(target_os = "ios", target_os = "macos"))] #[no_mangle] pub extern "C" fn wgpu_create_surface_from_metal_layer(