Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottatop committed Jun 22, 2024
1 parent b655a17 commit 3643480
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 150 deletions.
270 changes: 250 additions & 20 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repository = "https://github.com/pinnacle-comp/pinnacle/"
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"]}
tokio-stream = { version = "0.1.15", features = ["net"] }
# gRPC
prost = "0.12.4"
prost = "0.12.6"
tonic = "0.11.0"
tonic-reflection = "0.11.0"
tonic-build = "0.11.0"
Expand All @@ -30,14 +30,14 @@ pinnacle-api-defs = { path = "./pinnacle-api-defs" }
xkbcommon = "0.7.0"
xdg = "2.5.2"
bitflags = "2.5.0"
clap = { version = "4.5.4", features = ["derive"] }
clap = { version = "4.5.7", features = ["derive"] }
dircpy = "0.3.16"
tempfile = "3.10.1"
indexmap = "2.2.6"

[workspace.dependencies.smithay]
git = "https://github.com/Smithay/smithay"
rev = "b4f8120"
rev = "69b379d"
# path = "../../git/smithay"
default-features = false
features = [
Expand All @@ -48,7 +48,6 @@ features = [
"backend_udev",
"backend_drm",
"backend_gbm",
"backend_vulkan",
"backend_egl",
"backend_session_libseat",
"renderer_gl",
Expand Down Expand Up @@ -86,14 +85,14 @@ keywords = ["wayland", "compositor", "smithay", "lua"]
[dependencies]
# Smithay
smithay = { workspace = true }
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "b4f8120" }
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "69b379d" }
# Tracing
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-appender = "0.2.3"
# Errors
anyhow = { version = "1.0.83", features = ["backtrace"] }
thiserror = "1.0.60"
anyhow = { version = "1.0.86", features = ["backtrace"] }
thiserror = "1.0.61"
# xcursor stuff
xcursor = { version = "0.3.5" }
image = { version = "0.25.1", default-features = false }
Expand All @@ -106,11 +105,11 @@ tokio = { workspace = true, features = ["process", "io-util", "signal"] }
tokio-stream = { workspace = true }
# CLI
clap = { workspace = true }
cliclack = "0.2.5"
cliclack = "0.3.1"
# Misc.
bitflags = { workspace = true }
serde = { version = "1.0.202", features = ["derive"] }
toml = "0.8.13"
serde = { version = "1.0.203", features = ["derive"] }
toml = "0.8.14"
shellexpand = { version = "3.1.0", features = ["path"] }
x11rb = { version = "0.13.1", default-features = false, features = ["composite"] }
xkbcommon = { workspace = true }
Expand All @@ -120,7 +119,7 @@ sysinfo = "0.30.12"
pinnacle-api-defs = { workspace = true }
dircpy = { workspace = true }
chrono = "0.4.38"
bytemuck = "1.16.0"
bytemuck = "1.16.1"
pinnacle-api = { path = "./api/rust", default-features = false }
gag = "1.0.0"
drm-sys = "0.7.0"
Expand Down
2 changes: 1 addition & 1 deletion snowcap
Submodule snowcap updated 2 files
+18 −12 src/lib.rs
+1 −1 src/main.rs
77 changes: 8 additions & 69 deletions src/backend/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ mod drm;
mod gamma;

pub use drm::util::drm_mode_from_api_modeline;
use indexmap::IndexSet;

use std::{
collections::{HashMap, HashSet},
path::Path,
time::Duration,
};
use std::{collections::HashMap, path::Path, time::Duration};

