1

I'm refactoring the render layer of cocos2d-x, and the new engine will use Metal on iOS. In the original version, cocos2dx would recreate all buffers and textures when the app was brought to foreground after a long time stayed in the background.

I'm a newbie with Metal, and my question is: Is it necessary to recreate the MTLBuffer, MTLTexture and other Metal resources as GLES?

Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42
realxie
  • 109
  • 3

1 Answers1

5

It's not necessary to recreate Metal resources when an app returns to being active from being in a background state.

On the other hand, since textures and buffers can be large, and because they reside in system memory for the duration of their lifetime (iOS has a unified memory architecture and lacks a paging system), you may want to free some or all of your Metal resources when entering a background state to reduce the likelihood that your app gets terminated when another app needs the memory it is using. In that case, you'd recreate those resources if/when your app returns from the background state.

warrenm
  • 31,094
  • 6
  • 92
  • 116