Make winit truly optional

This commit is contained in:
Dzmitry Malyshau 2019-08-16 18:07:42 -04:00
parent a47ff090bb
commit f30cb20508
5 changed files with 24 additions and 19 deletions

View File

@ -57,6 +57,9 @@ before_install:
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
@ -72,5 +75,3 @@ script:
make example-compute example-triangle VERBOSE=1;
fi
- if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME != "windows" ]]; then make VERBOSE=1; fi
# 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 build --features local,gfx-backend-gl; fi

1
Cargo.lock generated
View File

@ -361,7 +361,6 @@ dependencies = [
"wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.25 (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]]

View File

@ -20,7 +20,12 @@ default = []
local = []
remote = ["serde"]
metal-auto-capture = ["gfx-backend-metal/auto-capture"]
window-winit = ["winit", "gfx-backend-empty/winit"]
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"]
[dependencies]
arrayvec = "0.4"
@ -29,12 +34,12 @@ copyless = "0.1"
lazy_static = "1.1.0"
log = "0.4"
hal = { package = "gfx-hal", version = "0.3.0" }
gfx-backend-empty = { version = "0.3.0", features = ["winit"] }
gfx-backend-vulkan = { version = "0.3.0", features = ["winit", "x11"], optional = true }
gfx-backend-dx11 = { version = "0.3.0", features = ["winit"], optional = true }
gfx-backend-dx12 = { version = "0.3.0", features = ["winit"], optional = true }
gfx-backend-metal = { version = "0.3.0", features = ["winit"], optional = true }
gfx-backend-gl = { version = "0.3.0", features = ["winit", "glutin"], optional = true }
gfx-backend-empty = { version = "0.3.0" }
gfx-backend-vulkan = { version = "0.3.0", features = ["x11"], optional = true }
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 = { git = "https://github.com/amethyst/rendy", rev = "db6adbe7454f52ebf559a38dd88580aa3ebbcaaf" }
rendy-descriptor = { git = "https://github.com/amethyst/rendy", rev = "db6adbe7454f52ebf559a38dd88580aa3ebbcaaf" }

View File

@ -81,14 +81,14 @@ pub extern "C" fn wgpu_create_instance() -> InstanceId {
HUB.instances.register_local(inst, &mut Token::root())
}
#[cfg(all(feature = "local", feature = "gfx-backend-gl"))]
#[cfg(all(feature = "local", feature = "glutin"))]
pub fn wgpu_create_gl_instance(windowed_context: back::glutin::RawContext<back::glutin::PossiblyCurrent>) -> InstanceId {
let raw = back::Surface::from_context(windowed_context);
let surface = SurfaceHandle::new(raw);
HUB.surfaces.register_local(surface, &mut Token::root())
}
#[cfg(all(feature = "window-winit", not(feature = "gfx-backend-gl")))]
#[cfg(all(feature = "local", feature = "winit", not(feature = "glutin")))]
#[no_mangle]
pub extern "C" fn wgpu_instance_create_surface_from_winit(
instance_id: InstanceId,
@ -151,8 +151,7 @@ pub fn instance_create_surface_from_macos_layer(
}
}
#[cfg(not(feature = "gfx-backend-gl"))]
#[cfg(feature = "local")]
#[cfg(all(feature = "local", not(feature = "gfx-backend-gl")))]
#[no_mangle]
pub extern "C" fn wgpu_instance_create_surface_from_macos_layer(
instance_id: InstanceId,
@ -190,8 +189,7 @@ pub fn instance_create_surface_from_windows_hwnd(
SurfaceHandle::new(raw)
}
#[cfg(not(feature = "gfx-backend-gl"))]
#[cfg(feature = "local")]
#[cfg(all(feature = "local", not(feature = "gfx-backend-gl")))]
#[no_mangle]
pub extern "C" fn wgpu_instance_create_surface_from_windows_hwnd(
instance_id: InstanceId,
@ -218,11 +216,13 @@ pub fn instance_get_adapter(
let (instance_guard, _) = HUB.instances.read(token);
instance_guard[instance_id].enumerate_adapters()
};
#[cfg(feature = "gfx-backend-gl")]
#[cfg(feature = "glutin")]
let adapters = {
let (surface_guard, _) = HUB.surfaces.read(token);
surface_guard[instance_id].raw.enumerate_adapters()
};
#[cfg(all(feature = "glutin", not(feature = "gfx-backend-gl")))]
let adapters = Vec::<AdapterHandle>::new();
let (mut integrated_first, mut discrete_first, mut discrete_last, mut alternative) =
(None, None, None, None);

View File

@ -1,4 +1,4 @@
#[cfg(all(feature = "local", feature = "window-winit"))]
#[cfg(all(feature = "winit"))]
pub extern crate winit;
#[cfg(feature = "gfx-backend-dx11")]
@ -44,7 +44,7 @@ pub use hal::pso::read_spirv;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "gfx-backend-gl")]
#[cfg(feature = "glutin")]
pub use back::glutin;
use std::{