Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
Vulkan Validation Layer keeps throwing an Image Layout Error on VkQueuePresentKHR()
明显的noob警告。从昨天开始学习Vulkan,正如标题所说,我在提交到现在时不断出现上述错误。我已经检查了教程中的代码,但没有发现任何明显的错误。这是我的RenderPass创建代码:
VkAttachmentDescription colorAttachmentDescription = {};
colorAttachmentDescription.format = this->surfaceFormat.format;
colorAttachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
colorAttachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
colorAttachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
colorAttachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colorAttachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorAttachmentDescription.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorAttachmentDescription.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentReference attachmentReference = {};
attachmentReference.attachment = 0;
attachmentReference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDescription subpassDescription = {};
subpassDescription.colorAttachmentCount = 1;
subpassDescription.pColorAttachments = &attachmentReference;
subpassDescription.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
VkSubpassDependency subpassDependency = {};
subpassDependency.srcSubpass = VK_SUBPASS_EXTERNAL;
subpassDependency.dstSubpass = 0;
subpassDependency.srcAccessMask = 0;
subpassDependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
subpassDependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
VkRenderPassCreateInfo renderPassCreateInfo = {};
renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassCreateInfo.attachmentCount = 1;
renderPassCreateInfo.pAttachments = &colorAttachmentDescription;
renderPassCreateInfo.subpassCount = 1;
renderPassCreateInfo.pSubpasses = &subpassDescription;
renderPassCreateInfo.dependencyCount = 1;
renderPassCreateInfo.pDependencies = &subpassDependency;
vkCreateRenderPass(logicalDevice, &renderPassCreateInfo, nullptr, &renderPass);
哦,我甚至尝试过将initialLayout更改为VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
,但仍然出现错误。这是我得到的验证层错误。
VALIDATION LAYER : Images passed to present must be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in VK_IMAGE_LAYOUT_UNDEFINED. The Vulkan spec states: Each element of pImageIndices must be the index of a presentable image acquired from the swapchain specified by the corresponding element of the pSwapchains array, and the presented image subresource must be in the VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout at the time the operation is executed on a VkDevice (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkPresentInfoKHR-pImageIndices-01296)
问题在于从发布的代码中省略了渲染过程的创建。
双击VkRenderPassCreateInfo中的VkAttachmentDescription条目。
同时检查attachmentCount
是否不为零。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 增加 gil 读取图像错误
- 在图像上覆盖文本的程序会产生无休止的字符串错误
- 卤化物:较大图像的去马赛克算法错误.似乎适用于 16x16 图像
- 视觉C++:图像序列加载错误
- SFML 库未加载错误,找不到图像
- 使用 Nvidia NPP 调整图像大小时未记录的大小调整错误
- C++/openCV - 为什么显示图像会产生 Linux 分割错误?(打开CV错误?
- 张量流错误:执行器无法创建内核。没有注册'Snapshot' 适用于 GPU 设备的 OpKernel 运行图像标签示例
- SWscaler 错误的 SRC 图像指针
- Mat的convertTo函数在OpenCV中将灰度图像的类型转换为CV_32F时抱怨断言错误
- 幼稚的过滤返回错误的图像
- OPENCV IMREAD 8BPP PNG图像错误
- TBB免费图像lambda阵列比较错误
- GTK图像突然不会刷新任何错误或警告
- 试图均衡图像时的分割错误
- glDrawArrays的意外行为-参数顺序错误会产生所需的图像
- 尝试为图像缓冲区分配内存时 ptr 值错误
- 未能加载图像错误代码2