Xcode's GPU frame capture highlight multiple expressions as purple and say I should set the texture storage mode to private because only GPU access it. I am trying to fix the purple suggestion.
Memory Usage'Texture:0x10499ae00 "CoreVideo 0x6000017f2bc0"' has storage mode 'Managed' but is accessed exclusively by a GPU
When using device.makeBuffer(bytes:length:options:) to create MTLTexture, I can set storageMode to private in the argument options.
But when create MTLTexture from CVPixelBuffer through CVMetalTextureCacheCreateTextureFromImage(), I don't know how to configure the storage mode for the created texture.
Ways I tried:
- Pass a texture attributes dictionary to the
textureAttributesargument inCVMetalTextureCacheCreateTextureFromImage(..., _ textureAttributes: CFDictionary?, ...)
var textureAttrs: [String: Any] = [:]
if #available(macOS 10.15, *) {
textureAttrs[kCVMetalTextureStorageMode as String] = MTLStorageMode.private
}
CVMetalTextureCacheCreateTextureFromImage(,,,textureAttrs as CFDictionary,..., &texture)
if let texture = texture,
let metalTexture = CVMetalTextureGetTexture(texture) {
print(metalTexture.storageMode.rawValue)
}
}
My OS is already 10.15.4, but the created MTLTexture still has storageMode as managed/rawValue: 1
- Pass the same attribute to
CVMetalTextureCacheCreate()which creates the cache forCVMetalTextureCacheCreateTextureFromImageincacheAttributesandtextureAttributes.
The result is the same.
Problems:
- Is that my attributes dictionary has wrong key-value set? The apple documentation doesn't describe which key and value need to be set.
- Or there is a correct way to configure
- Or currently it does not support yet?
References: