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.
You have two options here:
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.
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.