我试图使用纹理视图为纹理仅生成mipmap的子集,但所有尝试都会导致以下错误:
由于执行期间出错,命令缓冲区的执行被中止。忽略(导致先前/过多GPU错误)(IOAF代码4)
伪代码:
// This is a texture that is 1024 x 1024 with 11 mipmap levels.
id<MTLTexture> destinationTexture = ...
// Extract all mipmap levels from 256 and smaller
NSRange levelsRange = NSMakeRange(2, 9);
// Create a new texture view for that includes only those levels from the destination texture.
id<MTLTexture> destinationView = [destinationTexture newTextureViewWithPixelFormat:destinationTexture.pixelFormat
textureType:destinationTexture.textureType
levels:levelsRange
slices:NSMakeRange(0, 1)];
// Copy a region from a source texture into the destination view,
// starting at level 0 of the view which, I think, should represent
// level 2 of its parent texture.
[blitEncoder copyFromTexture:sourceTexture
sourceSlice:0
sourceLevel:0
sourceOrigin:sourceOrigin
sourceSize:sourceSize
toTexture:destinationView
destinationSlice:0
destinationLevel:0
destinationOrigin:destinationOrigin];
// Generate mipmaps on the destination view. This causes the crash.
[blitEncoder generateMipmapsForTexture:destinationView];
目前,blit正确执行,纹理更新,但如果我尝试生成mipmap,它会崩溃。如果我不生成mipmap,那么我需要使用
lod()
,而我希望使用
bias()
改为使用功能来限制范围。