該
筆記:
在統一記憶體模型中,Metal 可能會完全忽略同步呼叫,因為它只為資源創建單個記憶體分配。
您還可以檢查其他開發人員的一些實作:
皮克斯影片作業室/美元:
HgiMetalCapabilities::HgiMetalCapabilities(id<MTLDevice> device)
{
if (@available(macOS 10.14.5, ios 12.0, *)) {
_SetFlag(HgiDeviceCapabilitiesBitsConcurrentDispatch, true);
}
defaultStorageMode = MTLResourceStorageModeShared;
bool unifiedMemory = false;
if (@available(macOS 100.100, ios 12.0, *)) {
unifiedMemory = true;
} else if (@available(macOS 10.15, ios 13.0, *)) {
#if defined(ARCH_OS_IOS) || (defined(__MAC_10_15) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15)
unifiedMemory = [device hasUnifiedMemory];
#else
unifiedMemory = [device isLowPower];
#endif
}
_SetFlag(HgiDeviceCapabilitiesBitsUnifiedMemory, unifiedMemory);
#if defined(ARCH_OS_MACOS)
if (!unifiedMemory) {
defaultStorageMode = MTLResourceStorageModeManaged;
}
#endif
}
KhronosGroup/MoltenVK
// Metal Managed:
// - applies to both buffers and textures
// - default mode for textures on macOS
// - two copies of each buffer or texture when discrete memory available
// - convenience of shared mode, performance of private mode
// - on unified systems behaves like shared memory and has only one copy of content
// - when writing, use:
// - buffer didModifyRange:
// - texture replaceRegion:
// - when reading, use:
// - encoder synchronizeResource: followed by
// - cmdbuff waitUntilCompleted (or completion handler)
// - buffer/texture getBytes:
uj5u.com熱心網友回復:
測驗硬體兼容性的最佳實踐是在您測驗兼容性的實際硬體上。如果您計劃支持與 Apple Silicon有很大不同的獨立 GPU,那么最好能夠訪問一個進行測驗。
您可能會近似行為,但請記住,這只是一種模擬,無法確保實際硬體的作業方式相同。
這類似于僅使用模擬器進行開發,這根本不是一個好的做法。
更新:有許多服務可以租用裸機 Mac。該MacInCloud服務允許您配置一臺機器與外部GPU(如AMD RX 580)。前 24 小時只需 0.99 美元。
有許多類似的服務,但這是我能夠驗證離散 GPU 是一種選擇的第一個服務。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/352832.html
