Sign In
Forgot Password?
Sign In | | Create Account

Understanding animation performance using Sourcery Analyzer

Brad Dixon

Brad Dixon

Posted Jun 24, 2013
0 Comments

One of the fun parts about working at Mentor Graphics is that we’ve got a large team of very bright engineers who find novel uses for our products. We just wrapped up the first stage of an internal contest that challenged our developers to apply Sourcery Analyzer to problems that they had seen customers struggling with or that were impeding their own progress. I’d like to share the work of one of our winners, Asad Zia, who applied Sourcery Analyzer to help improve the performance of animated user interfaces.

Modern user interfaces exploit the underlying power of GPUs to produce fluid animations. For example when a text entry keyboard slides up over an application the screen is showing images provided by several applications and OS services. This careful interaction of software and hardware doesn’t always work out perfectly as this clip shows:

Obviously that jerky motion as the pink area slides out is not what we are shooting for. Additionally the distance between the left edge of the scrollbar and the edge of the blue field changes during the slide effect. That destroys the effect by reducing the perception that these are physical objects being slid on-screen.

To understand what is going on a little background information on how graphics are displayed on a screen is helpful. Back in the dark ages computer displays were made out of large vacuum tubes with an electron gun scanning top to bottom one row at a time. You may have read about this in history class.

Television scan

When the scan reached the bottom the electron gun would re-aim from the bottom-right hand corner to the top-left hand corner. This re-aiming took a while to complete and happened at a regular interval that could be derived from the resolution of the display and the horizontal scanning rate. Wikipedia gives an example of “… a monitor with a horizontal scanning frequency of 96 kHz at a resolution of 1280 × 1024 results in a refresh rate of 96,000 / (1024 × 1.05) ≈ 89 Hz”. Computer video cards that drive these monitors generate a vertical blanking signal that causes the electron gun to re-aim.

Even though LCD monitors don’t have an electron gun their internal architecture defines a refresh rate which typically is around 60Hz.

The implication for software is that once every 60Hz (depending on the monitor and resolution) came the opportunity to change the image displayed on the screen without showing partial or distorted image. This short time window is the “vertical blanking interval” (VBI). At the start of the VBI the GPU takes a snapshot of the control registers that define the image and begin updating the displayed image. For a software developer this is a critical deadline. If the software has not completed updating the control registers in time the image will be corrupted in some way.

Asad’s thesis was that the compositor he was working on was missing this deadline. To test this hypothesis he added two software trace points to his application:

  • One which triggered on the vertical blanking interval interrupt
  • Another which triggered when the compositor began loading new values into the GPU control registers

This is what the data looks like:

Obviously using cursors to measure the interval between each write to the GPU control registers and the VBI is just not going to be very fun or practical. Asad then took advantage of one of the powerful features of Sourcery Analyzer and created a custom Analysis Agent to automate this type of tedium.

Bingo! Asad’s custom agent highlighted the areas of software execution where bad frames are likely to be produced due to writes to the GPU control registers in close proximity to the VBI. From this point it was easy work to inspect other activities in the system to why the deadline is being missed and rebalance the workload appropriately. While this demonstration was done under Linux the custom analysis agent itself is portable provided that the target software environment produces the appropriate trace events.

The big win for this effort is that the new custom analysis agent can be shared with other colleagues to allow them to easily check for bad video frames during their engineering efforts. This key feature will help Sourcery Analyzer customers to create a library of application specific analysis agents that can be used to spot check and diagnose application issues during development when problems can most easily be fixed.

Lastly here’s how Asad’s slide effect improved after modifying his application to correctly time graphics layer updates to occur during the vertical blanking interval:

As you can see the slide effect is both smoother and the distance between the scroll bar and the edge of the blue field doesn’t change during the slide animation. Great improvement!

We have other contest entries we’ll be sharing with you soon. There are some really exciting applications for this tool being cooked up by our engineering team. Maybe this tool would be useful on your own software behavior or performance challenge. If you’d like to try this out on your own then feel free to start an evaluation of Sourcery Analyzer. Questions? Drop into the Sourcery Tools forum and ask.

More Blog Posts

About Brad Dixon

Brad DixonBrad Dixon is the Director of Open Source and Tools Solutions at Mentor Graphics responsible for Mentor Embedded Linux, Sourcery developer tools, and probes solutions. Brad has been at the nexus of open source and embedded software as a developer, application engineer, and product manager since 2000. Previously at MontaVista, Brad has helped some of the world’s most demanding companies understand how to apply Linux and other open source technology to design new applications and devices. In addition to technical nuts and bolts, Brad is involved in open source licensing, quality assurance, networking, and security. Visit Embedded Blog

More Posts by Brad Dixon

Comments

No one has commented yet on this post. Be the first to comment below.

Add Your Comment

Please complete the following information to comment or sign in.

(Your email will not be published)

Archives

 
Online Chat