Home > Net >  How to write into specific mipmap using Metal kernel?
How to write into specific mipmap using Metal kernel?

Time:07-08

When using GLSL, it's easy writing into specific mipmap level.

But I found out it seems missing in Metal shading language.

Well, I might be wrong. Maybe there are some workaround.

CodePudding user response:

You have two options here:

  1. If you are using Metal 2.3 or higher, you can use void write(Tv color, uint2 coord, uint lod = 0) or void write(Tv color, ushort2 coord, ushort lod = 0) methods on metal::texture2d. The problem is, that even with Metal 2.3 lod must be 0 on Intel and AMD GPUs.

  2. To work around that limitation, you can make an MTLTexture view using newTextureViewWithPixelFormat:textureType:levels:slices: (https://developer.apple.com/documentation/metal/mtltexture/1515409-newtextureviewwithpixelformat?language=objc) for the level you want to write.

  • Related