c++ - 提交的命令缓冲区上的 CoreValidation-DrawState-InvalidImageLayout 错误
问题描述
我不知道为什么我会收到这个错误
消息:[UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout] 对象:0x55f38f345890(类型 = 6)| 提交的命令缓冲区期望图像 0x1e(子资源:aspectMask 0x1 数组第 0 层,mip 级别 0)在布局 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL 中——相反,图像 0x1e 的当前布局是 VK_IMAGE_LAYOUT_PRESENT_SRC_KHR。
我正在使用命令缓冲区将图像从帧缓冲区传输到当前存在的图像,如下所示
command_buffer.transitionImageLayout(
framebuffer_image, ImageLayout::COLOR_ATTACHMENT_OPTIMAL, ImageLayout::TRANSFERT_SRC_OPTIMAL);
command_buffer.transitionImageLayout(
current_image, ImageLayout::PRESENT_SRC, ImageLayout::TRANSFERT_DST_OPTIMAL);
command_buffer.blitImage(
framebuffer_image, current_image, framebuffer_image.extent(), m_extent);
command_buffer.transitionImageLayout(
framebuffer_image, ImageLayout::TRANSFERT_SRC_OPTIMAL, ImageLayout::COLOR_ATTACHMENT_OPTIMAL);
command_buffer.transitionImageLayout(
current_image, ImageLayout::TRANSFERT_DST_OPTIMAL, ImageLayout::PRESENT_SRC);
错误在命令缓冲区提交时触发
我激活了 VK_LAYER_LUNARG_api_dump 层,我得到了这个:
解决方案
错误消息非常简单。
您首先VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
在命令缓冲区中使用图像。我们可以看到并验证:
command_buffer.transitionImageLayout( framebuffer_image, ImageLayout::COLOR_ATTACHMENT_OPTIMAL // etc
该错误通知您该图像是在VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
而不是。这是如何发生的取决于您的代码的其余部分。您必须在之前(意外地)将图像转换为该布局。那将是通过一些 previousvkCmdPipelineBarrier
或通过 renderpass finalLayout
。
(或者验证层中不太可能存在错误。在这种情况下,将其报告给KhronosGroup/Vulkan-ValidationLayers。)
推荐阅读
- firebase - Firebase Hosting How to put multiple links in Access Control Allow Origin Header
- php - 从浏览器运行 phar 文件
- java - 使用 Web Sphere 服务器,我们可以从部署的 .war/.ear/ 中更新和读取文件吗?文件?
- node.js - 寻找node-sqlite3的优化方法
- java - XML Parsing Query Linq 用于搜索所需
- asp.net - asp.net mvc 如何获取到我的网站的传入帖子请求的 Web 服务器 ip
- c++ - 修改 not_null 以禁止与 nullptr 进行比较
- javascript - 使用自动完成 jquery 和 Odoo rpc 调用的输入不显示建议
- angularjs - How to use track by in ng-repeat having array in ng-model
- java - 如何将位图图像添加到int数组