Skip to content

Commit

Permalink
Make winit truly optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Aug 17, 2019
1 parent ab0ba19 commit 56f478c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ before_install:

script:
- cargo test
- cd wgpu-native && cargo check --features local,window-winit; 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 check --features local,window-winit,gfx-backend-gl; 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
Expand All @@ -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 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id,
void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t value);

void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
uint32_t start_slot,
const WGPUBufferId *buffers,
const WGPUBufferAddress *offsets,
uintptr_t length);
Expand Down
14 changes: 7 additions & 7 deletions wgpu-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default = []
local = []
remote = ["serde"]
metal-auto-capture = ["gfx-backend-metal/auto-capture"]
window-winit = ["winit", "gfx-backend-empty/winit"]
window-winit = ["winit", "gfx-backend-empty/winit", "gfx-backend-vulkan/winit", "gfx-backend-dx11/winit", "gfx-backend-dx12/winit", "gfx-backend-metal/winit", "gfx-backend-gl/glutin"]

[dependencies]
arrayvec = "0.4"
Expand All @@ -29,12 +29,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-dx11 = { version = "0.3.0", optional = true }
gfx-backend-dx12 = { 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" }
Expand Down
8 changes: 5 additions & 3 deletions wgpu-native/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ 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 = "window-winit", feature = "gfx-backend-gl"))]
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);
Expand Down Expand Up @@ -212,15 +212,17 @@ pub fn instance_get_adapter(
let (instance_guard, _) = HUB.instances.read(token);
instance_guard[instance_id].enumerate_adapters()
};
#[cfg(feature = "gfx-backend-gl")]
#[cfg(all(feature = "window-winit", feature = "gfx-backend-gl"))]
let adapters = {
let (surface_guard, _) = HUB.surfaces.read(token);
surface_guard[instance_id].raw.enumerate_adapters()
};
#[cfg(all(not(feature = "windiw-winit"), 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);

// On Windows > 1803, dx12 enumerate_adapters returns the adapters in order from highest to
// lowest performance. Therefore, the first found adapter in each category is selected.
//
Expand Down
2 changes: 1 addition & 1 deletion wgpu-native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use hal::pso::read_spirv;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(feature = "gfx-backend-gl")]
#[cfg(all(feature = "window-winit", feature = "gfx-backend-gl"))]
pub use back::glutin;

use std::{
Expand Down

0 comments on commit 56f478c

Please sign in to comment.