Restrict MTLHeap to private or shared storage modes on iOS.

Set heap storage mode and CPU cache mode parameters directly.
This commit is contained in:
Bill Hollings 2019-12-16 16:53:20 -05:00
parent a7348e2c69
commit b6aae29a85

View File

@ -182,13 +182,19 @@ bool MVKDeviceMemory::ensureMTLHeap() {
if (_allocationSize == 0) { return true; } if (_allocationSize == 0) { return true; }
#if MVK_MACOS #if MVK_MACOS
// MTLHeaps on Mac must use private storage for now. // MTLHeaps on macOS must use private storage for now.
if (_mtlStorageMode != MTLStorageModePrivate) { return true; } if (_mtlStorageMode != MTLStorageModePrivate) { return true; }
#endif #endif
#if MVK_IOS
// MTLHeaps on iOS must use private or shared storage for now.
if ( !(_mtlStorageMode == MTLStorageModePrivate ||
_mtlStorageMode == MTLStorageModeShared) ) { return true; }
#endif
MTLHeapDescriptor* heapDesc = [MTLHeapDescriptor new]; MTLHeapDescriptor* heapDesc = [MTLHeapDescriptor new];
heapDesc.type = MTLHeapTypePlacement; heapDesc.type = MTLHeapTypePlacement;
heapDesc.resourceOptions = getMTLResourceOptions(); heapDesc.storageMode = _mtlStorageMode;
heapDesc.cpuCacheMode = _mtlCPUCacheMode;
// For now, use tracked resources. Later, we should probably default // For now, use tracked resources. Later, we should probably default
// to untracked, since Vulkan uses explicit barriers anyway. // to untracked, since Vulkan uses explicit barriers anyway.
heapDesc.hazardTrackingMode = MTLHazardTrackingModeTracked; heapDesc.hazardTrackingMode = MTLHazardTrackingModeTracked;