Home > Software engineering >  How to reduce MSAA memory usage?
How to reduce MSAA memory usage?

Time:10-27

Here is working on rendering with OpenGL ES on iOS. To get a better image quality, we adopt MSAA, ie. Multisample anti-aliasing, which use 4 times larger FBO.

For example, with 1080P resolution, a single render target texture use 1080 * 1920 * 4 * 4 = 33 MB.

Is there some methods to reduce this?

CodePudding user response:

Here are some options.

Reduce the number of samples of MSAA: you could use for example only two samples.

Use other anti-aliasing / multisampling techniques.

I found this overview of some different techgniques: https://www.geeksforgeeks.org/types-of-antialiasing-techniques/

CodePudding user response:

There is no way to avoid that allocation when rendering with OpenGL. If you have the option of using Metal, you can use a Memoryless Render Target, assuming all you needed to do was resolve the msaa buffer immediately after rendering.

CodePudding user response:

For example, with 1080P resolution, a single render target texture use 1080 * 1920 * 4 * 4 = 33 MB.

Are you sure about that? On a desktop GPU I'd say you'd be correct, but iOS GPUs are Tile Based Deferred Renderers. Memory bandwidth use is very power hungry, so different approaches are used on mobile GPUs to save the bandwidth. Tile based renderers split up the fragment shading of the screen into e.g. 32x32 tiles so that they're not constantly reading and writing the frame buffer.

Such an architecture allows MSAA to be implemented very efficiently. The extra samples don't need to exist as allocated memory, they can just exist temporarily in the tile memory, and the image gets resolved while still in tile memory, so only the resolved pixels need to be written to the frame buffer. The MSAA buffer doesn't need to exist.

E.g. See this quote from PowerVR (iOS GPUs were originally based on PowerVR, although the technology has diverged more recently) https://docs.imgtec.com/Profiling_and_Optimisations/PerfRec/topics/c_PerfRec_msaa_performance.html

On PowerVR hardware, Multi-Sampled Anti-Aliasing (MSAA) can be performed directly in on-chip memory before being written out to system memory, which saves valuable memory bandwidth

If using MSAA is costing you memory on iOS, then it's either because of a poorly written driver, or because of some unusual usage which prevents the driver from optimising it away. That said, GLES has been deprecated on iOS for quite a long time, so the drivers may not be great.

  • Related