DRHT > error > MTLTextureDescriptor

my code:

guard let drawable = view.currentDrawable else { return }
    let renderPassDescriptor = MTLRenderPassDescriptor()
    renderPassDescriptor.colorAttachments[0].texture = drawable.texture //There is a crash
    renderPassDescriptor.colorAttachments[0].loadAction = .clear
    renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: 0, green: 0, blue: 0, alpha: 0)

error info:

MTLTextureDescriptor has height (9964) greater than the maximum allowed size of 8192. > validateTextureDimensions > validateTextureDimensions:1075: failed assertion `MTLTextureDescriptor has height (9964) greater than the maximum allowed size of 8192.'

please help:

I try to put a canvas on an image,as you can see,the size of this canvas is too large to exceed the GPU processing limit。Is there a better way that don't change size to solve this problem

Answered by Ceylo in 738398022

Look for "Maximum 2D texture width and height" in https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf

You can check the GPUFamily through MTLDevice API.

As for how to workaround this limitation, I guess you only have two choices:

  • use a smaller texture size
  • use several textures and display them next to each other like tiles

So far, I only found it on the iPad mini 2

Accepted Answer

Look for "Maximum 2D texture width and height" in https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf

You can check the GPUFamily through MTLDevice API.

As for how to workaround this limitation, I guess you only have two choices:

  • use a smaller texture size
  • use several textures and display them next to each other like tiles
DRHT > error > MTLTextureDescriptor
 
 
Q