繁体   English   中英

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

[英]Vulkan.hpp Supbass attachment violates validation layer

我有以下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

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

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

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

考虑2个未使用的参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM