Anti-Aliasing with Adreno
Anti-aliasing techniques reduce the jagged appearance of lines and edges of shapes in 3D scenes. The workload on the GPU comes down to a kind of controlled blurriness to eliminate the jagged appearance.
Anti-aliasing is very memory- and bandwidth-intensive, consuming a lot of power. Generally, mobile GPUs with their tiling architectures aren’t designed to perform the same level of post-processing anti-aliasing that GPUs in PCs and consoles perform.
The Qualcomm® Adreno™ GPU has extensions that help with multisample anti-aliasing (MSAA), though there are limitations on the level of sampling. You can do 2x-level MSAA without incurring any significant additional cost in the rendering pipeline, but above that level it can become expensive.
The following flowchart illustrates a post-processing anti-aliasing method using MSAA:
While effective, it involves blitting render buffer A into texture B, and blitting can be costly on a mobile GPU.
The flowchart below shows a less-costly alternative to the blit:
The Adreno GPU can perform multi-sampling in GMEM, then resolve (GMEM Store) to a single-sampled texture using glFramebufferTexture2DMultisampleEXT. The number of bins will be the same as 2xMSAA in the render buffer. Filtering will occur while resolving the tile into main memory.
Using Snapdragon Profiler in Trace Capture mode, you can utilize the Rendering Stages metric. In the screenshot below, the blit appears in the bottom track:
Snapdragon Profiler shows you the anti-aliasing level as the MSAA attribute of a rendering block for the surface:
Using Snapshot mode to help identify the source of the blit, you determine that it is generated in this case by a glBlitFramebuffer call, as described in the first flowchart above.
To implement the alternative technique described in the second flowchart, you can replace the call with glFramebufferTexture2DMultisampleEXT. The blit track is now absent from the Rendering Stages view:
Thus, the blit is avoided, but the surface block properties show that the number of bins is still 30 and the level of MSAA is still 2:
Better yet, the rendering time for the surface has dropped from 10.55ms to 10.01ms, a 5-percent improvement.
NOTE: Not all blits are cause for alarm or root-cause analysis. Mipmaps are sometimes generated in the GPU during a blit stage. Blits can also be caused by updates to in-use textures.