KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

Validation for dynamic rendering attachment layout possibly doesn't respect input attachment indices for local reads

Open
#12,039 6 comments 0 reactions 2 assignees Claimed by @artem-lunarg View on GitHub
Bug
Dominant language
C++
Stars
1k
Forks
504
Avg merge
11h 35m
Merged PRs (30d)
224

Description

**Environment:**
- OS: Windows 11
- GPU and driver version: NVIDIA RTX 4070, latest developer driver
- SDK or header version if building from repo: Built from latest commit
- Options enabled (synchronization, best practices, etc.): no

**Describe the Issue**

The check for image layouts of the attachments when using dynamic rendering does not take into account that you can "ignore" attachments via `VkRenderingInputAttachmentIndexInfo`.

E.g. if you have the following setup for a deferred renderer:

* Attachment 0: Swapchain image
* Attachment 1: Position and depth
* Attachment 2: Normal
* Attachment 3: Albedo

And only want to use Attachments 1 through 3 in a pass that reads from them locally (using `VK_KHR_dynamic_rendering_local_read`) you can configure the first attachment (swapchain image) as unused:

```cpp
std::vector colorAttachmentInputIndices = { VK_ATTACHMENT_UNUSED, 0, 1, 2 };
VkRenderingInputAttachmentIndexInfo renderingInputAttachmentIndexInfo = {
.sType = VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR,
.colorAttachmentCount = static_cast(colorAttachmentInputIndices.size()),
.pColorAttachmentInputIndices = colorAttachmentInputIndices.data()
};
```

This information will be added to the dynamic rendering info of the pipeline and will also be set during command buffer recording using `vkCmdSetRenderingInputAttachmentIndicesKHR`.

The (potential) issue here is, that the check seems to be triggered when `vkCmdBeginRenderingKHR` is called, at which point neither the pipeline is known (which has above info) nor `vkCmdSetRenderingInputAttachmentIndicesKHR` has been called, which puts this information in the command buffer.

This can be tested with the dynamic rendering local read sample from https://github.com/KhronosGroup/Vulkan-Samples

Possibly related to #11750

**Expected behavior**

The validation respects the information provided via `VkRenderingInputAttachmentIndexInfo` and skips image layout checks for unused attachments.

**Valid Usage ID**

VUID-vkCmdBeginRendering-pRenderingInfo-09592

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.