objective-c - 你可以使用纹理视图只为 MTLTexture 生成 mipmap 的子集吗?
问题描述
我正在尝试使用纹理视图仅生成纹理的 mipmap 子集,但我的所有尝试都导致 Metal 引发以下错误:
由于执行期间出现错误,命令缓冲区的执行被中止。忽略(用于导致先前/过多的 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];
我的目的是快速渲染一些较低分辨率的内容并将其复制到纹理,然后逐步渲染更高分辨率的内容。我可以显式渲染每个 mipmap 级别的内容,但我希望只选择几个“截止”级别,然后让 Metal 为截止以下的所有级别生成 mipmap。
就目前而言,blit 正确执行并更新了纹理,但如果我尝试生成 mipmap,它会崩溃。如果我不生成 mipmap,那么我需要使用 显式地从该级别进行采样lod()
,而我希望使用该bias()
功能来限制范围。
堆栈跟踪是:
解决方案
推荐阅读
- django - 我是 Django 的新手,一直被困在 ERROR 404 (Page Not Found)
- boolean-logic - Python真值表
- linux - 通过保存虚拟设备删除 genymotion
- dart - 飞镖中的异步等待同步运行?
- jquery - 指定何时应该使用 $(window).load 而不是 $(document).ready?jQuery
- javascript - 如何过滤其中包含空格的 Shopify 产品类型?
- pine-script - 当 RSI 回落到某个值以下时,Pinescript 会触发警报
- php - Wordpress 中的帖子突然被删除?
- selenium - Azure 管道运行 selenium 脚本
- java - Spring Boot JPA 多对多关系。得到意想不到的回应