How to get programmatically the maximum texture size (width and height)

前端 未结 2 1521
名媛妹妹
名媛妹妹 2021-01-06 16:59

How to get programmatically the maximum texture size (width and height) with metal? with openGL i can do: glGetIntegerv(GL_MAX_TEXTURE_SIZE, ...) but how to do

相关标签:
2条回答
  • 2021-01-06 17:51

    There is currently no API for retrieving the maximum texture dimensions of a Metal device. You should consult the Metal Feature Set Tables for this information and include it in your app instead.

    For A9 and newer GPUs running current versions of iOS/tvOS/iPadOS, the maximum size of a 2D texture is 16384×16384.

    0 讨论(0)
  • 2021-01-06 17:51

    As @warrenm has mentioned, it is programmatically not possible to get the maximum texture size supported by the device. However, the below code will give you the hardcoded size based on the device type.

    int maxTexSize = 4096;
    
    if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1] || [mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) {
        maxTexSize = 16384;
    else if ([mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily2_v2] || [mtldevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v2]) {
        maxTexSize = 8192;
    } else {
        maxTexSize = 4096;
    }
    
    0 讨论(0)
提交回复
热议问题