1// Copyright 2022-2023 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5= VK_EXT_attachment_feedback_loop_layout 6:toc: left 7:refpage: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/ 8:sectnums: 9 10This document details API design ideas for the `VK_EXT_attachment_feedback_loop_layout` extension, 11which provides functionality to both render to and sample/fetch from the same subresource of an image in a given 12render pass. 13 14== Problem Statement 15 16Some applications and API layering efforts need a way to sample from an image that is being rendered to 17at the same time. This can either be a color attachment or a depth/stencil attachment. 18 19Some applications and API layering efforts were using 20`VK_IMAGE_LAYOUT_GENERAL` for feedback loops against the specification. 21 22The cases that need to be covered are: 23 24 * One-to-one texel-to-pixel interactions. 25 * Reading/sampling from a region not currently being written 26 to the image as a color or depth/stencil attachment. 27 28Ideally, the solution would also support sampling an image using regular texture operations. 29 30== Solution Space 31 32 . Extend input attachments + `subpassLoad` to support disjoint regions: 33 34 * Using input attachments would also require extra work to patch shaders and re-compile pipelines 35 at draw time, which would result in stutter. 36 * Would not support using samplers, which is needed by the layers. 37 * Would somehow need to support lod-bias/grad which really does not make sense for `subpassLoad`. 38 39 . Require image copies for feedback loops used in this manner 40 41 * There can be hundreds of draws with a feedback loop which results in a hundreds of copies and barriers 42 between each draw call, which does not work for performance. 43 44 . Add a new `VkImageLayout` that supports attachment feedback loops. 45 46== Proposal 47 48Add a new layout, `VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT`, that supports attachment feedback loops. 49 50It will support all of the following cases: 51 52 * One-to-one texel-to-pixel interactions. 53 * Reading/sampling from a region not currently being written 54 to the image as a color or depth/stencil attachment. 55 * Sampling or fetching from the image while it is not a 56 color or depth/stencil attachment in the current render pass. 57 * Writing to the image as a color or depth/stencil attachment while it is not 58 being sampled or fetched in the current render pass. 59 60== Issues 61 62=== RESOLVED: Is it possible to use `VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT` image layout with sparse images? 63 64Yes, there is no difference between sparse and non-sparse images. 65