Created
July 9, 2020 03:03
-
-
Save kylehowells/63d0723abc9588eb734cade4b7df660d to your computer and use it in GitHub Desktop.
Get the maximum supported Metal texture size for the current device on iOS or macOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SceneKit | |
import CoreGraphics | |
static func getMaxImageWidth() -> Int { | |
let device = MTLCreateSystemDefaultDevice()! | |
// According to the Metal Feature Set Tables there are only two supported maximum resolutions | |
// 16384px for macs and the latest iOS devices | |
// 8192px for the older iOS devices | |
// Older Apple devices used to be limited to 4,096, 2,048 or even 1,024, but are no longer supported | |
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf | |
if device.supportsFamily(MTLGPUFamily.macCatalyst1) || | |
device.supportsFamily(MTLGPUFamily.mac1) || | |
device.supportsFamily(MTLGPUFamily.apple3) { | |
return 16384 | |
} | |
return 8192 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment