mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-13 08:01:05 +01:00
commit
ebebcfb4a1
3 changed files with 59 additions and 29 deletions
14
Cargo.toml
14
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pinnacle"
|
name = "pinnacle"
|
||||||
version = "0.1.0"
|
version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@ license = "MPL-2.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||||
smithay = { git = "https://github.com/Smithay/smithay", rev = "9b3d173" }
|
smithay = { git = "https://github.com/Smithay/smithay", rev = "ae7fb22" }
|
||||||
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", optional = true }
|
smithay-drm-extras = { git = "https://github.com/Smithay/smithay", optional = true }
|
||||||
thiserror = "1.0.40"
|
thiserror = "1.0.44"
|
||||||
xcursor = {version = "0.3.4", optional = true }
|
xcursor = {version = "0.3.4", optional = true }
|
||||||
image = {version = "0.24.0", default-features = false, optional = true}
|
image = {version = "0.24.6", default-features = false, optional = true}
|
||||||
serde = { version = "1.0.164", features = ["derive"] }
|
serde = { version = "1.0.174", features = ["derive"] }
|
||||||
rmp = { version = "0.8.11" }
|
rmp = { version = "0.8.12" }
|
||||||
rmp-serde = { version = "1.1.1" }
|
rmp-serde = { version = "1.1.2" }
|
||||||
calloop = { version = "0.10.1", features = ["executor", "futures-io"] }
|
calloop = { version = "0.10.1", features = ["executor", "futures-io"] }
|
||||||
futures-lite = { version = "1.13.0" }
|
futures-lite = { version = "1.13.0" }
|
||||||
async-process = { version = "1.7.0" }
|
async-process = { version = "1.7.0" }
|
||||||
|
|
|
@ -26,8 +26,9 @@ use smithay::{
|
||||||
Allocator, Fourcc,
|
Allocator, Fourcc,
|
||||||
},
|
},
|
||||||
drm::{
|
drm::{
|
||||||
compositor::DrmCompositor, CreateDrmNodeError, DrmDevice, DrmDeviceFd, DrmError,
|
compositor::{DrmCompositor, PrimaryPlaneElement},
|
||||||
DrmEvent, DrmEventMetadata, DrmNode, DrmSurface, GbmBufferedSurface, NodeType,
|
CreateDrmNodeError, DrmDevice, DrmDeviceFd, DrmError, DrmEvent, DrmEventMetadata,
|
||||||
|
DrmNode, DrmSurface, GbmBufferedSurface, NodeType,
|
||||||
},
|
},
|
||||||
egl::{self, EGLDevice, EGLDisplay},
|
egl::{self, EGLDevice, EGLDisplay},
|
||||||
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
||||||
|
@ -39,6 +40,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
gles::{GlesRenderer, GlesTexture},
|
gles::{GlesRenderer, GlesTexture},
|
||||||
multigpu::{gbm::GbmGlesBackend, GpuManager, MultiRenderer, MultiTexture},
|
multigpu::{gbm::GbmGlesBackend, GpuManager, MultiRenderer, MultiTexture},
|
||||||
|
sync::SyncPoint,
|
||||||
Bind, ExportMem, ImportDma, ImportEgl, ImportMemWl, Offscreen, Renderer,
|
Bind, ExportMem, ImportDma, ImportEgl, ImportMemWl, Offscreen, Renderer,
|
||||||
},
|
},
|
||||||
session::{
|
session::{
|
||||||
|
@ -80,7 +82,9 @@ use smithay::{
|
||||||
backend::GlobalId, protocol::wl_surface::WlSurface, Display, DisplayHandle,
|
backend::GlobalId, protocol::wl_surface::WlSurface, Display, DisplayHandle,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
utils::{Clock, DeviceFd, IsAlive, Logical, Monotonic, Point, Scale, Transform},
|
utils::{
|
||||||
|
Clock, DeviceFd, IsAlive, Logical, Monotonic, Physical, Point, Rectangle, Scale, Transform,
|
||||||
|
},
|
||||||
wayland::{
|
wayland::{
|
||||||
compositor,
|
compositor,
|
||||||
dmabuf::{
|
dmabuf::{
|
||||||
|
@ -592,6 +596,13 @@ enum SurfaceComposition {
|
||||||
Compositor(GbmDrmCompositor),
|
Compositor(GbmDrmCompositor),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SurfaceCompositorRenderResult {
|
||||||
|
rendered: bool,
|
||||||
|
states: RenderElementStates,
|
||||||
|
sync: Option<SyncPoint>,
|
||||||
|
damage: Option<Vec<Rectangle<i32, Physical>>>,
|
||||||
|
}
|
||||||
|
|
||||||
impl SurfaceComposition {
|
impl SurfaceComposition {
|
||||||
fn frame_submitted(&mut self) -> Result<Option<OutputPresentationFeedback>, SwapBuffersError> {
|
fn frame_submitted(&mut self) -> Result<Option<OutputPresentationFeedback>, SwapBuffersError> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -629,11 +640,13 @@ impl SurfaceComposition {
|
||||||
|
|
||||||
fn queue_frame(
|
fn queue_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
sync: Option<SyncPoint>,
|
||||||
|
damage: Option<Vec<Rectangle<i32, Physical>>>,
|
||||||
user_data: Option<OutputPresentationFeedback>,
|
user_data: Option<OutputPresentationFeedback>,
|
||||||
) -> Result<(), SwapBuffersError> {
|
) -> Result<(), SwapBuffersError> {
|
||||||
match self {
|
match self {
|
||||||
SurfaceComposition::Surface { surface, .. } => surface
|
SurfaceComposition::Surface { surface, .. } => surface
|
||||||
.queue_buffer(None, user_data)
|
.queue_buffer(sync, damage, user_data)
|
||||||
.map_err(Into::<SwapBuffersError>::into),
|
.map_err(Into::<SwapBuffersError>::into),
|
||||||
SurfaceComposition::Compositor(c) => c
|
SurfaceComposition::Compositor(c) => c
|
||||||
.queue_frame(user_data)
|
.queue_frame(user_data)
|
||||||
|
@ -646,7 +659,7 @@ impl SurfaceComposition {
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
elements: &[E],
|
elements: &[E],
|
||||||
clear_color: [f32; 4],
|
clear_color: [f32; 4],
|
||||||
) -> Result<(bool, RenderElementStates), SwapBuffersError>
|
) -> Result<SurfaceCompositorRenderResult, SwapBuffersError>
|
||||||
where
|
where
|
||||||
R: Renderer + Bind<Dmabuf> + Bind<Target> + Offscreen<Target> + ExportMem,
|
R: Renderer + Bind<Dmabuf> + Bind<Target> + Offscreen<Target> + ExportMem,
|
||||||
<R as Renderer>::TextureId: 'static,
|
<R as Renderer>::TextureId: 'static,
|
||||||
|
@ -670,7 +683,16 @@ impl SurfaceComposition {
|
||||||
|
|
||||||
let res = damage_tracker
|
let res = damage_tracker
|
||||||
.render_output(renderer, age.into(), elements, clear_color)
|
.render_output(renderer, age.into(), elements, clear_color)
|
||||||
.map(|(damage, states)| (damage.is_some(), states))
|
.map(|res| {
|
||||||
|
res.sync.wait(); // feature flag here
|
||||||
|
let rendered = res.damage.is_some();
|
||||||
|
SurfaceCompositorRenderResult {
|
||||||
|
rendered,
|
||||||
|
damage: res.damage,
|
||||||
|
states: res.states,
|
||||||
|
sync: rendered.then_some(res.sync),
|
||||||
|
}
|
||||||
|
})
|
||||||
.map_err(|err| match err {
|
.map_err(|err| match err {
|
||||||
damage::Error::Rendering(err) => err.into(),
|
damage::Error::Rendering(err) => err.into(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -681,10 +703,18 @@ impl SurfaceComposition {
|
||||||
SurfaceComposition::Compositor(compositor) => compositor
|
SurfaceComposition::Compositor(compositor) => compositor
|
||||||
.render_frame(renderer, elements, clear_color)
|
.render_frame(renderer, elements, clear_color)
|
||||||
.map(|render_frame_result| {
|
.map(|render_frame_result| {
|
||||||
(
|
// feature flag here
|
||||||
render_frame_result.damage.is_some(),
|
if let PrimaryPlaneElement::Swapchain(element) =
|
||||||
render_frame_result.states,
|
render_frame_result.primary_element
|
||||||
)
|
{
|
||||||
|
element.sync.wait();
|
||||||
|
}
|
||||||
|
SurfaceCompositorRenderResult {
|
||||||
|
rendered: render_frame_result.damage.is_some(),
|
||||||
|
states: render_frame_result.states,
|
||||||
|
sync: None,
|
||||||
|
damage: None,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.map_err(|err| match err {
|
.map_err(|err| match err {
|
||||||
smithay::backend::drm::compositor::RenderFrameError::PrepareFrame(err) => {
|
smithay::backend::drm::compositor::RenderFrameError::PrepareFrame(err) => {
|
||||||
|
@ -1518,7 +1548,7 @@ fn render_surface<'a>(
|
||||||
.map(OutputRenderElements::Space),
|
.map(OutputRenderElements::Space),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (rendered, states) = surface.compositor.render_frame::<_, _, GlesTexture>(
|
let res = surface.compositor.render_frame::<_, _, GlesTexture>(
|
||||||
renderer,
|
renderer,
|
||||||
&output_render_elements,
|
&output_render_elements,
|
||||||
[0.6, 0.6, 0.6, 1.0],
|
[0.6, 0.6, 0.6, 1.0],
|
||||||
|
@ -1533,7 +1563,7 @@ fn render_surface<'a>(
|
||||||
surface,
|
surface,
|
||||||
output,
|
output,
|
||||||
states_inner,
|
states_inner,
|
||||||
&states,
|
&res.states,
|
||||||
element::default_primary_scanout_output_compare,
|
element::default_primary_scanout_output_compare,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1568,7 +1598,7 @@ fn render_surface<'a>(
|
||||||
|surface, _| {
|
|surface, _| {
|
||||||
select_dmabuf_feedback(
|
select_dmabuf_feedback(
|
||||||
surface,
|
surface,
|
||||||
&states,
|
&res.states,
|
||||||
dmabuf_feedback.render_feedback,
|
dmabuf_feedback.render_feedback,
|
||||||
dmabuf_feedback.scanout_feedback,
|
dmabuf_feedback.scanout_feedback,
|
||||||
)
|
)
|
||||||
|
@ -1579,15 +1609,15 @@ fn render_surface<'a>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if rendered {
|
if res.rendered {
|
||||||
let output_presentation_feedback = take_presentation_feedback(output, space, &states);
|
let output_presentation_feedback = take_presentation_feedback(output, space, &res.states);
|
||||||
surface
|
surface
|
||||||
.compositor
|
.compositor
|
||||||
.queue_frame(Some(output_presentation_feedback))
|
.queue_frame(res.sync, res.damage, Some(output_presentation_feedback))
|
||||||
.map_err(Into::<SwapBuffersError>::into)?;
|
.map_err(Into::<SwapBuffersError>::into)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(rendered)
|
Ok(res.rendered)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initial_render(
|
fn initial_render(
|
||||||
|
@ -1601,7 +1631,7 @@ fn initial_render(
|
||||||
&[],
|
&[],
|
||||||
[0.6, 0.6, 0.6, 1.0],
|
[0.6, 0.6, 0.6, 1.0],
|
||||||
)?;
|
)?;
|
||||||
surface.compositor.queue_frame(None)?;
|
surface.compositor.queue_frame(None, None, None)?;
|
||||||
surface.compositor.reset_buffers();
|
surface.compositor.reset_buffers();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -315,9 +315,9 @@ pub fn run_winit() -> Result<(), Box<dyn Error>> {
|
||||||
});
|
});
|
||||||
|
|
||||||
match render_res {
|
match render_res {
|
||||||
Ok((damage, states)) => {
|
Ok(render_output_result) => {
|
||||||
let has_rendered = damage.is_some();
|
let has_rendered = render_output_result.damage.is_some();
|
||||||
if let Some(damage) = damage {
|
if let Some(damage) = render_output_result.damage {
|
||||||
if let Err(err) = state.backend_data.backend.submit(Some(&damage)) {
|
if let Err(err) = state.backend_data.backend.submit(Some(&damage)) {
|
||||||
tracing::warn!("{}", err);
|
tracing::warn!("{}", err);
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ pub fn run_winit() -> Result<(), Box<dyn Error>> {
|
||||||
surface,
|
surface,
|
||||||
&output,
|
&output,
|
||||||
states_inner,
|
states_inner,
|
||||||
&states,
|
&render_output_result.states,
|
||||||
default_primary_scanout_output_compare,
|
default_primary_scanout_output_compare,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue