1page.title=Performance tuning
2@jd:body
3
4<!--
5    Copyright 2013 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19<p>This document describes performance tuning that you can do to get the most out of your
20  hardware.</p>
21
22<h2>OpenGLRenderer (libhwui) Properties</h2>
23<p>This document lists all the properties that you can use to control
24Android’s 2D hardware accelerated rendering pipeline. Set these properties
25in the <code>device.mk</code> as <code>PRODUCT_PROPERTY_OVERRIDES</code>.
26</p>
27
28<table>
29<tr>
30  <th>Property</th>
31  <th>Type</th>
32  <th>Default Value</th>
33  <th>Description</th>
34</tr>
35
36<tr>
37  <td><code>ro.hwui.disable_scissor_opt</code></td>
38  <td><code>boolean</code></td>
39  <td><code>false</code></td>
40  <td><p>Used to enable or disable scissor optimization. The accepted values are true and false. When scissor optimization is enabled, OpenGLRenderer attempts to minimize the use of scissoring by selectively enabling and disabling the GL scissor test.</p>
41  <p>When the optimization is disabled, OpenGLRenderer keeps the GL scissor test enabled and changes the scissor rect as needed. Some GPUs (for instance, the SGX 540) perform better when changing the scissor rect more often than enabling or disabling the scissor test often.</p>
42  </td>
43</tr>
44
45<tr>
46
47  <td><code>ro.hwui.texture_cache_size</code></td>
48  <td><code>float</code></td>
49  <td><code>24</code></td>
50  <td>Defines the size, in megabytes, of the per process texture cache. We
51  recommend using a cache large enough to hold several screens worth of 32-bit textures (for instance, on a 1280x800 display, a full screen buffer uses about 4 MB so the cache should be at least 20 MB.)</td>
52</tr>
53
54<tr>
55  <td><code>ro.hwui.layer_cache_size</code></td>
56  <td><code>float</code></td>
57  <td><code>16</code></td>
58  <td>Defines the size, in megabytes, of the per process layers cache. We recommend
59  using a cache large enough to hold 4 times the screen in 32 bits. For instance,
60  on a 1280x800 display, a full screen buffer uses about 4 MB, so the cache should be at least 16 MB.</td>
61</tr>
62<tr>
63  <td><code>ro.hwui.gradient_cache_size</code></td>
64  <td><code>0.5</code></td>
65  <td><code>float</code></td>
66  <td>Defines the size, in megabytes, of the per process gradients cache. A single
67  gradient generally occupies between 1 and 4 KB of memory. It is recommended to use a
68  cache large enough to hold at least twelve gradients.</td>
69</tr>
70
71<tr>
72  <td><code>ro.hwui.patch_cache_size</code></td>
73  <td><code>integer</code></td>
74  <td><code>128</code></td>
75  <td>Defines the size, in kilobytes, of the 9-patches cache, per process. This
76cache holds only vertex data and can therefore be kept small. Each vertex is
77made of 4 floats, or 16 bytes.</td>
78</tr>
79
80<tr>
81  <td><code>ro.hwui.path_cache_size</code></td>
82  <td><code>float</code></td>
83  <td><code>4</code></td>
84  <td>Defines the size, in megabytes, of the per process paths cache. We recommended using a
85  cache large enough to hold at least one screen worth of 32-bit textures. For instance,
86  on a 1280x800 display, a full screen buffer uses about 4 MB, so the cache should be at least 4 MB.</td>
87</tr>
88
89<tr>
90  <td><code>ro.hwui.shape_cache_size</code></td>
91  <td><code>float</code></td>
92  <td><code>1</code></td>
93  <td>Defines the size, in megabytes, of the per process shapes caches. This value is used by
94  several caches such as circles and rounded rectangles. We recommend using a cache
95  large enough to hold at least one 8-bit screen. For instance, on a 1280x800 display,
96  a full screen buffer uses about 1 MB, so the cache should be at least 1 MB.</td>
97</tr>
98<tr>
99  <td><code>ro.hwui.drop_shadow_cache_size</code></td>
100  <td><code>float</code></td>
101  <td><code>2</code></td>
102  <td>Defines the size, in megabytes, of the per process text drop shadows cache. We recommend
103  using a cache large enough to hold two screens worth of 8-bit textures. For instance, on a 1280x800 display, a full screen buffer uses about 1 MB, so the cache should be at least 2 MB.</td>
104</tr>
105<tr>
106  <td><code>ro.hwui.r_buffer_cache_size</code></td>
107  <td><code>float</code></td>
108  <td><code>2</code></td>
109  <td>Defines the size, in megabytes, of the render buffers cache per process. It is recommended to use a cache large enough to hold twice the screen in 8 bits. For instance, on a 1280x800 display, a full screen buffer uses about 1 MB so the cache should be at least 2 MB. The cache can be smaller if the device supports 4 bits or 1 bit stencil buffers.</td>
110</tr>
111<tr>
112  <td><code>ro.hwui.texture_cache_flush_rate</code></td>
113  <td><code>float</code></td>
114  <td><code>0.6</code></td>
115  <td>Defines the percentage of the texture cache to keep after a memory flush. Memory flushes are triggered when the system needs to reclaim memory across all applications. We recommend releasing about 50% of the cache in such situations.</td>
116</tr>
117<tr>
118  <td><code>ro.hwui.text_small_cache_width</code></td>
119  <td><code>integer</code></td>
120  <td><code>1024</code></td>
121  <td>Defines the width in pixels of the default font cache. The upper bound depends on how fast the GPU can upload textures.
122  We recommend using at least 1024 pixels but at most 2048 pixels. You should also use a power of two value.</td>
123</tr>
124<tr>
125  <td><code>ro.hwui.text_small_cache_height</code></td>
126  <td><code>integer</code></td>
127  <td><code>256</code></td>
128  <td>Defines the height in pixels of the default font cache. The upper bound depends on how fast the GPU can upload textures.
129  We recommend using at least 256 pixels but at most 1024 pixels. </td>
130</tr>
131<tr>
132  <td><code>ro.hwui.text_large_cache_width</code></td>
133  <td><code>integer</code></td>
134  <td><code>2048</code></td>
135  <td>Defines the width in pixels of the large font cache. This cache is used for glyphs too large to fit in the default font cache. The upper bound depends on how fast the GPU can upload textures. We recommended using at least 2048 pixels but at most 4096 pixels. You should also use a power of two value.</td>
136</tr>
137
138<tr>
139  <td><code>ro.hwui.text_large_cache_height</code></td>
140  <td><code>integer</code></td>
141  <td><code>512</code></td>
142  <td>Defines the height in pixels of the large font cache. The large font cache is used for glyphs too large to fit in the default font cache. The upper bound depends on how fast the GPU can upload textures. 
143  We recommend using at least 512 pixels but at most 2048 pixels. You should also use a power of two value.</td>
144</tr>
145
146<tr>
147  <td><code>ro.zygote.disable_gl_preload</code></td>
148  <td><code>boolean</code></td>
149  <td><code>false</code></td>
150  <td>Used to enable/disable preloading of EGL/GL drivers in Zygote at boot time. When this property is 
151set to false, Zygote will preload the GL drivers by invoking eglGetDisplay(EGL_DEFAULT_DISPLAY). 
152The goal is to load the dynamic libraries code in Zygote to share it with all the other processes. If a driver
153does not support being shared, set this property to true.</td>
154</tr>
155
156<tr>
157  <td><code>hwui.text_gamma_correction</code></td>
158  <td><code>string</code></td>
159  <td><code>lookup</code></td>
160  <td>Selects the text gamma correction technique. There are four possible choices:
161  <ul>
162   <li><code>lookup3</code>: A correction based on lookup tables. Gamma correction is different for black
163  and white text (see thresholds below).</li>
164
165   <li><code>lookup</code>: A correction based on a single lookup table.</li>
166
167    <li><code>shader3</code>: A correction applied by a GLSL shader. Gamma correction is different
168    for black and white text (see thresholds below).</li>
169
170    <li><code>shader</code>: A correction applied by a GLSL shader.</li>
171  </ul>
172  Lookup gamma corrections function best on GPUs with limited shader math. Shader gamma corrections are best to save memory. We recommend using the default <code>lookup</code> technique, which offers a good compromise in terms of quality, speed, and memory usage.
173</td>
174</tr>
175
176<tr>
177  <td><code>hwui.text_gamma</code></td>
178  <td><code>float</code></td>
179  <td><code>1.4</code></td>
180  <td>Defines the gamma value used for text gamma correction.
181  This value can be adjusted based on the display that is used by the device.</td>
182</tr>
183<tr>
184  <td><code>hwui.text_gamma.black_threshold</code></td>
185  <td><code>integer</code></td>
186  <td><code>64</code></td>
187  <td>Defines the luminance threshold below which black gamma correction is applied.
188  The value must be defined in the range 0..255.</td>
189</tr>
190<tr>
191  <td><code>hwui.text_gamma.white_threshold</code></td>
192  <td><code>integer</code></td>
193  <td><code>192</code></td>
194  <td>Defines the luminance threshold above which white gamma correction is applied.
195  The value must be defined in the range 0..255.</td>
196</tr>
197<tr>
198  <td><code>hwui.use_gpu_pixel_buffers</code></td>
199  <td><code>boolean</code></td>
200  <td><code>true</code></td>
201  <td>Used to enable or disable the use of PBOs on OpenGL ES 3.0 hardware. PBOs are used by the renderer to perform asynchronous texture uploads, especially for the font cache. This property should always remain enabled but can be disabled during bringup or development if the use of PBOs causes corruptions or terrible performance. This is why the property is not read-only.</td>
202</tr>
203</table>
204