Fix crashes for Metal 3.0 capabilities.
Don't allocate MTLHeap of zero size. MVKImage check for device memory when accessing MTLCPUCacheMode..
This commit is contained in:
parent
c6ea99e4db
commit
b5b103e75c
@ -178,6 +178,9 @@ bool MVKDeviceMemory::ensureMTLHeap() {
|
||||
// Don't bother if we don't have placement heaps.
|
||||
if (!getDevice()->_pMetalFeatures->placementHeaps) { return true; }
|
||||
|
||||
// Can't create MTLHeaps of zero size.
|
||||
if (_allocationSize == 0) { return true; }
|
||||
|
||||
#if MVK_MACOS
|
||||
// MTLHeaps on Mac must use private storage for now.
|
||||
if (_mtlStorageMode != MTLStorageModePrivate) { return true; }
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
MTLStorageMode getMTLStorageMode();
|
||||
|
||||
/** Returns the Metal CPU cache mode used by this image. */
|
||||
inline MTLCPUCacheMode getMTLCPUCacheMode() { return _deviceMemory->getMTLCPUCacheMode(); }
|
||||
MTLCPUCacheMode getMTLCPUCacheMode();
|
||||
|
||||
/**
|
||||
* Returns whether the memory is automatically coherent between device and host.
|
||||
|
@ -487,6 +487,10 @@ MTLStorageMode MVKImage::getMTLStorageMode() {
|
||||
return stgMode;
|
||||
}
|
||||
|
||||
MTLCPUCacheMode MVKImage::getMTLCPUCacheMode() {
|
||||
return _deviceMemory ? _deviceMemory->getMTLCPUCacheMode() : MTLCPUCacheModeDefaultCache;
|
||||
}
|
||||
|
||||
bool MVKImage::isMemoryHostCoherent() {
|
||||
return (getMTLStorageMode() == MTLStorageModeShared);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user