NXP Semiconductors Document Number: IMXGRAPHICUG
Rev. 0, 02/2018
i.MX Graphics User’s Guide
i.MX Graphics User’s Guide, Rev. 0, 02/2018
2 NXP Semiconductors
Contents
Chapter 1 Introduction ............................................................................................................................................. 6
Chapter 2 i.MX G2D API ............................................................................................................................................ 6
2.1 Overview ...................................................................................................................................................... 6
2.2 Enumerations and structures ....................................................................................................................... 6
2.3 G2D function descriptions .......................................................................................................................... 10
2.4 Support of new operating system in G2D .................................................................................................. 16
2.5 Sample code for G2D API usage ................................................................................................................. 16
2.6 Feature list on multiple platforms.............................................................................................................. 19
Chapter 3 i.MX EGL and OGL Extension Support .................................................................................................... 20
3.1 Introduction ............................................................................................................................................... 20
3.2 EGL extension support ............................................................................................................................... 20
3.3 OpenGL ES extension support .................................................................................................................... 23
3.4 Extension GL_VIV_direct_texture .............................................................................................................. 29
3.5 Extension GL_VIV_texture_border_clamp ................................................................................................. 32
Chapter 4 i.MX Framebuffer API ............................................................................................................................ 35
4.1 Overview .................................................................................................................................................... 35
4.2 API data types and environment variables ................................................................................................ 35
4.3 API description and syntax ......................................................................................................................... 37
Chapter 5 OpenCL ................................................................................................................................................... 44
5.1 Overview .................................................................................................................................................... 44
5.2 Vivante OpenCL implementation ............................................................................................................... 51
5.3 Optimization for OpenCL embedded profile .............................................................................................. 53
5.4 OpenCL Debug messages ........................................................................................................................... 56
Chapter 6 OpenVX Introduction ............................................................................................................................. 57
6.1 Overview .................................................................................................................................................... 57
6.2 Designing framework of OpenVX ............................................................................................................... 57
6.3 OpenVX extension implementation ........................................................................................................... 59
6.4 OpenCL functions compatible with Vivante vision..................................................................................... 62
Chapter 7 Vulkan .................................................................................................................................................... 65
7.1 OverView .................................................................................................................................................... 65
7.2 Vivante Extension Support for Vulkan ....................................................................................................... 65
Chapter 8 Multiple GPUs and Virtualization........................................................................................................... 67
8.1 Overview .................................................................................................................................................... 67
8.2 Multi-GPU configurations .......................................................................................................................... 67
8.3 GPU affinity configuration .......................................................................................................................... 67
i.MX Graphics User’s Guide, Rev. 0, 02/2018
3 NXP Semiconductors
8.4 OpenCL on multi-GPU device ..................................................................................................................... 67
8.5 GPU virtualization configuration ................................................................................................................ 68
Chapter 9 G2D compositor on Weston .................................................................................................................. 69
9.1 Overview .................................................................................................................................................... 69
9.2 Enabe G2D compositor .............................................................................................................................. 69
Chapter 10 XServer Video Driver ......................................................................................................................... 70
10.1 EXA driver ................................................................................................................................................... 70
10.2 XRandR ....................................................................................................................................................... 71
Chapter 11 Advanced GPU Configuration ............................................................................................................ 82
11.1 GPU Scaling Governor ................................................................................................................................ 82
11.2 GPU Device Cooling .................................................................................................................................... 82
Chapter 12 Vivante Software Tool Kit .................................................................................................................. 82
12.1 Vivante Tool Kit overview .......................................................................................................................... 82
12.2 vEmulator ................................................................................................................................................... 84
12.3 vShader ...................................................................................................................................................... 95
12.4 vCompiler ................................................................................................................................................. 103
12.5 vTexture ................................................................................................................................................... 107
12.6 vProfiler and vAnalyzer ............................................................................................................................ 111
12.7 Debug and performance counters ........................................................................................................... 125
Chapter 13 GPU Tools ........................................................................................................................................ 127
13.1 gpuinfo tool .............................................................................................................................................. 127
13.2 gmem_info tool ........................................................................................................................................ 129
13.3 Apitrace user guide .................................................................................................................................. 130
Chapter 14 GPU Memory Introduction .............................................................................................................. 135
14.1 GPU memory overview ............................................................................................................................ 135
14.2 GPU memory pools .................................................................................................................................. 135
14.3 GPU memory allocators ........................................................................................................................... 135
14.4 GPU reserved memory ............................................................................................................................. 136
14.5 GPU memory base address ...................................................................................................................... 136
Chapter 15 Application Programming Recommendations ................................................................................. 138
15.1 Understand the system configuration and target application ................................................................. 138
15.2 Optimize off chip data transfer such as accessing off-chip DDR memory/mobile DDR memory ............ 138
15.3 Avoid W-Clipping issue in the Application Program ................................................................................. 138
15.4 Avoid GPU hang and data corruption when use occlusion query ............................................................ 139
15.5 Avoid random cache or memory accesses ............................................................................................... 139
15.6 Optimize your use of system memory ..................................................................................................... 139
i.MX Graphics User’s Guide, Rev. 0, 02/2018
4 NXP Semiconductors
15.7 Target a fixed frame rate that is visibly smooth....................................................................................... 139
15.8 Minimize GL state changes ...................................................................................................................... 140
15.9 Batch primitives to minimize the number of draw calls .......................................................................... 140
15.10 Perform calculations per vertex instead of per fragment/pixel .......................................................... 140
15.11 Enable early-Z, hierarchical-Z and back face culling ............................................................................ 140
15.12 Use branching carefully ....................................................................................................................... 141
15.13 Do not use static or stack data as vertex data - use VBOs instead ...................................................... 141
15.14 Use dynamic VBO if data is changing frame by frame ......................................................................... 141
15.15 Tessellate your data so that Hierarchical Z (HZ) can do its job ............................................................ 142
15.16 Use dynamic textures as a texture cache (texture atlas) ..................................................................... 142
15.17 If you use many small triangle strips, stitch them together ................................................................ 142
15.18 Specify EGL configuration attributes precisely .................................................................................... 142
15.19 Use aligned texture/render buffers ..................................................................................................... 142
15.20 Disable MSAA rendering unless high quality is needed ....................................................................... 143
15.21 Avoid partial clears .............................................................................................................................. 143
15.22 Avoid mask operations ........................................................................................................................ 143
15.23 Use MIPMAP textures .......................................................................................................................... 143
15.24 Use compressed textures if constricted by RAM/ROM budget ........................................................... 143
15.25 Draw objects from near to far if possible ............................................................................................ 143
15.26 Avoid indexed triangle strips. .............................................................................................................. 143
15.27 Vertex attribute stride should not be larger than 256 bytes ............................................................... 144
15.28 Avoid binding buffers to mixed index/vertex array ............................................................................. 144
15.29 Avoid using CPU to update texture/buffer contexts during render .................................................... 144
15.30 Avoid frequent context switching ........................................................................................................ 144
15.31 Optimize resources within a shader .................................................................................................... 144
15.32 Avoid using glScissor Clear for small regions ....................................................................................... 144
15.33 Use PRE to accelerate data transfer .................................................................................................... 144
15.34 i.MX 8QuadMax dual-GPU performance ............................................................................................. 145
Chapter 16 Demo Framework ............................................................................................................................ 146
16.1 Summaries................................................................................................................................................ 146
16.2 Introduction ............................................................................................................................................. 146
16.3 Design overview ....................................................................................................................................... 147
16.4 High level overview .................................................................................................................................. 147
16.5 Demo application details ......................................................................................................................... 148
16.6 Helper Class Overview .............................................................................................................................. 152
16.7 Android SDK+NDK on Windows OS build guide ....................................................................................... 157
i.MX Graphics User’s Guide, Rev. 0, 02/2018
5 NXP Semiconductors
16.8 Ubuntu build guide .................................................................................................................................. 158
16.9 Windows OS build guide .......................................................................................................................... 160
16.10 Yocto build guide ................................................................................................................................. 162
16.11 FslContentSync.py notes ...................................................................................................................... 166
16.12 Roadmap – Upcoming features ........................................................................................................... 166
16.13 Known limitations ................................................................................................................................ 167
Chapter 17 Environment Variables Summary .................................................................................................... 168
17.1 Environment variable for drivers and HAL ............................................................................................... 168
17.2 Environment variable for compiler .......................................................................................................... 169