Vulkan.hpp Supbass附件违反了验证层

问题描述 投票:0回答:1

我有以下vulkan初始化代码:

vk::AttachmentReference color_attachment_ref(0,
    vk::ImageLayout::eColorAttachmentOptimal);

auto colorAttachment = *(VkAttachmentDescription*)&color_attachment;
auto colorAttachmentRef = (VkAttachmentReference)color_attachment_ref;

/*vk::SubpassDescription spass({}, vk::PipelineBindPoint::eGraphics, 1,
    &color_attachment_ref);
auto subpass = (VkSubpassDescription) spass;*/
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;

但是,当我尝试重构代码以使用vulkan.hpp中的对象时,这非常有效:

vk::AttachmentReference color_attachment_ref(0,
    vk::ImageLayout::eColorAttachmentOptimal);

auto colorAttachment = *(VkAttachmentDescription*)&color_attachment;
auto colorAttachmentRef = (VkAttachmentReference)color_attachment_ref;

vk::SubpassDescription spass({}, vk::PipelineBindPoint::eGraphics, 1,
    &color_attachment_ref);
auto subpass = (VkSubpassDescription) spass;
/*VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;*/

我明白了:

validation layer: Layout for input attachment is VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL.
UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout

据我所知,两种方法初始化都是等价的,我搞砸了什么?

c++ graphics gpu vulkan
1个回答
0
投票

问题是参数的顺序。我传递的参数不对应于函数签名,正确的版本是:

vk::SubpassDescription spass({}, vk::PipelineBindPoint::eGraphics, 0, nullptr, 1,
&color_attachment_ref);

考虑2个未使用的参数。

© www.soinside.com 2019 - 2024. All rights reserved.