fix: upgrade sk + smithay

This commit is contained in:
Nova
2025-04-27 01:20:13 -07:00
parent 277dc3c8a3
commit 8ef8f4ba2b
11 changed files with 238 additions and 220 deletions

152
Cargo.lock generated
View File

@@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046"
dependencies = [
"android-properties",
"bitflags 2.6.0",
"bitflags 2.9.0",
"cc",
"cesu8",
"jni",
@@ -61,15 +61,15 @@ checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "android_log-sys"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937"
checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d"
[[package]]
name = "android_logger"
version = "0.14.1"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826"
checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b"
dependencies = [
"android_log-sys",
"env_filter",
@@ -338,6 +338,12 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "atomic_float"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628d228f918ac3b82fe590352cc719d30664a0c13ca3a60266fe02c7132d480a"
[[package]]
name = "autocfg"
version = "1.3.0"
@@ -447,9 +453,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.6.0"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "blocking"
@@ -502,7 +508,7 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c58a38167d6fba8c67cce63c4a91f2a73ca42cbdaf6fb9ba164f1e07b43ecc10"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"log",
"polling",
"rustix",
@@ -606,9 +612,9 @@ dependencies = [
[[package]]
name = "cmake"
version = "0.1.51"
version = "0.1.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a"
checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
dependencies = [
"cc",
]
@@ -820,15 +826,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "dlib"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [
"libloading",
]
[[package]]
name = "downcast-rs"
version = "1.2.1"
@@ -841,7 +838,7 @@ version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"bytemuck",
"drm-ffi",
"drm-fourcc",
@@ -935,12 +932,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.9"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -1139,9 +1136,9 @@ dependencies = [
[[package]]
name = "glam"
version = "0.29.0"
version = "0.30.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28091a37a5d09b555cb6628fd954da299b536433834f5b8e59eba78e0cbbf8a"
checksum = "d0e9b6647e9b41d3a5ef02964c6be01311a7f2472fea40595c635c6d046c259e"
dependencies = [
"mint",
"serde",
@@ -1378,12 +1375,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "io-lifetimes"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
@@ -1501,9 +1492,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.158"
version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
[[package]]
name = "libloading"
@@ -1512,7 +1503,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [
"cfg-if",
"windows-targets 0.52.6",
"windows-targets 0.48.5",
]
[[package]]
@@ -1521,7 +1512,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"libc",
]
@@ -1739,7 +1730,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"jni-sys",
"log",
"ndk-sys",
@@ -1777,7 +1768,7 @@ version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"cfg-if",
"libc",
"memoffset",
@@ -1789,7 +1780,7 @@ version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"cfg-if",
"cfg_aliases 0.1.1",
"libc",
@@ -1801,7 +1792,7 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"cfg-if",
"cfg_aliases 0.2.1",
"libc",
@@ -1873,7 +1864,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [
"proc-macro-crate 3.2.0",
"proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
"syn 2.0.87",
@@ -2230,9 +2221,9 @@ dependencies = [
[[package]]
name = "quick-xml"
version = "0.36.1"
version = "0.37.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc"
checksum = "a4ce8c88de324ff838700f36fb6ab86c96df0e3c4ab6ef3a9b2044465cce1369"
dependencies = [
"memchr",
]
@@ -2312,7 +2303,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
]
[[package]]
@@ -2393,15 +2384,15 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.35"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"errno",
"libc",
"linux-raw-sys 0.4.14",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -2570,11 +2561,12 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smithay"
version = "0.4.0"
source = "git+https://github.com/smithay/smithay.git#0c2230f858580b52d628087d6dae1795278b8756"
version = "0.6.0"
source = "git+https://github.com/smithay/smithay.git#f85d06a4629795f5008b573f6b48606db9ff6d71"
dependencies = [
"appendlist",
"bitflags 2.6.0",
"atomic_float",
"bitflags 2.9.0",
"calloop",
"cgmath",
"cursor-icon",
@@ -2715,17 +2707,23 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "stereokit-macros"
version = "0.1.0"
source = "git+https://github.com/mvvvv/StereoKit-rust.git?rev=73ffaae6f42aa369e599a6ea0391f77840d682d8#73ffaae6f42aa369e599a6ea0391f77840d682d8"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020dcab2a9a09f2945837e638ef812d8f7c2f4ef81df203b1ba7613f3736935a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "stereokit-rust"
version = "0.1.0"
source = "git+https://github.com/mvvvv/StereoKit-rust.git?rev=73ffaae6f42aa369e599a6ea0391f77840d682d8#73ffaae6f42aa369e599a6ea0391f77840d682d8"
version = "0.4.0-alpha.3"
source = "git+https://github.com/mvvvv/StereoKit-rust.git#0b8b4eb3dfec88a619b5788481edf324fb3bd11b"
dependencies = [
"android-activity",
"android_logger",
"bitflags 2.6.0",
"bitflags 2.9.0",
"cmake",
"glam",
"jni",
@@ -3251,25 +3249,24 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wayland-backend"
version = "0.3.7"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6"
checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf"
dependencies = [
"cc",
"downcast-rs",
"rustix",
"scoped-tls",
"smallvec",
"wayland-sys",
]
[[package]]
name = "wayland-protocols"
version = "0.32.5"
version = "0.32.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd0ade57c4e6e9a8952741325c30bf82f4246885dca8bf561898b86d0c1f58e"
checksum = "0781cf46869b37e36928f7b432273c0995aa8aed9552c556fb18754420541efc"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"wayland-backend",
"wayland-scanner",
"wayland-server",
@@ -3277,11 +3274,11 @@ dependencies = [
[[package]]
name = "wayland-protocols-misc"
version = "0.3.4"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40dd9d2f7f2713724d84b920d6f73ff878f6a353712942f75f78f4dadb72886"
checksum = "feb7ee1810026d1bb15d47086d03a7e5c68651c707e305ba1e8cc796fcbf5a54"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"wayland-backend",
"wayland-protocols",
"wayland-scanner",
@@ -3290,11 +3287,11 @@ dependencies = [
[[package]]
name = "wayland-protocols-wlr"
version = "0.3.4"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dad87b5fd1b1d3ca2f792df8f686a2a11e3fe1077b71096f7a175ab699f89109"
checksum = "248a02e6f595aad796561fa82d25601bd2c8c3b145b1c7453fc8f94c1a58f8b2"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"wayland-backend",
"wayland-protocols",
"wayland-scanner",
@@ -3303,9 +3300,9 @@ dependencies = [
[[package]]
name = "wayland-scanner"
version = "0.31.5"
version = "0.31.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597f2001b2e5fc1121e3d5b9791d3e78f05ba6bfa4641053846248e3a13661c3"
checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484"
dependencies = [
"proc-macro2",
"quick-xml",
@@ -3314,13 +3311,12 @@ dependencies = [
[[package]]
name = "wayland-server"
version = "0.31.6"
version = "0.31.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89532cc712a2adb119eb4d09694b402576052254d0bb284f82ac1c47fb786ad"
checksum = "97fabd7ed68cff8e7657b8a8a1fbe90cb4a3f0c30d90da4bf179a7a23008a4cb"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"downcast-rs",
"io-lifetimes",
"rustix",
"wayland-backend",
"wayland-scanner",
@@ -3328,12 +3324,10 @@ dependencies = [
[[package]]
name = "wayland-sys"
version = "0.31.5"
version = "0.31.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efa8ac0d8e8ed3e3b5c9fc92c7881406a268e11555abe36493efabe649a29e09"
checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615"
dependencies = [
"dlib",
"log",
"pkg-config",
]
@@ -3359,7 +3353,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.48.0",
]
[[package]]
@@ -3700,7 +3694,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d02316af6831aee03a1ecc7b887ec1e983f4cc43792b80faade552cd7e710c6"
dependencies = [
"bitflags 2.6.0",
"bitflags 2.9.0",
"indexmap 2.5.0",
"lalrpop",
"lalrpop-util",

View File

@@ -79,7 +79,7 @@ serde_repr = "0.1.19"
toml = "0.8.19"
# mathy stuffs
glam = { version = "0.29.0", features = ["mint", "serde"] }
glam = { version = "0.30.0", features = ["mint", "serde"] }
mint = "0.5.9"
tokio = { version = "1.39.2", features = ["rt-multi-thread", "signal", "time"] }
@@ -103,7 +103,6 @@ optional = true
[dependencies.stereokit-rust]
git = "https://github.com/mvvvv/StereoKit-rust.git"
rev = "73ffaae6f42aa369e599a6ea0391f77840d682d8"
features = ["no-event-loop"]
default-features = false

View File

@@ -189,7 +189,7 @@ async fn main() {
tokio::select! {
_ = stereokit_loop => (),
_ = tokio::signal::ctrl_c() => unsafe {sk_quit(QuitReason::SystemClose)},
_ = tokio::signal::ctrl_c() => unsafe {sk_quit(QuitReason::User)},
}
info!("Stopping...");
if let Some(project_dirs) = project_dirs {
@@ -259,7 +259,7 @@ fn stereokit_loop(
TexType::Cubemap,
TexFormat::RGBA32,
));
let _ = DEFAULT_SKYLIGHT.set(Renderer::get_skylight());
let _ = DEFAULT_SKYLIGHT.set(Renderer::get_sky_light());
if let Some(sky) = project_dirs
.as_ref()
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
@@ -268,7 +268,7 @@ fn stereokit_loop(
{
sky.render_as_sky();
} else {
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
Renderer::sky_tex(DEFAULT_SKYTEX.get().unwrap());
}
}

View File

@@ -6,7 +6,7 @@ use crate::core::registry::Registry;
use crate::core::resource::get_resource_file;
use crate::nodes::spatial::{SPATIAL_ASPECT_ALIAS_INFO, Spatial, Transform};
use color_eyre::eyre::eyre;
use glam::{Vec4Swizzles, vec3};
use glam::Vec4Swizzles;
use parking_lot::Mutex;
use stardust_xr::values::ResourceID;
@@ -60,7 +60,7 @@ impl Sound {
}
}
if self.instance.lock().is_none() && self.play.lock().take().is_some() {
let instance = sound.play(vec3(0.0, 0.0, 0.0), Some(self.volume));
let instance = sound.play([0.0; 3], Some(self.volume));
self.instance.lock().replace(instance);
}
if let Some(instance) = self.instance.lock().deref_mut() {

View File

@@ -28,22 +28,22 @@ pub fn draw(token: &MainThreadToken) {
match QUEUED_SKYTEX.lock().take() {
Some(Some(skytex)) => {
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
Renderer::skytex(skytex.tex);
Renderer::sky_tex(skytex.tex);
}
}
Some(None) => {
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
Renderer::sky_tex(DEFAULT_SKYTEX.get().unwrap());
}
None => {}
}
match QUEUED_SKYLIGHT.lock().take() {
Some(Some(skylight)) => {
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
Renderer::skylight(skylight.sh);
Renderer::sky_light(skylight.sh);
}
}
Some(None) => {
Renderer::skylight(*DEFAULT_SKYLIGHT.get().unwrap());
Renderer::sky_light(*DEFAULT_SKYLIGHT.get().unwrap());
}
None => {}
}

View File

@@ -32,7 +32,12 @@ impl Hash for MaterialWrapper {
self.0.get_shader().0.as_ptr().hash(state);
for param in self.0.get_all_param_info() {
param.name.hash(state);
param.to_string().hash(state);
(param.get_type() as u32).hash(state);
let data = self
.0
.get_all_param_info()
.get_data(&param.name, param.get_type());
data.hash(state);
}
self.0.get_chain().map(MaterialWrapper).hash(state)
}
@@ -53,7 +58,14 @@ impl PartialEq for MaterialWrapper {
else {
return false;
};
if self_param.to_string() != other_param.to_string() {
let Some(self_param) = self
.0
.get_all_param_info()
.get_data(self_param.get_name(), self_param.get_type())
else {
return false;
};
if self_param != other_param {
return false;
}
}
@@ -118,10 +130,10 @@ impl MaterialParameter {
params.set_float(parameter_name, *val);
}
MaterialParameter::Vec2(val) => {
params.set_vec2(parameter_name, Vec2::from(*val));
params.set_vector2(parameter_name, Vec2::from(*val));
}
MaterialParameter::Vec3(val) => {
params.set_vec3(parameter_name, Vec3::from(*val));
params.set_vector3(parameter_name, Vec3::from(*val));
}
MaterialParameter::Color(val) => {
params.set_color(
@@ -172,7 +184,7 @@ impl ModelPart {
let mut parts = model.parts.lock();
let parent_part = part
.get_parent()
.and_then(|part| parts.iter().find(|p| p.id == *part.get_id()));
.and_then(|part| parts.iter().find(|p| p.id == part.get_id()));
let stardust_model_part = model.space.node()?;
let client = stardust_model_part.get_client()?;
@@ -215,7 +227,7 @@ impl ModelPart {
});
let model_part = Arc::new(ModelPart {
id: *part.get_id(),
id: part.get_id(),
path: part_path,
space,
model: Arc::downgrade(model),
@@ -353,7 +365,7 @@ impl Model {
MODEL_REGISTRY.add_raw(&model);
// technically doing this in anything but the main thread isn't a good idea but dangit we need those model nodes ASAP
let sk_model = SKModel::copy(SKModel::from_file(
let sk_model = SKModel::copy(&SKModel::from_file(
pending_model_path.to_str().unwrap(),
None,
)?);

View File

@@ -16,7 +16,7 @@ use std::{
use stereokit_rust::{
font::Font,
sk::MainThreadToken,
system::{TextAlign, TextFit, TextStyle as SkTextStyle},
system::{Align, Pivot, TextFit, TextStyle as SkTextStyle},
util::{Color32, Color128},
};
@@ -24,17 +24,30 @@ use super::{TextAspect, TextStyle};
static TEXT_REGISTRY: Registry<Text> = Registry::new();
fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> TextAlign {
fn convert_pivot(x_align: super::XAlign, y_align: super::YAlign) -> Pivot {
match (x_align, y_align) {
(super::XAlign::Left, super::YAlign::Top) => TextAlign::TopLeft,
(super::XAlign::Left, super::YAlign::Center) => TextAlign::CenterLeft,
(super::XAlign::Left, super::YAlign::Bottom) => TextAlign::BottomLeft,
(super::XAlign::Center, super::YAlign::Top) => TextAlign::Center,
(super::XAlign::Center, super::YAlign::Center) => TextAlign::Center,
(super::XAlign::Center, super::YAlign::Bottom) => TextAlign::BottomCenter,
(super::XAlign::Right, super::YAlign::Top) => TextAlign::TopRight,
(super::XAlign::Right, super::YAlign::Center) => TextAlign::CenterRight,
(super::XAlign::Right, super::YAlign::Bottom) => TextAlign::BottomRight,
(super::XAlign::Left, super::YAlign::Top) => Pivot::TopLeft,
(super::XAlign::Left, super::YAlign::Center) => Pivot::CenterLeft,
(super::XAlign::Left, super::YAlign::Bottom) => Pivot::BottomLeft,
(super::XAlign::Center, super::YAlign::Top) => Pivot::Center,
(super::XAlign::Center, super::YAlign::Center) => Pivot::Center,
(super::XAlign::Center, super::YAlign::Bottom) => Pivot::BottomCenter,
(super::XAlign::Right, super::YAlign::Top) => Pivot::TopRight,
(super::XAlign::Right, super::YAlign::Center) => Pivot::CenterRight,
(super::XAlign::Right, super::YAlign::Bottom) => Pivot::BottomRight,
}
}
fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> Align {
match (x_align, y_align) {
(super::XAlign::Left, super::YAlign::Top) => Align::TopLeft,
(super::XAlign::Left, super::YAlign::Center) => Align::CenterLeft,
(super::XAlign::Left, super::YAlign::Bottom) => Align::BottomLeft,
(super::XAlign::Center, super::YAlign::Top) => Align::Center,
(super::XAlign::Center, super::YAlign::Center) => Align::Center,
(super::XAlign::Center, super::YAlign::Bottom) => Align::BottomCenter,
(super::XAlign::Right, super::YAlign::Top) => Align::TopRight,
(super::XAlign::Right, super::YAlign::Center) => Align::CenterRight,
(super::XAlign::Right, super::YAlign::Bottom) => Align::BottomRight,
}
}
@@ -104,7 +117,7 @@ impl Text {
)),
data.bounds
.as_ref()
.map(|b| convert_align(b.anchor_align_x, b.anchor_align_y)),
.map(|b| convert_pivot(b.anchor_align_x, b.anchor_align_y)),
Some(convert_align(data.text_align_x, data.text_align_y)),
None,
None,
@@ -124,7 +137,7 @@ impl Text {
)),
data.bounds
.as_ref()
.map(|b| convert_align(b.anchor_align_x, b.anchor_align_y)),
.map(|b| convert_pivot(b.anchor_align_x, b.anchor_align_y)),
Some(convert_align(data.text_align_x, data.text_align_y)),
None,
None,

View File

@@ -97,9 +97,9 @@ impl SkController {
);
self.material
.color_tint(if self.capture_manager.capture.upgrade().is_none() {
Color128::new_rgb(1.0, 1.0, 1.0)
Color128::rgb(1.0, 1.0, 1.0)
} else {
Color128::new_rgb(0.0, 1.0, 0.75)
Color128::rgb(0.0, 1.0, 0.75)
});
self.model.draw(
token,

View File

@@ -141,9 +141,9 @@ impl SkHand {
hand.elbow = None;
let hand_color = if self.capture_manager.capture.upgrade().is_none() {
Color128::new_rgb(1.0, 1.0, 1.0)
Color128::rgb(1.0, 1.0, 1.0)
} else {
Color128::new_rgb(0.0, 1.0, 0.75)
Color128::rgb(0.0, 1.0, 0.75)
};
material.color_tint(hand_color);
}

View File

@@ -13,29 +13,29 @@ use self::{state::WaylandState, surface::CORE_SURFACES};
use crate::{core::task, wayland::state::ClientState};
use color_eyre::eyre::{Result, ensure};
use parking_lot::Mutex;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::egl::EGLContext;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::{ImportDma, Renderer};
use smithay::output::Output;
use smithay::reexports::wayland_server::DisplayHandle;
use smithay::reexports::wayland_server::backend::ClientId;
use smithay::reexports::wayland_server::{Display, ListeningSocket};
use smithay::wayland::dmabuf;
use std::ffi::OsStr;
use std::os::fd::{IntoRawFd, OwnedFd};
use std::os::unix::prelude::AsRawFd;
use std::sync::OnceLock;
use smithay::{
backend::{
allocator::dmabuf::Dmabuf,
egl::EGLContext,
renderer::{ImportDma, Renderer, gles::GlesRenderer},
},
output::Output,
reexports::wayland_server::{Display, DisplayHandle, ListeningSocket},
wayland::dmabuf,
};
use std::{
ffi::c_void,
os::unix::{net::UnixListener, prelude::FromRawFd},
sync::Arc,
ffi::{OsStr, c_void},
os::fd::AsFd,
sync::{Arc, OnceLock},
};
use stereokit_rust::system::{Backend, BackendGraphics};
use tokio::io::unix::AsyncFdReadyGuard;
use tokio::sync::mpsc::UnboundedReceiver;
use tokio::{
io::unix::AsyncFd, net::UnixListener as AsyncUnixListener, sync::mpsc, task::JoinHandle,
io::unix::AsyncFd,
sync::{
Notify,
mpsc::{self, UnboundedReceiver},
},
task::AbortHandle,
};
use tracing::{debug_span, info, instrument};
@@ -61,39 +61,10 @@ fn get_sk_egl() -> Result<EGLRawHandles> {
})
}
pub struct DisplayWrapper(Mutex<Display<WaylandState>>, DisplayHandle);
impl DisplayWrapper {
pub fn handle(&self) -> DisplayHandle {
self.1.clone()
}
pub fn dispatch_clients(&self, state: &mut WaylandState) -> Result<usize, std::io::Error> {
self.0.lock().dispatch_clients(state)
}
pub fn flush_clients(&self, client: Option<ClientId>) {
if let Some(mut lock) = self.0.try_lock() {
let _ = lock.backend().flush(client);
}
}
pub fn poll_fd(&self) -> Result<OwnedFd, std::io::Error> {
self.0.lock().backend().poll_fd().try_clone_to_owned()
}
}
struct UnownedFd(Option<AsyncFd<OwnedFd>>);
impl UnownedFd {
async fn readable(&self) -> std::io::Result<AsyncFdReadyGuard<'_, OwnedFd>> {
self.0.as_ref().unwrap().readable().await
}
}
impl Drop for UnownedFd {
fn drop(&mut self) {
let _ = self.0.take().unwrap().into_inner().into_raw_fd();
}
}
pub struct Wayland {
display: Arc<DisplayWrapper>,
join_handle: JoinHandle<Result<()>>,
flush_notify: Arc<Notify>,
client_listener: AbortHandle,
client_dispatcher: AbortHandle,
renderer: GlesRenderer,
output: Output,
dmabuf_rx: UnboundedReceiver<(Dmabuf, Option<dmabuf::ImportNotifier>)>,
@@ -113,7 +84,6 @@ impl Wayland {
let display_handle = display.handle();
let (dmabuf_tx, dmabuf_rx) = mpsc::unbounded_channel();
let display = Arc::new(DisplayWrapper(Mutex::new(display), display_handle.clone()));
let wayland_state = WaylandState::new(display_handle.clone(), &renderer, dmabuf_tx);
let output = wayland_state.lock().output.clone();
@@ -128,57 +98,78 @@ impl Wayland {
}
info!(socket_name, "Wayland active");
let join_handle = Wayland::start_loop(display.clone(), socket, wayland_state)?;
let flush_notify = Arc::new(Notify::new());
let client_listener = task::new(
|| "Wayland client listener loop",
Wayland::client_listener_loop(display_handle, socket, wayland_state.clone()),
)?
.abort_handle();
let client_dispatcher = task::new(
|| "Wayland dispatch client loop",
Wayland::dispatch_client_loop(display, flush_notify.clone(), wayland_state),
)?
.abort_handle();
Ok(Wayland {
display,
join_handle,
flush_notify,
client_listener,
client_dispatcher,
renderer,
output,
dmabuf_rx,
})
}
fn start_loop(
display: Arc<DisplayWrapper>,
async fn client_listener_loop(
mut display_handle: DisplayHandle,
socket: ListeningSocket,
state: Arc<Mutex<WaylandState>>,
) -> Result<JoinHandle<Result<()>>> {
let listen_async =
AsyncUnixListener::from_std(unsafe { UnixListener::from_raw_fd(socket.as_raw_fd()) })?;
) -> Result<()> {
let async_fd = AsyncFd::new(socket.as_fd())?;
loop {
let mut guard = async_fd.readable().await?;
let Ok(Some(stream)) = socket.accept() else {
guard.clear_ready();
continue;
};
let dispatch_poll_fd = display.poll_fd()?;
let dispatch_poll_listener = UnownedFd(Some(AsyncFd::new(dispatch_poll_fd)?));
let stream = tokio::net::UnixStream::from_std(stream)?;
let pid = stream.peer_cred().ok().and_then(|c| c.pid());
let dh1 = display.handle();
let mut dh2 = dh1.clone();
// New client connected
let client_state = Arc::new(ClientState {
pid,
id: OnceLock::new(),
compositor_state: Default::default(),
seat: state.lock().seat.clone(),
});
let _client = display_handle.insert_client(stream.into_std()?, client_state.clone())?;
}
}
task::new(|| "wayland loop", async move {
let _socket = socket; // Keep the socket alive
loop {
tokio::select! {
acc = listen_async.accept() => { // New client connected
let (stream, _) = acc?;
let client_state = Arc::new(ClientState {
pid: stream.peer_cred().ok().and_then(|c| c.pid()),
id: OnceLock::new(),
compositor_state: Default::default(),
seat: state.lock().seat.clone(),
});
let _client = dh2.insert_client(stream.into_std()?, client_state.clone())?;
}
e = dispatch_poll_listener.readable() => { // Dispatch
let mut guard = e?;
debug_span!("Dispatch wayland event").in_scope(|| -> Result<(), color_eyre::Report> {
display.dispatch_clients(&mut state.lock())?;
display.flush_clients(None);
Ok(())
})?;
guard.clear_ready();
}
async fn dispatch_client_loop(
mut display: Display<WaylandState>,
flush_notify: Arc<Notify>,
state: Arc<Mutex<WaylandState>>,
) -> std::io::Result<()> {
loop {
let poll_fd = display.backend().poll_fd();
let async_fd = AsyncFd::new(poll_fd)?;
tokio::select! {
biased;
_ = async_fd.readable() => {
drop(async_fd);
let _span = debug_span!("Dispatch wayland event");
let _span = _span.enter();
let _ = display.dispatch_clients(&mut *state.lock());
let _ = display.flush_clients();
}
_ = flush_notify.notified() => {
drop(async_fd);
let _ = display.flush_clients();
},
}
})
}
}
#[instrument(level = "debug", name = "Wayland frame", skip(self))]
@@ -195,7 +186,7 @@ impl Wayland {
}
let _ = self.renderer.cleanup_texture_cache();
self.display.flush_clients(None);
self.flush_notify.notify_waiters();
}
pub fn frame_event(&self) {
@@ -212,6 +203,7 @@ impl Wayland {
}
impl Drop for Wayland {
fn drop(&mut self) {
self.join_handle.abort();
self.client_listener.abort();
self.client_dispatcher.abort();
}
}

View File

@@ -96,7 +96,11 @@ impl CoreSurface {
// Import all surface buffers into textures
if let Err(err) = import_surface_tree(renderer, &wl_surface) {
tracing::error!("Failed to import surface tree for surface {}: {}", wl_surface.id(), err);
tracing::error!(
"Failed to import surface tree for surface {}: {}",
wl_surface.id(),
err
);
return;
}
@@ -112,7 +116,9 @@ impl CoreSurface {
let Some(smithay_tex) = wl_surface
.get_data_raw::<RendererSurfaceStateUserData, _, _>(|surface_states| {
let locked = surface_states.lock().unwrap();
locked.texture::<GlesRenderer>(renderer.id()).cloned()
locked
.texture::<GlesTexture>(renderer.context_id())
.cloned()
})
.flatten()
else {
@@ -127,20 +133,22 @@ impl CoreSurface {
tracing::error!("No sk_mat found for surface");
return;
};
sk_tex
.lock()
.0
.set_native_surface(
smithay_tex.tex_id() as usize as *mut c_void,
TexType::ImageNomips,
smithay::backend::renderer::gles::ffi::RGBA8.into(),
smithay_tex.width() as i32,
smithay_tex.height() as i32,
1,
false,
)
.sample_mode(TexSample::Point)
.address_mode(TexAddress::Clamp);
unsafe {
sk_tex
.lock()
.0
.set_native_surface(
smithay_tex.tex_id() as usize as *mut c_void,
TexType::ImageNomips,
smithay::backend::renderer::gles::ffi::RGBA8.into(),
smithay_tex.width() as i32,
smithay_tex.height() as i32,
1,
false,
)
.sample_mode(TexSample::Point)
.address_mode(TexAddress::Clamp)
};
if let Some(material_offset) = self.material_offset.lock().delta() {
sk_mat.lock().0.queue_offset(*material_offset as i32);