diff --git a/Cargo.lock b/Cargo.lock index 24e6d92ff8..653e395f98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,34 +199,21 @@ version = "21.0.0-dev01" dependencies = [ "alvr_audio", "alvr_common", + "alvr_graphics", "alvr_packets", "alvr_session", "alvr_sockets", "alvr_system_info", "android_logger", "app_dirs2", - "bincode", - "bindgen 0.70.1", - "cc", "env_logger", - "glow", - "glyph_brush_layout", - "jni", - "khronos-egl", - "local-ip-address", "mdns-sd", "ndk 0.9.0", "ndk-context", - "ndk-sys 0.6.0+11769913", "oboe", - "pollster", "rand", "serde", "serde_json", - "walkdir", - "wgpu", - "wgpu-core", - "whoami", ] [[package]] @@ -248,6 +235,7 @@ version = "21.0.0-dev01" dependencies = [ "alvr_client_core", "alvr_common", + "alvr_graphics", "alvr_packets", "alvr_session", "alvr_system_info", @@ -326,6 +314,20 @@ dependencies = [ "once_cell", ] +[[package]] +name = "alvr_graphics" +version = "21.0.0-dev01" +dependencies = [ + "alvr_common", + "alvr_session", + "glow", + "glyph_brush_layout", + "khronos-egl", + "pollster", + "wgpu", + "wgpu-core", +] + [[package]] name = "alvr_gui_common" version = "21.0.0-dev01" @@ -6180,12 +6182,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" - [[package]] name = "wasm-bindgen" version = "0.2.99" @@ -6578,17 +6574,6 @@ dependencies = [ "rustix 0.38.42", ] -[[package]] -name = "whoami" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" -dependencies = [ - "redox_syscall 0.5.8", - "wasite", - "web-sys", -] - [[package]] name = "wide" version = "0.7.30" diff --git a/Cargo.toml b/Cargo.toml index 502451b834..77d14f0cd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ alvr_client_core = { path = "alvr/client_core" } alvr_common = { path = "alvr/common" } alvr_events = { path = "alvr/events" } alvr_filesystem = { path = "alvr/filesystem" } +alvr_graphics = { path = "alvr/graphics" } alvr_gui_common = { path = "alvr/gui_common" } alvr_packets = { path = "alvr/packets" } alvr_server_core = { path = "alvr/server_core"} diff --git a/alvr/client_core/Cargo.toml b/alvr/client_core/Cargo.toml index a9140cb348..2ea50db417 100644 --- a/alvr/client_core/Cargo.toml +++ b/alvr/client_core/Cargo.toml @@ -11,44 +11,28 @@ crate-type = ["rlib", "staticlib", "cdylib"] [features] link-stdcpp-shared = [] -use-cpp = [] -default = ["link-stdcpp-shared", "use-cpp"] +default = ["link-stdcpp-shared"] [dependencies] alvr_audio.workspace = true alvr_common.workspace = true +alvr_graphics.workspace = true alvr_packets.workspace = true alvr_session.workspace = true alvr_sockets.workspace = true alvr_system_info.workspace = true app_dirs2 = "2" -bincode = "1" -glow = "0.13" -glyph_brush_layout = "0.2" -jni = "0.21" -khronos-egl = { version = "6", features = ["dynamic"] } -local-ip-address = "0.6" mdns-sd = "0.11" -pollster = "0.3" rand = "0.8" serde = "1" serde_json = "1" -wgpu = "0.20" -wgpu-core = { version = "0.21", features = ["gles"] } -whoami = "1" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.14" ndk = { version = "0.9", features = ["api-level-26", "media"] } ndk-context = "0.1" -ndk-sys = "0.6" oboe = "0.6" # todo: remove once AudioThread shutdown crash is fixed [target.'cfg(not(target_os = "android"))'.dependencies] env_logger = "0.11" - -[build-dependencies] -bindgen = "0.70" -cc = { version = "1", features = ["parallel"] } -walkdir = "2" diff --git a/alvr/client_core/src/c_api.rs b/alvr/client_core/src/c_api.rs index a95def481f..0619908a49 100644 --- a/alvr/client_core/src/c_api.rs +++ b/alvr/client_core/src/c_api.rs @@ -1,7 +1,6 @@ #![expect(dead_code)] use crate::{ - graphics::{GraphicsContext, LobbyRenderer, LobbyViewParams, StreamRenderer, StreamViewParams}, storage, video_decoder::{self, VideoDecoderConfig, VideoDecoderSource}, ClientCapabilities, ClientCoreContext, ClientCoreEvent, @@ -15,6 +14,9 @@ use alvr_common::{ parking_lot::Mutex, warn, DeviceMotion, Fov, OptLazy, Pose, }; +use alvr_graphics::{ + GraphicsContext, LobbyRenderer, LobbyViewParams, StreamRenderer, StreamViewParams, +}; use alvr_packets::{ButtonEntry, ButtonValue, FaceData, ViewParams}; use alvr_session::{CodecType, FoveatedEncodingConfig, MediacodecPropType, MediacodecProperty}; use std::{ @@ -785,7 +787,7 @@ pub unsafe extern "C" fn alvr_start_stream_opengl(config: AlvrStreamConfig) { GRAPHICS_CONTEXT.with_borrow(|c| c.as_ref().unwrap().clone()), view_resolution, swapchain_textures, - glow::RGBA8, + alvr_graphics::SDR_FORMAT_GL, foveated_encoding, true, false, // TODO: limited range fix config diff --git a/alvr/client_core/src/lib.rs b/alvr/client_core/src/lib.rs index 8058c33c79..664b96ca39 100644 --- a/alvr/client_core/src/lib.rs +++ b/alvr/client_core/src/lib.rs @@ -15,7 +15,6 @@ mod storage; #[cfg(target_os = "android")] mod audio; -pub mod graphics; pub mod video_decoder; use alvr_common::{ @@ -39,7 +38,6 @@ use std::{ }; use storage::Config; -pub use alvr_system_info::Platform; pub use logging_backend::init_logging; pub enum ClientCoreEvent { diff --git a/alvr/client_openxr/Cargo.toml b/alvr/client_openxr/Cargo.toml index c4be08a16d..8bcae4c740 100644 --- a/alvr/client_openxr/Cargo.toml +++ b/alvr/client_openxr/Cargo.toml @@ -12,6 +12,7 @@ crate-type = ["cdylib"] [dependencies] alvr_common.workspace = true alvr_client_core.workspace = true +alvr_graphics.workspace = true alvr_packets.workspace = true alvr_session.workspace = true alvr_system_info.workspace = true diff --git a/alvr/client_openxr/src/graphics.rs b/alvr/client_openxr/src/graphics.rs index 63412c335e..949db5cfff 100644 --- a/alvr/client_openxr/src/graphics.rs +++ b/alvr/client_openxr/src/graphics.rs @@ -1,5 +1,5 @@ -use alvr_client_core::graphics::{self, GraphicsContext}; use alvr_common::glam::UVec2; +use alvr_graphics::GraphicsContext; use openxr as xr; #[allow(unused)] @@ -24,7 +24,7 @@ pub fn swapchain_format( gfx_ctx.make_current(); let formats = session.enumerate_swapchain_formats().unwrap(); - graphics::choose_swapchain_format(&formats, enable_hdr) + alvr_graphics::choose_swapchain_format(&formats, enable_hdr) } #[allow(unused_variables)] diff --git a/alvr/client_openxr/src/lib.rs b/alvr/client_openxr/src/lib.rs index b176b99d63..065fbd5a4c 100644 --- a/alvr/client_openxr/src/lib.rs +++ b/alvr/client_openxr/src/lib.rs @@ -7,9 +7,7 @@ mod passthrough; mod stream; use crate::stream::ParsedStreamConfig; -use alvr_client_core::{ - graphics::GraphicsContext, ClientCapabilities, ClientCoreContext, ClientCoreEvent, Platform, -}; +use alvr_client_core::{ClientCapabilities, ClientCoreContext, ClientCoreEvent}; use alvr_common::{ error, glam::{Quat, UVec2, Vec3}, @@ -17,6 +15,8 @@ use alvr_common::{ parking_lot::RwLock, Fov, Pose, HAND_LEFT_ID, }; +use alvr_graphics::GraphicsContext; +use alvr_system_info::Platform; use extra_extensions::{ META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME, META_DETACHED_CONTROLLERS_EXTENSION_NAME, META_SIMULTANEOUS_HANDS_AND_CONTROLLERS_EXTENSION_NAME, diff --git a/alvr/client_openxr/src/lobby.rs b/alvr/client_openxr/src/lobby.rs index 0244ceeca3..caeb1a6726 100644 --- a/alvr/client_openxr/src/lobby.rs +++ b/alvr/client_openxr/src/lobby.rs @@ -2,8 +2,8 @@ use crate::{ graphics::{self, ProjectionLayerAlphaConfig, ProjectionLayerBuilder}, interaction::{self, InteractionContext}, }; -use alvr_client_core::graphics::{GraphicsContext, LobbyRenderer, LobbyViewParams, SDR_FORMAT_GL}; use alvr_common::{glam::UVec2, parking_lot::RwLock, Pose}; +use alvr_graphics::{GraphicsContext, LobbyRenderer, LobbyViewParams, SDR_FORMAT_GL}; use alvr_system_info::Platform; use openxr as xr; use std::{rc::Rc, sync::Arc, time::Duration}; diff --git a/alvr/client_openxr/src/stream.rs b/alvr/client_openxr/src/stream.rs index 9fab265921..e789b886ec 100644 --- a/alvr/client_openxr/src/stream.rs +++ b/alvr/client_openxr/src/stream.rs @@ -3,9 +3,8 @@ use crate::{ interaction::{self, InteractionContext, InteractionSourcesConfig}, }; use alvr_client_core::{ - graphics::{GraphicsContext, StreamRenderer, StreamViewParams}, video_decoder::{self, VideoDecoderConfig, VideoDecoderSource}, - ClientCoreContext, Platform, + ClientCoreContext, }; use alvr_common::{ anyhow::Result, @@ -14,11 +13,13 @@ use alvr_common::{ parking_lot::RwLock, Pose, RelaxedAtomic, HAND_LEFT_ID, HAND_RIGHT_ID, HEAD_ID, }; +use alvr_graphics::{GraphicsContext, StreamRenderer, StreamViewParams}; use alvr_packets::{FaceData, StreamConfig, ViewParams}; use alvr_session::{ ClientsideFoveationConfig, ClientsideFoveationMode, CodecType, FoveatedEncodingConfig, MediacodecProperty, PassthroughMode, }; +use alvr_system_info::Platform; use openxr as xr; use std::{ ptr, diff --git a/alvr/graphics/Cargo.toml b/alvr/graphics/Cargo.toml new file mode 100644 index 0000000000..09d42944b1 --- /dev/null +++ b/alvr/graphics/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "alvr_graphics" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true + +[dependencies] +alvr_common.workspace = true +alvr_session.workspace = true + +glow = "0.13" +glyph_brush_layout = "0.2" +khronos-egl = { version = "6", features = ["dynamic"] } +pollster = "0.3" +wgpu = "0.20" +wgpu-core = { version = "0.21", features = ["gles"] } \ No newline at end of file diff --git a/alvr/client_core/resources/Ubuntu-Medium.ttf b/alvr/graphics/resources/Ubuntu-Medium.ttf similarity index 100% rename from alvr/client_core/resources/Ubuntu-Medium.ttf rename to alvr/graphics/resources/Ubuntu-Medium.ttf diff --git a/alvr/client_core/resources/lobby_line.wgsl b/alvr/graphics/resources/lobby_line.wgsl similarity index 100% rename from alvr/client_core/resources/lobby_line.wgsl rename to alvr/graphics/resources/lobby_line.wgsl diff --git a/alvr/client_core/resources/lobby_quad.wgsl b/alvr/graphics/resources/lobby_quad.wgsl similarity index 100% rename from alvr/client_core/resources/lobby_quad.wgsl rename to alvr/graphics/resources/lobby_quad.wgsl diff --git a/alvr/client_core/resources/staging_fragment.glsl b/alvr/graphics/resources/staging_fragment.glsl similarity index 100% rename from alvr/client_core/resources/staging_fragment.glsl rename to alvr/graphics/resources/staging_fragment.glsl diff --git a/alvr/client_core/resources/staging_vertex.glsl b/alvr/graphics/resources/staging_vertex.glsl similarity index 100% rename from alvr/client_core/resources/staging_vertex.glsl rename to alvr/graphics/resources/staging_vertex.glsl diff --git a/alvr/client_core/resources/stream.wgsl b/alvr/graphics/resources/stream.wgsl similarity index 100% rename from alvr/client_core/resources/stream.wgsl rename to alvr/graphics/resources/stream.wgsl diff --git a/alvr/client_core/src/graphics/mod.rs b/alvr/graphics/src/lib.rs similarity index 99% rename from alvr/client_core/src/graphics/mod.rs rename to alvr/graphics/src/lib.rs index bf227ece83..7c2c122034 100644 --- a/alvr/client_core/src/graphics/mod.rs +++ b/alvr/graphics/src/lib.rs @@ -47,7 +47,7 @@ macro_rules! ck { let res = $gl_ctx.$($gl_cmd)*; #[cfg(debug_assertions)] - crate::graphics::check_error(&$gl_ctx, &format!("{}:{}: {}", file!(), line!(), stringify!($($gl_cmd)*))); + crate::check_error(&$gl_ctx, &format!("{}:{}: {}", file!(), line!(), stringify!($($gl_cmd)*))); res }}; diff --git a/alvr/client_core/src/graphics/lobby.rs b/alvr/graphics/src/lobby.rs similarity index 98% rename from alvr/client_core/src/graphics/lobby.rs rename to alvr/graphics/src/lobby.rs index 2aa3c619cd..4c7fd794c1 100644 --- a/alvr/client_core/src/graphics/lobby.rs +++ b/alvr/graphics/src/lobby.rs @@ -233,7 +233,7 @@ impl LobbyRenderer { "lobby_quad", &[&bind_group_layout], QUAD_PUSH_CONTANTS_SIZE, - include_wgsl!("../../resources/lobby_quad.wgsl"), + include_wgsl!("../resources/lobby_quad.wgsl"), PrimitiveTopology::TriangleStrip, ); @@ -242,7 +242,7 @@ impl LobbyRenderer { "lobby_line", &[], LINE_PUSH_CONTANTS_SIZE, - include_wgsl!("../../resources/lobby_line.wgsl"), + include_wgsl!("../resources/lobby_line.wgsl"), PrimitiveTopology::LineList, ); @@ -290,7 +290,7 @@ impl LobbyRenderer { pub fn update_hud_message(&self, message: &str) { let ubuntu_font = - FontRef::try_from_slice(include_bytes!("../../resources/Ubuntu-Medium.ttf")).unwrap(); + FontRef::try_from_slice(include_bytes!("../resources/Ubuntu-Medium.ttf")).unwrap(); let section_glyphs = Layout::default() .h_align(HorizontalAlign::Center) diff --git a/alvr/client_core/src/graphics/staging.rs b/alvr/graphics/src/staging.rs similarity index 96% rename from alvr/client_core/src/graphics/staging.rs rename to alvr/graphics/src/staging.rs index 5986dfd00e..febd2c3c38 100644 --- a/alvr/client_core/src/graphics/staging.rs +++ b/alvr/graphics/src/staging.rs @@ -1,5 +1,5 @@ use super::{ck, GraphicsContext}; -use crate::graphics::GL_TEXTURE_EXTERNAL_OES; +use crate::GL_TEXTURE_EXTERNAL_OES; use alvr_common::glam::{IVec2, UVec2}; use glow::{self as gl, HasContext}; use std::{ffi::c_void, rc::Rc}; @@ -68,7 +68,7 @@ impl StagingRenderer { context.make_current(); // Add #defines into the shader after the first line - let mut frag_lines: Vec<&str> = include_str!("../../resources/staging_fragment.glsl") + let mut frag_lines: Vec<&str> = include_str!("../resources/staging_fragment.glsl") .lines() .collect(); if fix_limited_range { @@ -78,7 +78,7 @@ impl StagingRenderer { let program = create_program( gl, - include_str!("../../resources/staging_vertex.glsl"), + include_str!("../resources/staging_vertex.glsl"), frag_str.as_str(), ); diff --git a/alvr/client_core/src/graphics/stream.rs b/alvr/graphics/src/stream.rs similarity index 99% rename from alvr/client_core/src/graphics/stream.rs rename to alvr/graphics/src/stream.rs index f93e4f462c..3ab8853da8 100644 --- a/alvr/client_core/src/graphics/stream.rs +++ b/alvr/graphics/src/stream.rs @@ -86,8 +86,7 @@ impl StreamRenderer { ], }); - let shader_module = - device.create_shader_module(include_wgsl!("../../resources/stream.wgsl")); + let shader_module = device.create_shader_module(include_wgsl!("../resources/stream.wgsl")); let mut constants = HashMap::new();