Debian Codegraph @

lvgl/docs/src/integration/chip_vendors/nxp/vg_lite_gpu.rst

raw
1 .. _vg_lite:
2
3 ===================
4 VG-Lite General GPU
5 ===================
6
7 This is a generic VG-Lite rendering backend implementation that is designed to utilize
8 `VeriSilicon <https://verisilicon.com/>`_'s generic API to operate GPU hardware as much as possible.
9
10 Even with different chip manufacturers, as long as they use the same version of VG-Lite API as the rendering backend,
11 LVGL rendering acceleration can be supported without the need for LVGL adaptation work.
12
13
14 Configuration
15 *************
16
17 1. Set :c:macro:`LV_USE_DRAW_VG_LITE` to 1 in ``lv_conf.h`` to enabled the VG-Lite rendering backend.
18 Make sure that your hardware has been adapted to the VG-Lite API and that the absolute path to ``vg_lite.h``, which can be directly referenced by lvgl, has been exposed.
19
20 2. Confirm the GPU initialization method, there are two ways:
21
22 - The SDK calls the GPU initialization function on its own during system startup, and the GPU is available when LVGL starts; set :c:macro:`LV_VG_LITE_USE_GPU_INIT` to 0.
23 - LVGL actively calls the GPU initialization function, and the SDK needs to implement the public function `gpu_init()`.
24 LVGL will call it to complete the GPU hardware initialization during startup; set :c:macro:`LV_VG_LITE_USE_GPU_INIT` to 1.
25
26 3. Set the :c:macro:`LV_VG_LITE_USE_ASSERT` configuration to enable GPU call parameter checking.
27 Due to the complexity of the parameters used in GPU calls, incorrect parameters can result in abnormal GPU hardware operation, such as forgetting to add an end symbol
28 to the path or not meeting the alignment requirements for buffer stride.
29 To quickly resolve such issues, strict parameter checking has been added before each VG-Lite call, including buffer stride validation and matrix invertibility check.
30 When an error parameter is detected, an assertion will occur to print out the error parameter, allowing the user to promptly make corrections and reduce the time wasted on hardware simulation.
31 Please note that enabling this check will decrease runtime performance. It is recommended to enable it in Debug mode and disable it in the Release version.
32
33 4. Set the :c:macro:`LV_VG_LITE_FLUSH_MAX_COUNT` configuration to specify the flush method.
34 VG-Lite uses two sets of command buffer buffers to render instructions, and utilizing this mechanism well can greatly improve drawing efficiency.
35 Currently, two buffering methods are supported:
36
37 - Set :c:macro:`LV_VG_LITE_FLUSH_MAX_COUNT` to zero (recommended). The rendering backend will obtain the GPU's working status every time it writes rendering instructions to the command buffer.
38
39 When the GPU is idle, it will immediately call ``vg_lite_flush`` to notify the GPU to start rendering and swap the command buffer. When the GPU is busy, it will continue to fill the command buffer cache with rendering instructions.
40 The underlying driver will automatically determine if the command buffer has been filled. When it is about to be filled, it will forcibly wait for the unfinished drawing tasks to end and swap the command buffer.
41 This method can effectively improve GPU utilization, especially in scenarios where rendering text, as the GPU's drawing time and the CPU's data preparation time are very close, allowing the CPU and GPU to run in parallel.
42
43 - Set :c:macro:`LV_VG_LITE_FLUSH_MAX_COUNT` to a value greater than zero, such as 8. After writing 8 rendering instructions to the command buffer, the rendering backend
44 will call ``vg_lite_flush`` to notify the GPU to start rendering and swap the command buffer.
45
46 5. Set the :c:macro:`LV_VG_LITE_USE_BOX_SHADOW` configuration to use GPU rendering for shadows.
47 In fact, GPU hardware does not actually support shadow rendering. However, through experimentation, it has been found that a similar shadow effect
48 can be achieved by using multiple layers of borders with different levels of transparency.
49 It is recommended to enable this configuration in scenarios where the shadow quality requirements are not high, as it can significantly improve rendering efficiency.
50
51 6. Set the :c:macro:`LV_VG_LITE_GRAD_CACHE_CNT` configuration to specify the number of gradient cache entries.
52 Gradient drawing includes linear gradients and radial gradients. Using a cache can effectively reduce the number of times the gradient image is created and improve drawing efficiency.
53 Each individual gradient consumes around 4K of GPU memory pool. If there are many gradients used in the interface, you can try increasing the number of gradient cache entries.
54 If the VG-Lite API returns the :c:macro:`VG_LITE_OUT_OF_RESOURCES` error, you can try increasing the size of the GPU memory pool or reducing the number of gradient cache entries.
55
56 7. Set the :c:macro:`LV_VG_LITE_STROKE_CACHE_CNT` configuration to specify the number of stroke path caches.
57 When the stroke parameters do not change, the previously generated stroke parameters are automatically retrieved from the cache to improve rendering performance.
58 The memory occupied by the stroke is strongly related to the path length. If the VG-Lite API returns the :c:macro:`VG_LITE_OUT_OF_RESOURCES` error,
59 you can try increasing the size of the GPU memory pool or reducing the number of stroke cache entries.
60
61 NOTE: VG-Lite rendering backend does not support multi-threaded calls, please make sure :c:macro:`LV_USE_OS` is always configured as :c:macro:`LV_OS_NONE`.
62
63
64 VG-Lite Simulator
65 *****************
66
67 LVGL integrates a VG-Lite simulator based on ThorVG.
68 Its purpose is to simplify the debugging of VG-Lite adaptation and reduce the time of debugging and locating problems on hardware devices.
69 For detailed instructions, see :ref:`vg_lite_tvg`.
70
71
72 Image Decoder Color Format Conversion
73 *************************************
74
75 The VG-Lite image decoder automatically converts certain color formats that are not natively
76 supported by the GPU hardware into compatible formats. This conversion happens transparently
77 during the image decoding process.
78
79 The following table shows the color format mapping:
80
81 .. list-table::
82 :widths: 30 30 40
83 :header-rows: 1
84
85 * - Source Format
86 - Target Format
87 - Description
88 * - ``LV_COLOR_FORMAT_I1``
89 - ``LV_COLOR_FORMAT_I8``
90 - VG-Lite index formats require endian + bit flipping, converted to I8 for simplicity
91 * - ``LV_COLOR_FORMAT_I2``
92 - ``LV_COLOR_FORMAT_I8``
93 - Same as above
94 * - ``LV_COLOR_FORMAT_I4``
95 - ``LV_COLOR_FORMAT_I8``
96 - Same as above
97 * - ``LV_COLOR_FORMAT_A1``
98 - ``LV_COLOR_FORMAT_A8``
99 - Alpha format expanded to 8-bit
100 * - ``LV_COLOR_FORMAT_A2``
101 - ``LV_COLOR_FORMAT_A8``
102 - Alpha format expanded to 8-bit
103 * - ``LV_COLOR_FORMAT_RGB888``
104 - ``LV_COLOR_FORMAT_XRGB8888``
105 - Converted when GPU doesn't support 24-bit format
106 * - ``LV_COLOR_FORMAT_ARGB8565``
107 - ``LV_COLOR_FORMAT_ARGB8888``
108 - Converted when GPU doesn't support 24-bit format
109 * - ``LV_COLOR_FORMAT_RGB565A8``
110 - ``LV_COLOR_FORMAT_ARGB8888``
111 - Separate RGB + Alpha planes merged into ARGB8888
112 * - ``LV_COLOR_FORMAT_AL88``
113 - ``LV_COLOR_FORMAT_ARGB8888``
114 - Alpha + Luminance converted to ARGB8888
115 * - ``LV_COLOR_FORMAT_RGB565_SWAPPED``
116 - ``LV_COLOR_FORMAT_RGB565``
117 - Byte order swapped
118
119 **Notes:**
120
121 - Formats not listed above will return ``LV_COLOR_FORMAT_UNKNOWN`` and be passed to other decoders in the chain.
122 - The 24-bit format conversion (``RGB888``, ``ARGB8565``) depends on GPU capability, queried via ``vg_lite_query_feature(gcFEATURE_BIT_VG_24BIT)``.
123 If the GPU supports 24-bit formats, the decoder will skip these formats and let the default binary decoder handle them.
124 - Index formats (``I1``, ``I2``, ``I4``) maintain their palette but expand index values to 8-bit for GPU compatibility.
125 - Alpha formats (``A1``, ``A2``) are linearly scaled to 8-bit (e.g., A1: 0→0, 1→255; A2: 0→0, 1→85, 2→170, 3→255).
126 - **Compressed formats are not supported.** Images with ``LV_IMAGE_FLAGS_COMPRESSED`` flag will be rejected by this decoder
127 and passed to other decoders that support decompression.
128
129
130 API
131 ***
132
133 .. API startswith: lv_draw_vglite_
134
135 .. API equals: vglite_set_buf
136
137 .. API equals: vglite_set_translation_matrix
138
139 .. API equals: vglite_create_rect_path_data
140
141 .. API equals: vglite_get_color