Skip to content

Errors for a Clear Attachment for Stencil values if first in a vsg::View #1514

@hytel

Description

@hytel

I have a stencil clear attachment that I initialize like so:

VkClearValue clearStencilValue{};
clearStencilValue.depthStencil = { 0.0f, 0 };
VkClearAttachment stencil_attachment{ VK_IMAGE_ASPECT_STENCIL_BIT, 1, clearStencilValue };
VkClearRect rect{ m_camera->getRenderArea(), 0, 1 };
m_stencil_clear_attachments = vsg::ClearAttachments::create(vsg::ClearAttachments::Attachments{ stencil_attachment }, vsg::ClearAttachments::Rects{ rect });

If I add this as my first child to my main vsg::View, I will get the errors showing to the console if I turn on debugLayer:

Validation Error: [ VUID-vkCmdClearAttachments-aspectMask-07885 ] | MessageID = 0x5baaed1d
vkCmdClearAttachments(): pAttachments[0] in pSubpasses[0] has VK_IMAGE_ASPECT_STENCIL_BIT and is backed by an image view with format (VK_FORMAT_D32_SFLOAT).
The Vulkan spec states: If the current render pass instance does not use dynamic rendering, and the aspectMask member of any element of pAttachments contains VK_IMAGE_ASPECT_STENCIL_BIT, the current subpass instance's depth-stencil attachment must be either VK_ATTACHMENT_UNUSED or the attachment format must contain a stencil component (https://vulkan.lunarg.com/doc/view/1.4.309.0/windows/antora/spec/latest/chapters/clears.html#VUID-vkCmdClearAttachments-aspectMask-07885)
Objects: 3
[0] VkCommandBuffer 0x1b71fecdef0
[1] VkRenderPass 0xba7514000000002a
[2] VkImageView 0xb9181f0000000029

This appears to be because I have the view dependent shadows on and I get more than one (maybe because I have requested more than one shadowmap?)

If Instead, I add a large scene group node to the view, and somewhere down in the group I add this clear attachment, I will not see these errors.

Either way, the results look fine on the screen - I think it's just complaining that the clear stencil isn't going to work for the shadow image which is a depth-only image (VK_FORMAT_D32_SFLOAT) I believe.

I expected that it wouldn't matter where I place this attachment. I'm trying to place it as a separate first child in my main view because I also have an off-screen view which needs a DIFFERENT attachment because it will have a different rect for it's offscreen image size. If I try to share this attachment in a single scene with both vsg::Views, I get the mismatch size error because this clear attachment won't work for both views. Any thoughts? Should I just ignore them?

  • OS: Windows 11 x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions