Skip to content

Commit

Permalink
drm: profile frame finish
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeissl committed Sep 4, 2023
1 parent 2401467 commit fb467e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ struct SurfaceCompositorRenderResult {
}

impl SurfaceComposition {
#[profiling::function]
fn frame_submitted(&mut self) -> Result<Option<Option<OutputPresentationFeedback>>, SwapBuffersError> {
match self {
SurfaceComposition::Compositor(c) => c.frame_submitted().map_err(Into::<SwapBuffersError>::into),
Expand Down Expand Up @@ -788,6 +789,7 @@ impl AnvilState<UdevData> {
notifier,
move |event, metadata, data: &mut CalloopData<_>| match event {
DrmEvent::VBlank(crtc) => {
profiling::scope!("vblank", &format!("{:?}:{crtc:?}", node.dev_path().unwrap()));
data.state.frame_finish(node, crtc, metadata);
}
DrmEvent::Error(error) => {
Expand Down Expand Up @@ -1081,6 +1083,11 @@ impl AnvilState<UdevData> {
}

fn frame_finish(&mut self, dev_id: DrmNode, crtc: crtc::Handle, metadata: &mut Option<DrmEventMetadata>) {
profiling::scope!(
"frame_finish",
&format!("{:?}:{crtc:?}", dev_id.dev_path().unwrap())
);

let device_backend = match self.backend_data.backends.get_mut(&dev_id) {
Some(backend) => backend,
None => {
Expand Down
1 change: 1 addition & 0 deletions src/backend/drm/compositor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2434,6 +2434,7 @@ where
/// *Note*: Needs to be called, after the vblank event of the matching [`DrmDevice`](super::super::DrmDevice)
/// was received after calling [`DrmCompositor::queue_frame`] on this surface.
/// Otherwise the underlying swapchain will run out of buffers eventually.
#[profiling::function]
pub fn frame_submitted(&mut self) -> FrameResult<Option<U>, A, F> {
if let Some((mut pending, user_data)) = self.pending_frame.take() {
std::mem::swap(&mut pending, &mut self.current_frame);
Expand Down

0 comments on commit fb467e4

Please sign in to comment.