【QT】Qt for Embedded Linux Hardware Accelerated Graphics

1、硬件加速

在嵌入式设备上设计应用程序时,通常要在图形特效与性能之间作出选择,不过在大多数设备上由于硬件特性,以及越来越多的设备上硬件能够很好地支持图形操作,可能不必担心这个问题。使用图形加速,不仅可以使用动态图形特效,还有其它两方面好处。一方面,图形硬件加速比CPU的电源使用率更高,当完成同样的事情时,CPU所需的时钟频率可能是GPU的20倍,例如,一个典型的硬件加速的手机图形单元可以在一个时钟周期内光栅化一个或两个双线性纹理插值,而一个软件实现很容易超过二十个时钟周期。与桌面版GPU相比,典型的SoC(System on Chip)图形硬件具有更低的时钟频率和内存带宽,以及不同的加速级别,比如说许多GPU在图形管线中忽略了变换和光照,只是实现了光栅化。另一方面,使用GPU可以减轻CPU的负荷,以便节能或者高并发地执行其它操作,GPU的描画速度可能并没有比CPU快多少,但是CPU减负后可以执行其它任务,创建更加敏捷的交互体验。写出好程序的关键在于限制目标硬件不能处理的因素,以及使用专用的图形硬件,Qt提供了几种方法使用硬件加速图形,可以同时在屏幕上渲染高级特效和加速程序运行。

2、嵌入式图形管线

这里写图片描述

Qt使用QPainter进行所有的图形操作,API接口一致,不必关心具体的平台,因此可以在不同的设备上重用代码。QPainter使用了不同实现的描画引擎(QPaintEngine)进行实际的描画,QPaintEngine为每个窗口系统提供了不同的描画引擎,以及Qt支持的描画框架,对于嵌入式设备中的Qt,还提供了OpenGL ES 1.1/2.0、OpenVG和DirectFB的实现。使用这些描画引擎时,可以提高Qt程序的图形性能,然后,使用的图形操作不被支持时,将严重影响程序性能,这些都依赖于目标设备的硬件配置所支持的图形操作。Qt描画引擎把设备硬件支持的图形操作发送给GPU,然后再到Framebuffer,不支持的图形操作将交给QRasterPaintEngine,由CPU处理,最后还是到Framebuffer,结束时,操作系统发送描画更新通知到屏幕,不过对于不支持的图形操作来说,虽可以交给CPU,但在内存消耗方面是非常昂贵的,应该避免。

3、硬件配置

在使用硬件加速部署程序前,最好先了解一下目标设备支持的硬件加速的图形操作。设备不支持硬件加速时,Qt将使用QRasterPaintEngine通过软件处理加速。设备支持OpenGL ES、OpenVG、DirectFB时,Qt将使用各自的描画引擎加速描画。然而,硬件配置只支持有限的图形加速特性,对于不支持的操作需要使用光栅引擎反而可能会降低程序的图形性能。设备中,不同的硬件架构有着不同的硬件加速技巧,嵌入式设备中主要有两种不同的架构,一种是UMA(Unified Memory Architecturededicated),另一种是图形专用架构,图形专用架构主要用于高端设备,而低端设备使用UMA,有时候还会预留一块内存区域。根据硬件支持的不同的图形操作,可以将设备分为五类,这五类设备以及不同架构下的描画引擎如下图所示。

这里写图片描述

4、窗口

Qt for Embedded Linux包括Qt自己的窗口系统QWS,QWS设计于1999年,在图形加速之前已可适用于嵌入式设备,提供了一个轻量级的窗口管理者,实现了所有的窗口功能,如移动、缩放、最小化等。QWS与CPU一起工作是有挑战的,特别是针对OpenGL和OpenVG,因为在Linux上并没有标准的方法在CPU间共享纹理,虽然某些芯片供应商提供了私有的API允许纹理共享,但还是有诸多限制,对于图形加速的最简单的支持便是全屏的单进程单窗口。下图是Qt(Qt4)支持的硬件加速API及其版本。

这里写图片描述

【参考】http://doc.qt.io/qt-4.8/qt-embeddedlinux-accel.html
【参考】http://doc.qt.io/qt-4.8/qt-embedded-accel.html
【参考】http://doc.qt.io/qt-4.8/qt-qws-svgalib-example.html

Linux Driver Development for Embedded Processors – Second Edition 版本: Learn to develop Linux embedded drivers with kernel 4.9 LTS The flexibility of Linux embedded, the availability of powerful, energy efficient processors designed for embedded computing and the low cost of new processors are encouraging many industrial companies to come up with new developments based on embedded processors. Current engineers have in their hands powerful tools for developing applications previously unimagined, but they need to understand the countless features that Linux offers today. This book will teach you how to develop device drivers for Device Tree Linux embedded systems. You will learn how to write different types of Linux drivers, as well as the appropriate APIs (Application Program Interfaces) and methods to interface with kernel and user spaces. This is a book is meant to be practical, but also provides an important theoretical base. More than twenty drivers are written and ported to three different processors. You can choose between NXP i.MX7D, Microchip SAMA5D2 and Broadcom BCM2837 processors to develop and test the drivers, whose implementation is described in detail in the practical lab sections of the book. Before you start reading, I encourage you to acquire any of these processor boards whenever you have access to some GPIOs, and at least one SPI and I2C controllers. One of the boards used to implement the drivers is the famous Raspberry PI 3 Model B board. You will learn how to develop drivers, from the simplest ones that do not interact with any external hardware, to drivers that manage different kind of devices: accelerometers, DACs, ADCs, RGB LEDs, Multi-Display LED controllers, I/O expanders, and Buttons. You will also develop DMA drivers, drivers that manage interrupts, and drivers that write/read on the internal registers of the processor to control external devices. To easy the development of some of these drivers, you will use different types of Frameworks: Miscellaneous framework, LED framework, UIO framework, Input framework and the IIO industrial one. This second edition has been updated to the v4.9 LTS kernel.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值