Is 2D/3D graphics on MOS hardware accelerated?
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Andreas_Wolf
    Posts: 11575 from 2003/5/22
    From: Germany
    > I did [...] ask if [...] Ambient (and maybe other) standard desktop applications
    > make use of it for drawing windows, icons, toolbar images, window shadows

    Yes, Ambient uses conventional 2D acceleration on Radeon GPUs up to R500 series. It even uses 3D functions (Enhanced Display) for nice effects (but that's still not through OpenGL/TinyGL).

    > I don't think that Ambient [...] does make use of that besides for special tools
    > like the screen cubes and such.

    Ambient uses 3D functions if Enhanced Display is activated, but not via OpenGL/TinyGL.
  • »23.07.15 - 21:21
    Profile
  • MorphOS Developer
    bigfoot
    Posts: 381 from 2003/4/11
    Quote:

    connor wrote:
    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?


    Short answer:
    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.
  • »24.07.15 - 07:49
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    connor
    Posts: 545 from 2007/7/29
    @ Andreas Wolf: yes, I checked again the Enhanced Display checkmark and in the bubble help it says that it uses 3D. I forgot about that.

    @ bigfoot: wow, thanks for this detailed answer! When using Windows I don't have this problem of raising CPU time. The curve stays on the ground. So maybe Windows does it dirrently. Mouse is also connected through USB. Or it is because the i7 and integrated Intel graphics is much more powerful.
  • »24.07.15 - 12:33
    Profile
  • MorphOS Developer
    bigfoot
    Posts: 381 from 2003/4/11
    Quote:

    @ bigfoot: wow, thanks for this detailed answer! When using Windows I don't have this problem of raising CPU time. The curve stays on the ground. So maybe Windows does it dirrently. Mouse is also connected through USB. Or it is because the i7 and integrated Intel graphics is much more powerful.


    I can only speculate since I don't know enough about how UI rendering works on Windows, and I believe that it very much depends on exactly which version of Windows you're using.

    So to speculate, I'd say that current versions of Windows keep window contents completely cached in video memory. This gives the advantage of not having to ask applications to rerender (parts of) their UI when moving windows around. On the other hand it has the disadvantage of consuming a lot more video memory. This is a trade-off that has started making sense with graphics cards getting 128MB and more of video memory.

    MorphOS can also keep window contents cached. However, this trade-off makes a bit less sense on a Mac Mini with 32 or 64MB of video memory, and you very easily run out of video memory in that case, which makes the performance really poor.
    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.
  • »24.07.15 - 13:13
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    Or Windows is hiding the CPU time spent in the OS itself (kernel or whatever)
  • »24.07.15 - 19:10
    Profile Visit Website
  • ASiegel
    Posts: 1331 from 2003/2/15
    From: Central Europe
    Quote:

    Henes wrote:
    Or Windows is hiding the CPU time spent in the OS itself (kernel or whatever)


    Windows 7 does not appear to do so at least. The results are very application-dependent, however. Moving around a Firefox or Chrome window will use between 5 and 9 percent of CPU time on this quad-core i7 machine with a dedicated AMD GPU. If I use certain Adobe apps, the number goes up as high as 20 percent (so 80% on a single i7 core). If I merely move around a Windows Explorer window, the percentage hovers at between 5 and 6 percent (which, again, is about 20+ percent on a single i7 core that is substantially faster than a G4 as found in a Mac Mini).
  • »24.07.15 - 19:22
    Profile
  • Jim
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Jim
    Posts: 4957 from 2009/1/28
    From: Delaware, USA
    Great stuff Mark, thanks for the continuing education.
    I was not aware of the lack of 2D acceleration above the R500.
    BTW - Thanks for the driver for that series, its a real gem.
    "Never attribute to malice what can more readily explained by incompetence"
  • »08.08.15 - 00:03
    Profile
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Andreas_Wolf
    Posts: 11575 from 2003/5/22
    From: Germany
    > I was not aware of the lack of 2D acceleration above the R500.

    vox told you about it on MorphOS 3.8 release day :-)

    https://morph.zone/modules/newbb_plus/viewtopic.php?forum=3&topic_id=11169&start=23
  • »08.08.15 - 14:14
    Profile
  • Jim
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Jim
    Posts: 4957 from 2009/1/28
    From: Delaware, USA
    Andreas, how your indexing skills beat my memory is beyond me.
    Good one.
    In any case, I am willing to accept the X1950XT as the best card we have for 2D and 3D.
    "Never attribute to malice what can more readily explained by incompetence"
  • »08.08.15 - 17:38
    Profile