LeMaker Guitar:GPU硬件加速

From BananaPro/Pi
Revision as of 17:01, 23 March 2016 by Super (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Other languages:
English • ‎中文(简体)‎

介绍

PowerVR是Imagination Technologies公司(原VideoLogic)的开发硬件和软件的2D和3D渲染和视频编码,解码,相关的图像处理和OpenGL ES,OpenCL加速的一个部门。

PowerVR SGX544MP GPU提供最好的游戏体验和全高清显示屏,支持行业标准API-OpenGL-ES1.1和2.0。
纹理支持:

  • 立方体映射
  • 投影纹理
  • 非平方纹理
  • 体积纹理
  • 结构数组

纹理格式:

  • RGB 8888, 565, 1555,1565
  • 单色 8, 16, 16f, 32f,32int
  • 双通道 8:8, 16:16, 16f:16f
  • 压缩纹理 PVR-TC1, PVR-TC2, ETC1
  • 可支持对所有YUV格式编程

分辨率支持:

  • 帧缓冲最大值 = 4096*4096
  • 纹理最大值 = 4096*4096
  • 最大体积 = 2048
  • 纹理坐标范围 = 8192


在LeMaker Guitar上安装硬件加速库

第一步: 下载并解压文档

wget http://mirror.lemaker.org/GPU_For_LeMaker_Guitar_201603.tar.gz
sudo tar -xvf GPU_For_LeMaker_Guitar_201603.tar.gz

GPU_For_LeMaker_Guitar_201511 下载.

第二步: 安装软件包

cd GPU_For_LeMaker_Guitar_201603
sudo chown -R root:root ./*
sudo ./install.sh

第三步: 替换 X, Xorg

cd /usr/bin
sudo mv X X.original
sudo mv Xorg Xorg.original
sudo ln -sf /usr/local/XSGX/bin/X X
sudo ln -sf /usr/local/XSGX/bin/Xorg Xorg
sudo cp /usr/local/XSGX/etc/xorg.conf  /etc/

第四步: 检查依赖模块

sudo depmod

第五步:加载库路径

sudo vi /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
/usr/local/XSGX/lib
/usr/lib
 
sudo ldconfig

第六步: 检查GPU是否开启

lsmod
Module                  Size  Used by
...
pvrsrvkm              336156  6 
drm                   225379  6 pvrsrvkm
...

确保已经加载了驱动pvrsrvkm和drm,而且其Used by选项的值不为0。另外,图形用户界面运行正常,则可以说明硬件加速已经正常开启了。

测试OpenGL ES

第一步: 安装一些必要的库

sudo apt-get install libgegl-0.2-0 libgfortran3 libgimp2.0 libgl1-mesa-dev libgles2-mesa-dev libglew-dev libglew1.10 libglib2.0-bin libglib2.0-data libglib2.0-dev libglu1-mesa-dev 
sudo apt-get install libpng-dev
sudo apt-get install libx11-dev
sudo apt-get install pkg-config
sudo apt-get install libjpeg-dev

第二步: 编译并安装 glmark2

sudo git clone https://github.com/LeMaker/glmark2.git
cd glmark2
sudo ./waf configure --with-flavors=x11-gl,x11-glesv2
sudo ./waf
sudo ./waf install

第三步: 替换一些库文件

sudo cp /usr/lib/libEGL.so* /usr/lib/arm-linux-gnueabihf/ -a
sudo cp /usr/lib/libGLES*  /usr/lib/arm-linux-gnueabihf/ -a

第四步:在Lemuntu系统命令行终端运行glmark2-es2

glmark2-es2

Glmark.png


测试OpenCL

第一步:安装OpenGL_test。

sudo apt-get install unzip
wget http://mirror.lemaker.org/OpenCL_test.zip
unzip OpenCL_test.zip

第二步: 运行ocl_filter_test。

cd OpenCL_test/
cp *.so /usr/lib/ 
chmod 755 *_test
./ocl_filter_test
OpenCL Filter Test(s) (SGX_DDK_Linux_XOrg sgxddk MAIN@3625561,release,omap_linux) at Tue Dec  8 10:16:31 2015
(00) *************************************************************************************
Runs a 1x1 copyimage filter on an image using texture samples
******************************************************************************************
copy1x1 --> passed
copy1x1: Test took 0.21 seconds (Compute: 0.01 seconds) to run 1 iterations:
copy1x1: Filter dims(1,1)       Image dims(512,512) size(1.00MB)        Pixelreads(0.26 million)
copy1x1: F/s(76.92)     s/F(0.01)       MB/s(76.92)     s/MB(0.01)      Pixelreads/s(20.09 million)
(01) *************************************************************************************
Runs a 3x3 copyimage filter on an image using texture samples
******************************************************************************************
copy3x3 --> passed
copy3x3: Test took 0.22 seconds (Compute: 0.01 seconds) to run 1 iterations:
copy3x3: Filter dims(3,3)       Image dims(512,512) size(1.00MB)        Pixelreads(2.33 million)
copy3x3: F/s(90.91)     s/F(0.01)       MB/s(90.91)     s/MB(0.01)      Pixelreads/s(211.98 million)
(02) *************************************************************************************
Runs a 5x5 copyimage filter on an image using memory reads
******************************************************************************************
...

第三步:运行ocl_unit_test。

./ocl_unit_test
OpenCL Unit Test(s) (SGX_DDK_Linux_XOrg sgxddk MAIN@3625561,release,omap_linux) at Tue Dec  8 10:20:02 2015
00******************************************************************************
Platform Test:
        Checks that an OpenCL compatible platform is present
        for the unit test to run.
********************************************************************************
Verify_Platform: Enumerating 1 platforms
Verify_Platform: CL_PLATFORM_PROFILE    EMBEDDED_PROFILE
Verify_Platform: CL_PLATFORM_VERSION    OpenCL 1.1 
Verify_Platform: CL_PLATFORM_NAME       PowerVR SGX
Verify_Platform: CL_PLATFORM_VENDOR     Imagination Technologies
Verify_Platform: CL_PLATFORM_EXTENSIONS 'cl_khr_byte_addressable_store'
platform --> passed
platform: Test took 0.03 seconds to run:
platform: Verify 0.03s (100.00)%
01******************************************************************************
Device Test:
        Checks that an OpenCL compatible device is present
        for the unit test to run.
********************************************************************************
Verify_Device: Enumerating 1 devices
Verify_Device: CL_DEVICE_TYPE       CL_DEVICE_TYPE_GPU
Verify_Device: CL_DEVICE_NAME       PowerVR SGX 544
Verify_Device: CL_DEVICE_VENDORI    Imagination Technologies
Verify_Device: CL_DRIVER_VERSION    1.1
Verify_Device: CL_DEVICE_PROFILE    EMBEDDED_PROFILE
Verify_Device: CL_DEVICE_VERSION    OpenCL 1.1 
Verify_Device: CL_DEVICE_EXTENSIONS cl_khr_byte_addressable_store cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics
device --> passed
device: Test took 0.00 seconds to run:
device: Verify 0.00s (100.00)%
02******************************************************************************
Addition Kernel:
        Performs an online compilation of an integer addition kernel
        and verifies that the output buffer is correct.
********************************************************************************
Compute_Add: Online compilation test with 4096 instances running source:
<source>
__kernel void AdditionKernel(__global int* a, __global int* b)
{
        int ith = get_global_id(0);
        a[ith] = a[ith] + b[ith];
}
...


另请参阅

1、https://en.wikipedia.org/wiki/PowerVR#Series_5_.28SGX.29
2、http://community.imgtec.com/developers/powervr/