CALayer 选择哪个 GPU

CALayer choose which GPU

在具有多个 GPU 的机器上,是否可以通过编程方式告诉 CALayer 使用哪个 GPU?

我似乎无法在网上或 Apple 文档中找到有关此的任何信息。如果不能选择,如何确定合适的GPU?

您似乎需要使用 Metal 在 CoreAnimation 中进行渲染。根据 Apple 的文档,您将通过引用 CAMetalLayer class 对象来执行此操作,该对象直接继承自 CALayer. 该信息在此处列出:

https://developer.apple.com/documentation/quartzcore/cametallayer

CAMetalLayer 公开了一些属性,例如 preferredDevice,Apple 将其描述为:

On systems with a single GPU, this method returns the default device object; see MTLCreateSystemDefaultDevice(). On systems with more than one GPU, this method returns the MTLDevice that was last used to composite and present the CAMetalLayer. This device object usually corresponds to the GPU associated with the screen that’s displaying the layer. If you set the layer’s device property to this device object, you reduce the number of cross-GPU texture copies that Core Animation must perform to present the layer’s contents onscreen.

综上所述,我认为您需要直接查看 Metal 文档,它提供了与 GPU/eGPU 交互的相当不错的前进路径。可以在这里找到:

https://developer.apple.com/documentation/metal/mtldevice

link 将带您了解与各种 GPU 设备交互的协议,它确实讨论了运行中的多个 GPU。祝你好运!