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:
If you are using Metal 2.3 or higher, you can use
void write(Tv color, uint2 coord, uint lod = 0)
orvoid write(Tv color, ushort2 coord, ushort lod = 0)
methods onmetal::texture2d
. The problem is, that even with Metal 2.3lod
must be 0 on Intel and AMD GPUs.To work around that limitation, you can make an
MTLTexture
view usingnewTextureViewWithPixelFormat:textureType:levels:slices:
(https://developer.apple.com/documentation/metal/mtltexture/1515409-newtextureviewwithpixelformat?language=objc) for the level you want to write.