-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On macOS Apple Silicon, avoid managed-memory textures, and resource syncs. #2217
On macOS Apple Silicon, avoid managed-memory textures, and resource syncs. #2217
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason that we can avoid Managed memory is that the Apple Silicon Mac GPUs use a shared memory architecture. However, I believe that some MacBooks with Intel CPUs also use this architecture for integrated GPUs. Therefore, I wonder if this change should not only be for Apple Silicon, but for any GPU with a SMA, at least for buffers?
MTLStorageModeShared
This is the default storage mode for MTLBuffer instances on integrated GPUs and both MTLBuffer and MTLTexture instances on Apple silicon GPUs. On non-Apple family GPUs, the shared storage mode isn’t available for MTLTexture instances.
Also, does this bring any noticeable performance benefits?
I did investigate this a bit. As mentioned in the So, to cover both Apple & older Intel GPUs, we'd have to have a mix of I've got nothing against eventually getting there, but my goal here is primarily to clean things up for Apple Silicon behaviour, since that's the path of the future.
I haven't tried running any benchmarks on this. Probably not a huge performance benefit, because I should think the Apple Silicon sync methods must effectively be no-ops. But it can't hurt, and now we treat all Apple Silicon platforms the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some concerns about dead code on iOS and tvOS.
…yncs. Like their iOS/tvOS counterparts, macOS Apple Silicon GPUs support using Shared memory for textures, and do not require resource synchronization, even with Managed memory. This change treats macOS Apple Silicon the same as iOS & tvOS. - MVKPhysicalDevice add _hasUnifiedMemory & _isAppleGPU flags. - MVKDeviceTrackingMixin add isUnifiedMemoryGPU() & isAppleGPU(). - Do not advertise host-visible-but-not-host-coherent Vulkan memory type on macOS Apple Silicon. - Replace mvkMTLStorageModeFromVkMemoryPropertyFlags() with MVKPhysicalDevice::getMTLStorageModeFromVkMemoryPropertyFlags(), and return Shared instead of Managed for Apple Silicon, even if coherency is not requested. - On unified memory devices, avoid needless calls to didModifyRange:, synchronizeResource:, and synchronizeTexture:slice:level:.
eb26fca
to
607aaff
Compare
Like their iOS/tvOS counterparts, macOS Apple Silicon GPUs support using Shared memory for textures, and do not require resource synchronization, even with Managed memory. This change treats macOS Apple Silicon the same as iOS & tvOS.
MVKPhysicalDevice
add_hasUnifiedMemory
&_isAppleGPU
flags.MVKDeviceTrackingMixin
addisUnifiedMemoryGPU()
&isAppleGPU()
.mvkMTLStorageModeFromVkMemoryPropertyFlags()
withMVKPhysicalDevice::getMTLStorageModeFromVkMemoryPropertyFlags()
, and return Shared instead of Managed for Apple Silicon, even if coherency is not requested.didModifyRange:
,synchronizeResource:
, andsynchronizeTexture:slice:level:
.