diff --git a/.travis.yml b/.travis.yml index 3affc72cc..d964dc870 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,6 @@ script: - cargo test - (cd wgpu-native && cargo check --features local,glutin) # TODO: Temporarily only test building the gl backend, properly test when it is usable from C - - if [[ $TRAVIS_OS_NAME == "linux" ]]; then cd wgpu-native && cargo check --features winit-vulkan; fi - if [[ $TRAVIS_OS_NAME == "linux" ]]; then cargo check --release; fi - if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo +nightly install cbindgen; fi - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME == "windows" ]]; then diff --git a/Cargo.lock b/Cargo.lock index 9339cda4a..821f2605e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,7 +313,6 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "spirv_cross 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", "wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -331,7 +330,6 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "spirv_cross 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -340,7 +338,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gfx-hal 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -384,7 +381,6 @@ dependencies = [ "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "spirv_cross 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -402,7 +398,6 @@ dependencies = [ "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -627,14 +622,6 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "lock_api" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lock_api" version = "0.3.1" @@ -826,16 +813,6 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot" version = "0.9.0" @@ -858,21 +835,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot_core" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot_core" version = "0.6.1" @@ -1014,6 +976,14 @@ name = "range-alloc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "raw-window-handle" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rdrand" version = "0.4.0" @@ -1449,7 +1419,7 @@ dependencies = [ [[package]] name = "wgpu-native" -version = "0.2.6" +version = "0.3.0" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1464,11 +1434,11 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rendy-descriptor 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rendy-memory 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1477,9 +1447,9 @@ version = "0.1.0" dependencies = [ "ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu-native 0.2.6", + "wgpu-native 0.3.0", ] [[package]] @@ -1667,7 +1637,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" @@ -1689,10 +1658,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a7bbaa05312363e0480e1efee133fff1a09ef4a6406b65e226b9a793c223a32" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" @@ -1709,6 +1676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5927936723a9e8b715d37d7e4b390455087c4bdf25b9f702309460577b14f9" +"checksum raw-window-handle 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "af3d3b2e1053b3ff2171efc29a8bff3439ce6b2ce6a0432695134bc1c7ff8e87" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bbc232e13d37f4547f5b9b42a5efc380cabe5dbc1807f8b893580640b2ab0308" diff --git a/examples/framework.c b/examples/framework.c index 812b87244..82a09e93c 100644 --- a/examples/framework.c +++ b/examples/framework.c @@ -16,7 +16,7 @@ WGPUU32Array read_file(const char *name) { fclose(file); return (WGPUU32Array){ .bytes = (uint32_t*) bytes, - .length = length, + .length = length / 4, }; } diff --git a/ffi/wgpu.h b/ffi/wgpu.h index dad0c2a80..b11f693f9 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -1,5 +1,4 @@ #define WGPU_LOCAL -struct WGPUWindow; /* Generated with cbindgen:0.9.0 */ @@ -836,11 +835,6 @@ WGPUSurfaceId wgpu_instance_create_surface_from_windows_hwnd(WGPUInstanceId inst void *hwnd); #endif -#if (defined(WGPU_LOCAL) && defined(WGPU_WINIT) && !defined(WGPU_GLUTIN)) -WGPUSurfaceId wgpu_instance_create_surface_from_winit(WGPUInstanceId instance_id, - const WGPUWindow *window); -#endif - #if (defined(WGPU_LOCAL) && !defined(WGPU_BACKEND_GL)) WGPUSurfaceId wgpu_instance_create_surface_from_xlib(WGPUInstanceId instance_id, const void **display, diff --git a/wgpu-native/Cargo.toml b/wgpu-native/Cargo.toml index 75cccbb54..149801887 100644 --- a/wgpu-native/Cargo.toml +++ b/wgpu-native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-native" -version = "0.2.6" +version = "0.3.0" authors = [ "Dzmitry Malyshau ", "Joshua Groves ", @@ -20,12 +20,8 @@ default = [] local = [] remote = ["serde"] metal-auto-capture = ["gfx-backend-metal/auto-capture"] -winit-empty = ["winit", "gfx-backend-empty/winit"] -winit-vulkan = ["winit", "gfx-backend-vulkan/winit"] -winit-dx12 = ["winit", "gfx-backend-dx12/winit"] -winit-dx11 = ["winit", "gfx-backend-dx11/winit"] -winit-metal = ["winit", "gfx-backend-metal/winit"] -glutin = ["winit", "gfx-backend-gl/glutin"] +#NOTE: glutin feature is not stable, use at your own risk +glutin = ["gfx-backend-gl/glutin"] [dependencies] arrayvec = "0.4" @@ -40,9 +36,10 @@ gfx-backend-dx12 = { version = "0.3.0", optional = true } gfx-backend-dx11 = { version = "0.3.0", optional = true } gfx-backend-metal = { version = "0.3.0", optional = true } gfx-backend-gl = { version = "0.3.0", optional = true } -parking_lot = { version = "0.9" } -rendy-memory = { version = "0.4" } -rendy-descriptor = { version = "0.4" } +parking_lot = "0.9" +raw-window-handle = "0.1" +rendy-memory = "0.4" +rendy-descriptor = "0.4" serde = { version = "1.0", features = ["serde_derive"], optional = true } vec_map = "0.8" -winit = { version = "0.19", optional = true } + diff --git a/wgpu-native/cbindgen.toml b/wgpu-native/cbindgen.toml index 738aa3acf..9a538ab74 100644 --- a/wgpu-native/cbindgen.toml +++ b/wgpu-native/cbindgen.toml @@ -1,6 +1,5 @@ header = """ #define WGPU_LOCAL -struct WGPUWindow; """ include_version = true braces = "SameLine" diff --git a/wgpu-native/src/instance.rs b/wgpu-native/src/instance.rs index 4f8ff4d19..6942d3d8a 100644 --- a/wgpu-native/src/instance.rs +++ b/wgpu-native/src/instance.rs @@ -88,15 +88,56 @@ pub fn wgpu_create_gl_instance(windowed_context: back::glutin::RawContext SurfaceId { let mut token = Token::root(); let (instance_guard, mut token) = HUB.instances.read(&mut token); - let raw = instance_guard[instance_id].create_surface(window); + let instance = &instance_guard[instance_id]; + let raw = match raw_handle { + #[cfg(all(target_os = "ios", feature = "gfx-backend-metal"))] + raw_window_handle::RawWindowHandle::IOS(h) => + instance.create_surface_from_uiview(h.ui_view, cfg!(debug_assertions)), + #[cfg(all(target_os = "macos", feature = "gfx-backend-metal"))] + raw_window_handle::RawWindowHandle::MacOS(h) => + instance.create_surface_from_nsview(h.ns_view, cfg!(debug_assertions)), + #[cfg(all(target_os = "macos", feature = "gfx-backend-vulkan"))] + raw_window_handle::RawWindowHandle::MacOS(h) => + instance.create_surface_from_nsview(h.ns_view), + #[cfg(all(unix, feature = "gfx-backend-vulkan"))] + raw_window_handle::RawWindowHandle::X11(h) => + instance.create_surface_from_xlib(h.display as _, h.window as _), + #[cfg(all(unix, feature = "gfx-backend-vulkan"))] + raw_window_handle::RawWindowHandle::Wayland(h) => + instance.create_surface_from_wayland(h.display, h.surface), + #[cfg(all(windows, feature = "gfx-backend-vulkan"))] + raw_window_handle::RawWindowHandle::Windows(h) => + instance.create_surface_from_hwnd(ptr::null_mut(), h.hwnd), + #[cfg(all(windows, feature = "gfx-backend-dx12"))] + raw_window_handle::RawWindowHandle::Windows(h) => + instance.create_surface_from_hwnd(h.hwnd), + #[cfg(all(windows, feature = "gfx-backend-dx12"))] + raw_window_handle::RawWindowHandle::Windows(h) => + instance.create_surface_from_hwnd(h.hwnd), + #[cfg(any( + feature = "gfx-backend-vulkan", + feature = "gfx-backend-dx11", + feature = "gfx-backend-dx12", + feature = "gfx-backend-metal", + feature = "gfx-backend-gl", + ))] + _ => panic!("Unsupported window handle"), + #[cfg(not(any( + feature = "gfx-backend-vulkan", + feature = "gfx-backend-dx11", + feature = "gfx-backend-dx12", + feature = "gfx-backend-metal", + feature = "gfx-backend-gl", + )))] + _ => { let _ = instance; back::Surface }, + }; let surface = SurfaceHandle::new(raw); HUB.surfaces.register_local(surface, &mut token) } @@ -221,7 +262,7 @@ pub fn instance_get_adapter( let (surface_guard, _) = HUB.surfaces.read(token); surface_guard[instance_id].raw.enumerate_adapters() }; - #[cfg(all(feature = "glutin", not(feature = "gfx-backend-gl")))] + #[cfg(all(not(feature = "glutin"), feature = "gfx-backend-gl"))] let adapters = Vec::::new(); let (mut integrated_first, mut discrete_first, mut discrete_last, mut alternative) = diff --git a/wgpu-native/src/lib.rs b/wgpu-native/src/lib.rs index 4224b8fb3..9c88414b5 100644 --- a/wgpu-native/src/lib.rs +++ b/wgpu-native/src/lib.rs @@ -1,6 +1,3 @@ -#[cfg(all(feature = "winit"))] -pub extern crate winit; - #[cfg(feature = "gfx-backend-dx11")] extern crate gfx_backend_dx11 as back; #[cfg(feature = "gfx-backend-dx12")] diff --git a/wgpu-remote/Cargo.toml b/wgpu-remote/Cargo.toml index f86bbe9ab..e3d00abcd 100644 --- a/wgpu-remote/Cargo.toml +++ b/wgpu-remote/Cargo.toml @@ -19,8 +19,8 @@ metal = ["wgpu-native/gfx-backend-metal"] gl = ["wgpu-native/gfx-backend-gl"] [dependencies] -wgpu-native = { path = "../wgpu-native", version = "0.2", features = ["remote"] } +wgpu-native = { path = "../wgpu-native", version = "0.3", features = ["remote"] } ipc-channel = "0.12" log = "0.4" -parking_lot = { version = "0.8" } +parking_lot = { version = "0.9" } serde = { version = "1.0", features = ["serde_derive"] }