metal - 金属渲染通道中没有颜色附件
问题描述
是否有可能MTLRenderPassDescriptor
渲染到深度或模板纹理,但没有颜色附件?像这样:
MTLRenderPassDescriptor* textureRenderPassDescriptor = [MTLRenderPassDescriptor renderPassDescriptor];
MTLRenderPassStencilAttachmentDescriptor* textureAttachment = [[MTLRenderPassStencilAttachmentDescriptor alloc]init];
textureAttachment.texture = texture;
textureAttachment.loadAction = MTLLoadActionClear;
textureAttachment.storeAction = MTLStoreActionStore;
textureRenderPassDescriptor.stencilAttachment = textureAttachment;
我尝试这样做,但在尝试使用此管道状态时出现以下错误:
failed assertion `For color attachment 0, the renderPipelineState pixelFormat must be MTLPixelFormatInvalid, as no texture is set.'
解决方案
正如断言所述,您需要pixelFormat
在创建时设置为无效MTLRenderPipelineState
:
pipelineStateDescriptor.colorAttachments[0].pixelFormat = MTLPixelFormatInvalid;
推荐阅读
- php - SSL_SERVER_S_DN_Email 在 PHP var_dump 中显示不正确的电子邮件
- sql - 一张表的一条记录显示在另一张表的所有记录上
- binary - mod 2^64 加法在密码学中实际上意味着什么?
- python - 如何获取自定义异常的参数以在消息中使用它?
- php - 未使用 PHP setcookie 函数设置 Cookie
- powershell - 如何获取共享文件夹中的剩余存储空间
- macros - 本地“宏”中未知的参数类型
- scala - 创建源时将 Future[Done] 指定为物化值
- php - Facebook SDK 以 JFIF 形式返回个人资料图片,如何在 PHP 中转换为 JPG/PNG?
- android - 有没有办法正确模拟房间数据库?