Mali GPU Best Practices

Recommendations for efficient API usage

Download PDF

The Mali GPU Best Pratices is a guide designed as a quick-reference for development on Mali GPUs. It assumes that the reader is familiar with using the underlying APIs. This guide is also the main reference for the Vulkan best practices for mobile developers on GitHub. 

Warning

These recommendations aim to provide the best practices for Mali GPUs, however real-world applications can be complicated and there are always exceptions to this generalized advice. We highly recommend making measurements of any applied optimizations to check they are performing as intended on your target device(s).

Guide structure

Graphics processing can be represented as a pipeline of processing stages that includes the application, the graphics driver, and the various hardware stages inside the GPU itself. Most stages follow a strict architectural pipeline, with outputs from one stage becoming the inputs into the next. Compute shaders are the one exception to this strict pipeline, as they simply write results back to resources stored in system memory, and therefore their outputs can be consumed by any stage in the pipeline which can consume those resources.

This guide is structured with topic ordering following this pipeline. Each topic provides recommendations which should be applied to processing running in that that pipeline stage. There are some generic topics such as shader program authoring advice which can apply to multiple pipeline stages; we've split these out into dedicated sections at the end of the document.

For each best practice topic we provide an explanation of the recommendation, and actionable do and don't technical points which should be considered during development. Where possible we also document the likely impact of not following the advice, and possible debugging techniques which could be applied.

Info

We provide relatively terse advice in this document for sake of brevity; for example, "Don't use discard in fragment shaders". There are inevitably cases where you will need to use a feature which we do not recommend using, some algorithms simply require it. Don't feel constrained by our advice to never use a feature, but in these cases at least start your algorithm design with the awareness that there might be an underlying performance implication for that algorithm that you should keep an eye on.

Best practices Contents 

  • Introduction
  • Article structure
  • Application logic
    • Draw call batching
    • Draw call culling
    • Draw call render order
    • Avoid depth prepasses
    • OpenGL ES GPU pipelining
    • Vulkan GPU pipelining
    • Vulkan pipeline synchronization
    • Pipelined resource updates
  • CPU overheads
    • Shader compilation
    • Pipeline creation
    • Allocating memory
    • OpenGL ES CPU memory mapping
    • Vulkan CPU memory mapping
    • Command buffers
    • Descriptor sets and layouts
  • Vertex shading
    • Index draw calls
    • Index buffer encoding
    • Attribute precision
    • Attribute layout
    • Varying precision
    • Triangle density
    • Instanced vertex buffers
  • Tessellation
  • Geometry shading
  • Tiling
    • Effective triangulation
  • Fragment shading
    • Efficient render passes
    • Multisampling
    • Multipass rendering
    • HDR rendering
    • Stencil updates
    • Blending
    • Transaction elimination
  • Buffers
    • Robust buffer access
  • Textures
    • Sampling performance
    • Anisotropic sampling performance
    • Texture and sampler descriptors
    • sRGB textures
    • AFBC textures
  • Compute
    • Workgroup sizes
    • Shared memory
    • Image processing
  • Shader code
    • Minimize precision
    • Vectorize code
    • Vectorize memory access
    • Manual optimization
    • Instruction caches
    • Uniforms
    • Uniform sub-expressions
    • Uniform control-flow
    • Branches
    • Discards
    • Atomics
  • System integration
    • EGL buffer preservation
    • Android blob cache size
    • Swapchain surface count
    • Semaphores in WSI
    • Window buffer alignment

Download PDF