VK_EXT_attachment_feedback_loop_layout.proposal

This document details API design ideas for the VK_EXT_attachment_feedback_loop_layout extension, which provides functionality to both render to and sample/fetch from the same subresource of an image in a given render pass.

Problem Statement

Some applications and API layering efforts need a way to sample from an image that is being rendered to at the same time. This can either be a color attachment or a depth/stencil attachment.

Some applications and API layering efforts were using VK_IMAGE_LAYOUT_GENERAL for feedback loops against the specification.

The cases that need to be covered are:

  • One-to-one texel-to-pixel interactions.
  • Reading/sampling from a region not currently being written to the image as a color or depth/stencil attachment.

Ideally, the solution would also support sampling an image using regular texture operations.

Solution Space

  1. Extend input attachments + subpassLoad to support disjoint regions:
    • Using input attachments would also require extra work to patch shaders and re-compile pipelines at draw time, which would result in stutter.
    • Would not support using samplers, which is needed by the layers.
    • Would somehow need to support lod-bias/grad which really does not make sense for subpassLoad.
  2. Require image copies for feedback loops used in this manner
    • There can be hundreds of draws with a feedback loop which results in a hundreds of copies and barriers between each draw call, which does not work for performance.
  3. Add a new VkImageLayout that supports attachment feedback loops.

Proposal

Add a new layout, VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT, that supports attachment feedback loops.

It will support all of the following cases:

  • One-to-one texel-to-pixel interactions.
  • Reading/sampling from a region not currently being written to the image as a color or depth/stencil attachment.
  • Sampling or fetching from the image while it is not a color or depth/stencil attachment in the current render pass.
  • Writing to the image as a color or depth/stencil attachment while it is not being sampled or fetched in the current render pass.

Issues

RESOLVED: Is it possible to use VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT image layout with sparse images?

Yes, there is no difference between sparse and non-sparse images.