Skip to content

Commit

Permalink
fix: 🐛 Fix dashboard crash on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Sep 26, 2023
1 parent 90dc78d commit 08c593d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 81 deletions.
52 changes: 24 additions & 28 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions alvr/dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ instant = { version = "0.1", features = ["wasm-bindgen"] }
wasm-bindgen-futures = "0.4"
wasm-logger = "0.2"

[target.'cfg(target_os = "linux")'.dependencies]
wgpu = "0.16"

[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
25 changes: 15 additions & 10 deletions alvr/dashboard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use dashboard::Dashboard;
#[cfg(not(target_arch = "wasm32"))]
fn main() {
use alvr_common::ALVR_VERSION;
use alvr_packets::GpuVendor;
use eframe::{egui, IconData, NativeOptions};
use ico::IconDir;
use std::{env, fs};
Expand All @@ -36,16 +35,22 @@ fn main() {

data_manager.clean_client_list();

if data_manager
.get_gpu_vendors()
.iter()
.any(|vendor| matches!(vendor, GpuVendor::Nvidia))
#[cfg(target_os = "linux")]
{
data_manager
.session_mut()
.session_settings
.patches
.linux_async_reprojection = false;
let has_nvidia = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::VULKAN,
dx12_shader_compiler: Default::default(),
})
.enumerate_adapters(wgpu::Backends::VULKAN)
.any(|adapter| adapter.get_info().vendor == 0x10de);

if has_nvidia {
data_manager
.session_mut()
.session_settings
.patches
.linux_async_reprojection = false;
}
}

if data_manager.session().server_version != *ALVR_VERSION {
Expand Down
6 changes: 0 additions & 6 deletions alvr/packets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@ pub struct AudioDevicesList {
pub input: Vec<String>,
}

pub enum GpuVendor {
Nvidia,
Amd,
Other,
}

#[derive(Serialize, Deserialize, Clone)]
pub enum PathSegment {
Name(String),
Expand Down
1 change: 0 additions & 1 deletion alvr/server_io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ encoding_rs_io = "0.1"
dirs = "5"
runas = "=1.0"
serde_json = "1"
wgpu = "0.16"
37 changes: 1 addition & 36 deletions alvr/server_io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alvr_common::{
error, info,
};
use alvr_events::EventType;
use alvr_packets::{AudioDevicesList, ClientListAction, GpuVendor, PathSegment, PathValuePair};
use alvr_packets::{AudioDevicesList, ClientListAction, PathSegment, PathValuePair};
use alvr_session::{ClientConnectionConfig, ConnectionState, SessionConfig, Settings};
use cpal::traits::{DeviceTrait, HostTrait};
use serde_json as json;
Expand All @@ -21,7 +21,6 @@ use std::{
ops::{Deref, DerefMut},
path::{Path, PathBuf},
};
use wgpu::AdapterInfo;

fn save_session(session: &SessionConfig, path: &Path) -> Result<()> {
fs::write(path, json::to_string_pretty(session)?)?;
Expand Down Expand Up @@ -66,7 +65,6 @@ pub struct ServerDataManager {
session: SessionConfig,
settings: Settings,
session_path: PathBuf,
gpu_infos: Vec<AdapterInfo>,
}

impl ServerDataManager {
Expand All @@ -75,23 +73,10 @@ impl ServerDataManager {
fs::create_dir_all(config_dir).ok();
let session_desc = Self::load_session(session_path, config_dir);

let vk_adapters: Vec<wgpu::Adapter> = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::VULKAN,
dx12_shader_compiler: Default::default(),
})
.enumerate_adapters(wgpu::Backends::VULKAN)
.collect();

let gpu_infos = vk_adapters
.iter()
.map(|adapter| adapter.get_info())
.collect();

Self {
session: session_desc.clone(),
settings: session_desc.to_settings(),
session_path: session_path.to_owned(),
gpu_infos,
}
}

Expand Down Expand Up @@ -303,26 +288,6 @@ impl ServerDataManager {
}
}

pub fn get_gpu_vendors(&self) -> Vec<GpuVendor> {
return self
.gpu_infos
.iter()
.map(|adapter_info| match adapter_info.vendor {
0x10de => GpuVendor::Nvidia,
0x1002 => GpuVendor::Amd,
_ => GpuVendor::Other,
})
.collect();
}

pub fn get_gpu_names(&self) -> Vec<String> {
return self
.gpu_infos
.iter()
.map(|adapter_info| adapter_info.name.clone())
.collect();
}

#[cfg_attr(not(target_os = "linux"), allow(unused_variables))]
pub fn get_audio_devices_list(&self) -> Result<AudioDevicesList> {
#[cfg(target_os = "linux")]
Expand Down

0 comments on commit 08c593d

Please sign in to comment.