Posts: 392 from 2003/4/11
With this news on hardware accelerated Radeons: http://www.heise.de/newsticker/meldung/Quelloffene-Linux-3D-Treiber-bekommen-OpenGL-4-0-Unterstuetzung-2760942.html (sorry, German only but Gogole translate could do the job) I wondered if our Radeon driver are hardware accelerated, too, at least for 2D. Because when I grab a window on Ambient, hold down the left mouse button and throw the window around for some seconds then the CPU goes up to 100% on a 1.5GHz Mac mini. But just moving around a window should cost the CPU nothing. So it seems like the CPU does all the job instead of the GPU. Is that true? If yes, will it change at some point?
Yes, the Radeon driver uses hardware acceleration, both 2D and 3D.
Longer answer, which will overlap a bit with other replies, and correct a few things:
To fully answer your question, I first need to explain what hardware acceleration means when it comes to graphics, and what the difference between "2D" and "3D" hardware acceleration is.
At the most abstract definition, graphics hardware acceleration is using an external (to the CPU) device to manipulate data in graphics memory. A slightly more specific definition of what is commonly known as "2D" graphics acceleration is to use an external (again, to the CPU) device to manipulate data in graphics memory, usually in rectangular shapes or in (possibly diagonal) lines.
All Radeons up to and including the R500 family of Radeon chips support this type of hardware acceleration. Newer Radeons do not. I'll explain that a bit later.
The operations most commonly used in "2D" graphics acceleration are copying rectangles, clearing/drawing solid rectangles and drawing lines. Also commonly used in MorphOS are graphics operations that "expand" data, for example for rendering text. All of this, and a bit more, is fully hardware accelerated on MorphOS.
So why does moving a window around take up CPU time? The simple answer is that there's a lot more involved in moving windows around than it would first seem. Some of them have minor impact on CPU usage, others a larger impact. Here's a list of some of them:
- Mouse input needs to be handled. Although this one is minor in the grand scheme of things, it's the first step. USB is relatively complex hardware, and USB drivers are therefore equally complex. A relatively large amount of code goes into handling the USB side of getting mouse input. From there on, Intuition needs to deal with that input: There's a bunch of calculations to do there, such as figuring out which window is now underneath the mouse, if any actions should be taken, and then updating the position of the cursor on the screen. All quite minor stuff, but still worth noting.
- Once it has been determined that a window needs to be moved, a bunch of new calculations need to happen, such as figuring out what needs to be refreshed in the space now revealed by the old position of the window. Once that has been figured out, all applications involved in that refresh need to run and basically redraw their entire user interface. Although the drawing will be clipped to only render the area that needs to be refreshed, in most cases the same calculations need to be done no matter how big an area needs to be refreshed.
- All of these rendering commands need to be sent to the graphics processor. This in itself also takes CPU time.
- Finally the CPU needs to wait till the graphics processor is done with its rendering jobs. If the graphics processor is relatively slow, like it is in the Mac Mini, this will take more time than if the graphics processor is fast.
This is at least part of the explanation for why you see high CPU usage when moving windows around. This doesn't cover everything completely, but as you can see, just because the hardware can perform some rendering commands doesn't mean that the CPU has no work left to do. There's still plenty for the CPU to do.
I just tried moving a window around on my Linux machine. It ended up using 200% CPU time while moving the window around. The 200% in Linux terms means that the equivalent of having two cores run at 100% usage was used. So this phenomenon is also not specific to MorphOS.
Moving on to the topic of "3D" acceleration, a simple definition of "3D" acceleration could be to use an external device to render triangle shaped objects, usually supporting a multitude of different rendering options.
Again in the case of Radeons up to and including R500, there's a part of the chip that's dedicated to doing just this, which is separate from the 2D acceleration part. MorphOS also supports graphics acceleration using this part of the chip, both for actual 3D rendering but also for what would normally be considered 2D rendering.
Do you see those icons on your Ambient screen? Do you notice how they're not appearing as rectangular, but rather have complex shapes? Well, technically they're rendered as triangles
using the 3D part of the Radeon chip. The 3D part is used because it supports per-pixel blending between the icon and the background, giving the illusion of rendering icons with a complex shape. Another thing that the 3D part of the Radeon is used to accelerate is the rendering of anti-aliased fonts. This again is done to support per-pixel blending of the text with the background. Yet another example of where 3D acceleration is used for 2D rendering is for the gradients you see in for example window backgrounds. Those are also rendered using "3D" hardware acceleration.
I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.