Serve /graphics-devices request

This commit is contained in:
zarik5 2020-10-26 22:48:04 +01:00
parent 53683f4f70
commit 1384d7d6e6
5 changed files with 178 additions and 5 deletions

159
Cargo.lock generated
View File

@ -63,6 +63,8 @@ version = "12.0.0"
dependencies = [
"alvr_xtask",
"backtrace",
"gfx-backend-dx11",
"gfx-hal",
"log 0.4.11",
"regex",
"runas",
@ -464,7 +466,7 @@ checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a"
dependencies = [
"glob",
"libc",
"libloading",
"libloading 0.5.2",
]
[[package]]
@ -491,6 +493,15 @@ dependencies = [
"bitflags",
]
[[package]]
name = "cloudabi"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467"
dependencies = [
"bitflags",
]
[[package]]
name = "cocoa"
version = "0.24.0"
@ -949,6 +960,15 @@ dependencies = [
"slab",
]
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
dependencies = [
"byteorder",
]
[[package]]
name = "gdk"
version = "0.13.2"
@ -1045,6 +1065,49 @@ dependencies = [
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
name = "gfx-auxil"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ec012a32036c6439180b688b15a24dc8a3fbdb3b1cd02eb55266201db4c1b0f"
dependencies = [
"fxhash",
"gfx-hal",
"spirv_cross",
]
[[package]]
name = "gfx-backend-dx11"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9298f97019462d13ac29d16715c7c30ac4b9f277dd67ca285a0024fa4f3c7bc1"
dependencies = [
"arrayvec",
"bitflags",
"gfx-auxil",
"gfx-hal",
"libloading 0.6.5",
"log 0.4.11",
"parking_lot",
"range-alloc",
"raw-window-handle",
"smallvec",
"spirv_cross",
"thunderdome",
"winapi 0.3.9",
"wio",
]
[[package]]
name = "gfx-hal"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18d0754f5b7a43915fd7466883b2d1bb0800d7cc4609178d0b27bf143b9e5123"
dependencies = [
"bitflags",
"raw-window-handle",
]
[[package]]
name = "gimli"
version = "0.22.0"
@ -1358,6 +1421,15 @@ dependencies = [
"bytes",
]
[[package]]
name = "instant"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "iovec"
version = "0.1.4"
@ -1461,12 +1533,31 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "libloading"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0"
dependencies = [
"cfg-if 1.0.0",
"winapi 0.3.9",
]
[[package]]
name = "linked-hash-map"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "lock_api"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.3.9"
@ -1797,6 +1888,32 @@ dependencies = [
"system-deps",
]
[[package]]
name = "parking_lot"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b"
dependencies = [
"cfg-if 0.1.10",
"cloudabi 0.1.0",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.9",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
@ -2120,7 +2237,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
dependencies = [
"cloudabi",
"cloudabi 0.0.3",
"fuchsia-cprng",
"libc",
"rand_core 0.4.2",
@ -2147,6 +2264,21 @@ dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "range-alloc"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a871f1e45a3a3f0c73fb60343c811238bb5143a81642e27c2ac7aac27ff01a63"
[[package]]
name = "raw-window-handle"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
dependencies = [
"libc",
]
[[package]]
name = "rayon"
version = "1.5.0"
@ -2432,6 +2564,12 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]]
name = "smallvec"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
[[package]]
name = "socket2"
version = "0.3.15"
@ -2444,6 +2582,17 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "spirv_cross"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b631bd956108f3e34a4fb7e39621711ac15ce022bc567da2d953c6df13f00e00"
dependencies = [
"cc",
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "starts-ends-with-caseless"
version = "0.5.4"
@ -2610,6 +2759,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "thunderdome"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7572415bd688d401c52f6e36f4c8e805b9ae1622619303b9fa835d531db0acae"
[[package]]
name = "time"
version = "0.1.44"

View File

@ -15,6 +15,7 @@ backtrace = '^0.3.46'
settings-schema = { git = 'https://github.com/zarik5/settings-schema-rs', features = ['rename_camel_case'] }
sysinfo = '^0.15.0'
runas = '^0.2.1'
gfx-hal = '^0.6.0'
# cpal = { git = 'https://github.com/RustAudio/cpal' }
[target.'cfg(windows)'.dependencies]
@ -30,6 +31,7 @@ winapi = { version = '^0.3.8', features = [
wio = '^0.2.2'
widestring = '^0.4.2'
winreg = '^0.7.0'
gfx-backend-dx11 = '^0.6.8'
[build-dependencies]
alvr_xtask = { path = '../xtask' }

View File

@ -0,0 +1,12 @@
use gfx_hal::Instance;
#[cfg(windows)]
pub fn get_gpu_names() -> Vec<String> {
let instance = gfx_backend_dx11::Instance::create("ALVR", 0).unwrap();
let adapters = instance.enumerate_adapters();
adapters
.into_iter()
.map(|a| a.info.name)
.collect::<Vec<_>>()
}

View File

@ -1,7 +1,7 @@
pub mod audio;
pub mod data;
pub mod graphics;
pub mod logging;
pub mod process;
pub mod audio;
pub use logging::StrResult;

View File

@ -2,7 +2,7 @@ mod logging_backend;
mod sockets;
mod tail;
use alvr_common::{data::*, logging::*, process::*, *};
use alvr_common::{data::*, graphics, logging::*, process::*, *};
use futures::SinkExt;
use logging_backend::*;
use settings_schema::Switch;
@ -309,6 +309,9 @@ async fn run(log_senders: Arc<Mutex<Vec<UnboundedSender<String>>>>) -> StrResult
reply::json(&maybe_err.unwrap_or(0))
});
let graphics_devices_request =
warp::path("graphics-devices").map(|| reply::json(&graphics::get_gpu_names()));
let audio_devices_request =
warp::path("audio_devices").map(|| reply::json(&audio::output_audio_devices().ok()));
@ -332,6 +335,7 @@ async fn run(log_senders: Arc<Mutex<Vec<UnboundedSender<String>>>>) -> StrResult
.or(log_subscription)
.or(driver_registration_requests)
.or(firewall_rules_requests)
.or(graphics_devices_request)
.or(audio_devices_request)
.or(files_requests)
.or(restart_steamvr_request)