use anyhow::{anyhow, ensure, Context};
use drm::{set_crtc_active, util::create_drm_mode};
use pinnacle_api_defs::pinnacle::signal::v0alpha1::OutputConnectResponse;
use smithay::{
backend::{
allocator::{
dmabuf::{AnyError, Dmabuf, DmabufAllocator},
gbm::{GbmAllocator, GbmBuffer, GbmBufferFlags, GbmDevice},
vulkan::{ImageUsageFlags, VulkanAllocator},
Allocator, Buffer, Fourcc,
Buffer, Fourcc,
},
drm::{
compositor::{DrmCompositor, PrimaryPlaneElement, RenderFrameResult},
Expand All @@ -46,14 +41,12 @@ use smithay::{
Session,
},
udev::{self, UdevBackend, UdevEvent},
vulkan::{self, version::Version, PhysicalDevice},
SwapBuffersError,
},
desktop::utils::OutputPresentationFeedback,
input::pointer::CursorImageStatus,
output::{Output, PhysicalProperties, Subpixel},
reexports::{
ash::vk::ExtPhysicalDeviceDrmFn,
calloop::{
self, generic::Generic, timer::Timer, Dispatcher, Idle, Interest, LoopHandle,
PostAction, RegistrationToken,
Expand Down Expand Up @@ -129,7 +122,6 @@ pub struct Udev {
display_handle: DisplayHandle,
pub(super) dmabuf_state: Option<(DmabufState, DmabufGlobal)>,
pub(super) primary_gpu: DrmNode,
allocator: Option<Box<dyn Allocator<Buffer = Dmabuf, Error = AnyError>>>,
pub(super) gpu_manager: GpuManager<GbmGlesBackend<GlesRenderer, DrmDeviceFd>>,
backends: HashMap<DrmNode, UdevBackendData>,

Expand Down Expand Up @@ -218,7 +210,6 @@ impl Udev {
session,
primary_gpu,
gpu_manager,
allocator: None,
backends: HashMap::new(),

upscale_filter: TextureFilter::Linear,
Expand Down Expand Up @@ -416,56 +407,6 @@ impl Udev {
.shm_formats(),
);

// Create the Vulkan allocator
if let Ok(instance) = vulkan::Instance::new(Version::VERSION_1_2, None) {
if let Some(physical_device) = PhysicalDevice::enumerate(&instance)
.ok()
.and_then(|devices| {
devices
.filter(|phd| {
phd.has_device_extension(ExtPhysicalDeviceDrmFn::name())
})
.find(|phd| {
phd.primary_node()
.is_ok_and(|node| node == Some(primary_gpu))
|| phd
.render_node()
.is_ok_and(|node| node == Some(primary_gpu))
})
})
{
match VulkanAllocator::new(
&physical_device,
ImageUsageFlags::COLOR_ATTACHMENT | ImageUsageFlags::SAMPLED,
) {
Ok(allocator) => {
udev.allocator = Some(Box::new(DmabufAllocator(allocator))
as Box<dyn Allocator<Buffer = Dmabuf, Error = AnyError>>);
}
Err(err) => {
warn!("Failed to create vulkan allocator: {}", err);
}
}
}
}

if udev.allocator.is_none() {
info!("No vulkan allocator found, using GBM.");
let gbm = udev
.backends
.get(&primary_gpu)
// If the primary_gpu failed to initialize, we likely have a kmsro device
.or_else(|| udev.backends.values().next())
// Don't fail, if there is no allocator. There is a chance, that this a single gpu system and we don't need one.
.map(|backend| backend.gbm.clone());
udev.allocator = gbm.map(|gbm| {
Box::new(DmabufAllocator(GbmAllocator::new(
gbm,
GbmBufferFlags::RENDERING,
))) as Box<_>
});
}

let mut renderer = udev.gpu_manager.single_renderer(&primary_gpu)?;

info!(
Expand All @@ -479,7 +420,7 @@ impl Udev {
}

// init dmabuf support with format list from our primary gpu
let dmabuf_formats = renderer.dmabuf_formats().collect::<Vec<_>>();
let dmabuf_formats = renderer.dmabuf_formats();
let default_feedback =
DmabufFeedbackBuilder::new(primary_gpu.dev_id(), dmabuf_formats)
.build()
Expand Down Expand Up @@ -747,20 +688,18 @@ fn get_surface_dmabuf_feedback(
let primary_formats = gpu_manager
.single_renderer(&primary_gpu)
.ok()?
.dmabuf_formats()
.collect::<HashSet<_>>();
.dmabuf_formats();

let render_formats = gpu_manager
.single_renderer(&render_node)
.ok()?
.dmabuf_formats()
.collect::<HashSet<_>>();
.dmabuf_formats();

let all_render_formats = primary_formats
.iter()
.chain(render_formats.iter())
.copied()
.collect::<HashSet<_>>();
.collect::<IndexSet<_>>();

let surface = composition.surface();
let planes = surface.planes().clone();
Expand All @@ -772,7 +711,7 @@ fn get_surface_dmabuf_feedback(
.formats
.into_iter()
.chain(planes.overlay.into_iter().flat_map(|p| p.formats))
.collect::<HashSet<_>>()
.collect::<IndexSet<_>>()
.intersection(&all_render_formats)
.copied()
.collect::<Vec<_>>();
Expand Down
18 changes: 6 additions & 12 deletions src/backend/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use smithay::{
DisplayHandle,
},
winit::{
platform::wayland::WindowBuilderExtWayland,
window::{Icon, WindowBuilder},
platform::wayland::WindowAttributesExtWayland,
window::{Icon, WindowAttributes},
},
},
utils::{IsAlive, Point, Rectangle, Transform},
Expand Down Expand Up @@ -82,13 +82,13 @@ impl Backend {

impl Winit {
pub(crate) fn try_new(display_handle: DisplayHandle) -> anyhow::Result<UninitBackend<Winit>> {
let window_builder = WindowBuilder::new()
let window_attrs = WindowAttributes::default()
.with_title("Pinnacle")
.with_name("pinnacle", "pinnacle")
.with_window_icon(Icon::from_rgba(LOGO_BYTES.to_vec(), 64, 64).ok());

let (mut winit_backend, winit_evt_loop) =
match winit::init_from_builder::<GlesRenderer>(window_builder) {
match winit::init_from_attributes::<GlesRenderer>(window_attrs) {
Ok(ret) => ret,
Err(err) => anyhow::bail!("Failed to init winit backend: {err}"),
};
Expand Down Expand Up @@ -123,10 +123,7 @@ impl Winit {

let dmabuf_default_feedback = match render_node {
Ok(Some(node)) => {
let dmabuf_formats = winit_backend
.renderer()
.dmabuf_formats()
.collect::<Vec<_>>();
let dmabuf_formats = winit_backend.renderer().dmabuf_formats();
let dmabuf_default_feedback =
DmabufFeedbackBuilder::new(node.dev_id(), dmabuf_formats)
.build()
Expand All @@ -153,10 +150,7 @@ impl Winit {
(dmabuf_state, dmabuf_global, Some(default_feedback))
}
None => {
let dmabuf_formats = winit_backend
.renderer()
.dmabuf_formats()
.collect::<Vec<_>>();
let dmabuf_formats = winit_backend.renderer().dmabuf_formats();
let mut dmabuf_state = DmabufState::new();
let dmabuf_global =
dmabuf_state.create_global::<State>(&display_handle, dmabuf_formats);
Expand Down
3 changes: 2 additions & 1 deletion src/grab/resize_grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ impl PointerGrab<State> for ResizeSurfaceGrab {

let (min_size, max_size) = match self.window.wl_surface() {
Some(wl_surface) => compositor::with_states(&wl_surface, |states| {
let data = states.cached_state.current::<SurfaceCachedState>();
let mut guard = states.cached_state.get::<SurfaceCachedState>();
let data = guard.current();
(data.min_size, data.max_size)
}),
None => (Size::default(), Size::default()),
Expand Down
3 changes: 2 additions & 1 deletion src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ impl CompositorHandler for State {
let maybe_dmabuf = compositor::with_states(surface, |surface_data| {
surface_data
.cached_state
.pending::<SurfaceAttributes>()
.get::<SurfaceAttributes>()
.pending()
.buffer
.as_ref()
.and_then(|assignment| match assignment {
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/xdg_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ pub fn snapshot_pre_commit_hook(
};

let got_unmapped = compositor::with_states(surface, |states| {
let buffer = &states.cached_state.pending::<SurfaceAttributes>().buffer;
let mut guard = states.cached_state.get::<SurfaceAttributes>();
let buffer = &guard.pending().buffer;
matches!(buffer, Some(BufferAssignment::Removed))
});

Expand Down
8 changes: 6 additions & 2 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,10 @@ impl State {
// Focus the topmost exclusive layer, if any
for layer in self.pinnacle.layer_shell_state.layer_surfaces().rev() {
let data = compositor::with_states(layer.wl_surface(), |states| {
*states.cached_state.current::<LayerSurfaceCachedState>()
*states
.cached_state
.get::<LayerSurfaceCachedState>()
.current()
});
if data.keyboard_interactivity == KeyboardInteractivity::Exclusive
&& matches!(
Expand Down Expand Up @@ -868,7 +871,8 @@ impl State {
compositor::with_states(&*focus.wl_surface()?, |states| {
states
.cached_state
.current::<SurfaceAttributes>()
.get::<SurfaceAttributes>()
.current()
.input_region
.clone()
})
Expand Down
31 changes: 15 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use pinnacle::{
util::increase_nofile_rlimit,
};
use smithay::reexports::{calloop::EventLoop, rustix::process::geteuid};
use tokio::sync::oneshot::error::TryRecvError;
use tracing::{error, info, warn};
use tracing_appender::rolling::Rotation;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer};
Expand Down Expand Up @@ -176,30 +177,28 @@ async fn main() -> anyhow::Result<()> {

#[cfg(feature = "snowcap")]
{
use smithay::reexports::calloop;
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};

info!("Starting Snowcap");
let (ping, source) = calloop::ping::make_ping()?;
let ready_flag = Arc::new(AtomicBool::new(false));
let ready_clone = ready_flag.clone();
let (sender, mut recv) = tokio::sync::oneshot::channel();
let join_handle = tokio::task::spawn_blocking(move || {
let _span = tracing::error_span!("snowcap");
let _span = _span.enter();
snowcap::start(Some(source), ready_clone);
snowcap::start(Some(sender));
});

while !ready_flag.load(Ordering::SeqCst) {
let stop_signal = loop {
if join_handle.is_finished() {
panic!("snowcap failed to start");
}
event_loop.dispatch(Duration::from_secs(1), &mut state)?;
state.on_event_loop_cycle_completion();
}
state.pinnacle.snowcap_shutdown_ping = Some(ping);
match recv.try_recv() {
Ok(stop_signal) => break stop_signal,
Err(TryRecvError::Empty) => {
event_loop.dispatch(Duration::from_secs(1), &mut state)?;
state.on_event_loop_cycle_completion();
}
Err(TryRecvError::Closed) => panic!("snowcap failed to start"),
}
};

state.pinnacle.snowcap_stop_signal = Some(stop_signal);
state.pinnacle.snowcap_join_handle = Some(join_handle);
}

Expand Down
Loading

0 comments on commit 3643480

Please sign in to comment.