mirror of
https://github.com/status-im/Vulkan-Docs.git
synced 2025-02-17 08:46:32 +00:00
* Bump API patch number and header version number to 39 for this update. Github Issues: * Clarified that only accesses via the specified buffer/image subresource ranges are included in the access scopes (public issue 306). * Add missing valid usage statements for flink:vkCreateComputePipelines and flink:vkCreateGraphicsPipelines (public issue 427). Internal Issues: * Add a Note to the <<invariance,Invariance>> appendix about a difference between OpenGL and Vulkan with regards to how primitives derived from offsets are handled (internal issue 355). * Add the +<<VK_KHR_get_physical_device_properties2>>+, +<<VK_KHR_maintenance1>>+, and +<<VK_KHR_shader_draw_parameters>>+ extensions (internal issue 448). * Add the +<<VK_EXT_shader_subgroup_vote>>+ and +<<VK_EXT_shader_subgroup_ballot>>+ extensions (internal issue 449). * Update the texture level-of-detail equation in the <<textures-scale-factor,Scale Factor Operation>> section to better approximate the ellipse major and minor axes (internal issue 547). * Forbid non-explicitly allowed uses of interface decorations in the introduction to the <<interfaces,Shader Interfaces>> chapter (internal issue 607). * Replace use of MathJax with KaTeX, for improved load-time performance as well as avoiding the scrolling-and-scrolling behavior due to MathJax asynchronous rendering when loading at an anchor inside the spec. This change also requires moving to HTML5 output for the spec instead of XHTML, and there is a visible difference in that the chapter navigation index is now in a scrollable sidebar instead of at the top of the document. We may or may not retain the nav sidebar based on feedback (internal issue 613). * Improve consistency of markup and formatting in extension appendices (internal issue 631). Other Issues: * Add explicit valid usage statements to slink:VkImageCopy requiring that the source and destination layer ranges be contained in their respective source and destination images. * Add valid usage language for swapchain of flink:vkAcquireNextImage. If the swapchain has been replaced, then it should not be passed to flink:vkAcquireNextImage. * Add a valid usage statement to flink:vkCreateImageView, that the image must have been created with an appropriate usage bit set. * Noted that slink:VkDisplayPresentInfoKHR is a valid extension of slink:VkPresentInfoKHR in the <<wsi_swapchain,WSI Swapchain>> section. * Update valid usage for flink:vkCmdSetViewport and flink:vkCmdSetScissor to account for the multiple viewport feature. If the feature is not enabled, the parameters for these functions have required values that are defined in the <<features-features-multiViewport,multiple viewports>> section of the spec but were not reflected in the valid usage text for these functions. * Add the +<<VK_EXT_swapchain_colorspace>>+ extension defining common color spaces.
1281 lines
60 KiB
Plaintext
1281 lines
60 KiB
Plaintext
// Copyright (c) 2015-2017 The Khronos Group Inc.
|
|
// Copyright notice at https://www.khronos.org/registry/speccopyright.html
|
|
|
|
[[renderpass]]
|
|
= Render Pass
|
|
|
|
// refBegin VkRenderPass Opaque handle to a render pass object
|
|
|
|
A _render pass_ represents a collection of attachments, subpasses, and
|
|
dependencies between the subpasses, and describes how the attachments are
|
|
used over the course of the subpasses.
|
|
The use of a render pass in a command buffer is a _render pass instance_.
|
|
|
|
Render passes are represented by sname:VkRenderPass handles:
|
|
|
|
include::../api/handles/VkRenderPass.txt[]
|
|
|
|
// refEnd VkRenderPass
|
|
|
|
An _attachment description_ describes the properties of an attachment
|
|
including its format, sample count, and how its contents are treated at the
|
|
beginning and end of each render pass instance.
|
|
|
|
A _subpass_ represents a phase of rendering that reads and writes a subset
|
|
of the attachments in a render pass.
|
|
Rendering commands are recorded into a particular subpass of a render pass
|
|
instance.
|
|
|
|
A _subpass description_ describes the subset of attachments that is involved
|
|
in the execution of a subpass.
|
|
Each subpass can: read from some attachments as _input attachments_, write
|
|
to some as _color attachments_ or _depth/stencil attachments_, and perform
|
|
_multisample resolve operations_ to _resolve attachments_.
|
|
A subpass description can: also include a set of _preserve attachments_,
|
|
which are attachments that are not read or written by the subpass but whose
|
|
contents must: be preserved throughout the subpass.
|
|
|
|
A subpass _uses an attachment_ if the attachment is a color, depth/stencil,
|
|
resolve, or input attachment for that subpass (as determined by the
|
|
pname:pColorAttachments, pname:pDepthStencilAttachment,
|
|
pname:pResolveAttachments, and pname:pInputAttachments members of
|
|
slink:VkSubpassDescription, respectively).
|
|
A subpass does not use an attachment if that attachment is preserved by the
|
|
subpass.
|
|
The _first use of an attachment_ is in the lowest numbered subpass that uses
|
|
that attachment.
|
|
Similarly, the _last use of an attachment_ is in the highest numbered
|
|
subpass that uses that attachment.
|
|
|
|
The subpasses in a render pass all render to the same dimensions, and
|
|
fragments for pixel (x,y,layer) in one subpass can: only read attachment
|
|
contents written by previous subpasses at that same (x,y,layer) location.
|
|
|
|
[NOTE]
|
|
.Note
|
|
====
|
|
By describing a complete set of subpasses in advance, render passes provide
|
|
the implementation an opportunity to optimize the storage and transfer of
|
|
attachment data between subpasses.
|
|
|
|
In practice, this means that subpasses with a simple framebuffer-space
|
|
dependency may: be merged into a single tiled rendering pass, keeping the
|
|
attachment data on-chip for the duration of a render pass instance.
|
|
However, it is also quite common for a render pass to only contain a single
|
|
subpass.
|
|
====
|
|
|
|
_Subpass dependencies_ describe <<synchronization-dependencies, execution
|
|
and memory dependencies>> between subpasses.
|
|
|
|
A _subpass dependency chain_ is a sequence of subpass dependencies in a
|
|
render pass, where the source subpass of each subpass dependency (after the
|
|
first) equals the destination subpass of the previous dependency.
|
|
|
|
Execution of subpasses may: overlap or execute out of order with regards to
|
|
other subpasses, unless otherwise enforced by an execution dependency.
|
|
|
|
A render pass describes the structure of subpasses and attachments
|
|
independent of any specific image views for the attachments.
|
|
The specific image views that will be used for the attachments, and their
|
|
dimensions, are specified in sname:VkFramebuffer objects.
|
|
Framebuffers are created with respect to a specific render pass that the
|
|
framebuffer is compatible with (see <<renderpass-compatibility,Render Pass
|
|
Compatibility>>).
|
|
Collectively, a render pass and a framebuffer define the complete render
|
|
target state for one or more subpasses as well as the algorithmic
|
|
dependencies between the subpasses.
|
|
|
|
The various pipeline stages of the drawing commands for a given subpass may:
|
|
execute concurrently and/or out of order, both within and across drawing
|
|
commands.
|
|
However for a given (x,y,layer,sample) sample location, certain per-sample
|
|
operations are performed in <<primrast-order,rasterization order>>.
|
|
|
|
|
|
[[renderpass-creation]]
|
|
== Render Pass Creation
|
|
|
|
// refBegin vkCreateRenderPass Create a new render pass object
|
|
|
|
To create a render pass, call:
|
|
|
|
include::../api/protos/vkCreateRenderPass.txt[]
|
|
|
|
* pname:device is the logical device that creates the render pass.
|
|
* pname:pCreateInfo is a pointer to an instance of the
|
|
slink:VkRenderPassCreateInfo structure that describes the parameters of
|
|
the render pass.
|
|
* pname:pAllocator controls host memory allocation as described in the
|
|
<<memory-allocation, Memory Allocation>> chapter.
|
|
* pname:pRenderPass points to a sname:VkRenderPass handle in which the
|
|
resulting render pass object is returned.
|
|
|
|
include::../validity/protos/vkCreateRenderPass.txt[]
|
|
|
|
// refBegin VkRenderPassCreateInfo Structure specifying parameters of a newly created render pass
|
|
|
|
The sname:VkRenderPassCreateInfo structure is defined as:
|
|
|
|
include::../api/structs/VkRenderPassCreateInfo.txt[]
|
|
|
|
* pname:sType is the type of this structure.
|
|
* pname:pNext is `NULL` or a pointer to an extension-specific structure.
|
|
* pname:flags is reserved for future use.
|
|
* pname:attachmentCount is the number of attachments used by this render
|
|
pass, or zero indicating no attachments.
|
|
Attachments are referred to by zero-based indices in the range
|
|
[0,pname:attachmentCount).
|
|
* pname:pAttachments points to an array of pname:attachmentCount number of
|
|
slink:VkAttachmentDescription structures describing properties of the
|
|
attachments, or `NULL` if pname:attachmentCount is zero.
|
|
* pname:subpassCount is the number of subpasses to create for this render
|
|
pass.
|
|
Subpasses are referred to by zero-based indices in the range
|
|
[0,pname:subpassCount).
|
|
A render pass must: have at least one subpass.
|
|
* pname:pSubpasses points to an array of pname:subpassCount number of
|
|
slink:VkSubpassDescription structures describing properties of the
|
|
subpasses.
|
|
* pname:dependencyCount is the number of dependencies between pairs of
|
|
subpasses, or zero indicating no dependencies.
|
|
* pname:pDependencies points to an array of pname:dependencyCount number
|
|
of slink:VkSubpassDependency structures describing dependencies between
|
|
pairs of subpasses, or `NULL` if pname:dependencyCount is zero.
|
|
|
|
.Valid Usage
|
|
****
|
|
* If any two subpasses operate on attachments with overlapping ranges of
|
|
the same sname:VkDeviceMemory object, and at least one subpass writes to
|
|
that area of sname:VkDeviceMemory, a subpass dependency must: be
|
|
included (either directly or via some intermediate subpasses) between
|
|
them
|
|
* If the pname:attachment member of any element of
|
|
pname:pInputAttachments, pname:pColorAttachments,
|
|
pname:pResolveAttachments or pname:pDepthStencilAttachment, or the
|
|
attachment indexed by any element of pname:pPreserveAttachments in any
|
|
given element of pname:pSubpasses is bound to a range of a
|
|
sname:VkDeviceMemory object that overlaps with any other attachment in
|
|
any subpass (including the same subpass), the
|
|
sname:VkAttachmentDescription structures describing them must: include
|
|
ename:VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT in pname:flags
|
|
* If the pname:attachment member of any element of
|
|
pname:pInputAttachments, pname:pColorAttachments,
|
|
pname:pResolveAttachments or pname:pDepthStencilAttachment, or any
|
|
element of pname:pPreserveAttachments in any given element of
|
|
pname:pSubpasses is not ename:VK_ATTACHMENT_UNUSED, it must: be less
|
|
than pname:attachmentCount
|
|
* The value of any element of the pname:pPreserveAttachments member in any
|
|
given element of pname:pSubpasses must: not be
|
|
ename:VK_ATTACHMENT_UNUSED
|
|
* For any member of pname:pAttachments with a pname:loadOp equal to
|
|
ename:VK_ATTACHMENT_LOAD_OP_CLEAR, the first use of that attachment
|
|
must: not specify a pname:layout equal to
|
|
pname:VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL or
|
|
pname:VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL.
|
|
* For any element of pname:pDependencies, if the pname:srcSubpass is not
|
|
ename:VK_SUBPASS_EXTERNAL, all stage flags included in the
|
|
pname:srcStageMask member of that dependency must: be a pipeline stage
|
|
supported by the <<synchronization-pipeline-stages-types, pipeline>>
|
|
identified by the pname:pipelineBindPoint member of the source subpass.
|
|
* For any element of pname:pDependencies, if the pname:dstSubpass is not
|
|
ename:VK_SUBPASS_EXTERNAL, all stage flags included in the
|
|
pname:dstStageMask member of that dependency must: be a pipeline stage
|
|
supported by the <<synchronization-pipeline-stages-types, pipeline>>
|
|
identified by the pname:pipelineBindPoint member of the source subpass.
|
|
****
|
|
|
|
include::../validity/structs/VkRenderPassCreateInfo.txt[]
|
|
|
|
// refBegin VkAttachmentDescription Structure specifying an attachment description
|
|
|
|
The sname:VkAttachmentDescription structure is defined as:
|
|
|
|
include::../api/structs/VkAttachmentDescription.txt[]
|
|
|
|
* pname:flags is a bitmask describing additional properties of the
|
|
attachment.
|
|
Bits which can: be set include:
|
|
+
|
|
--
|
|
// refBegin VkAttachmentDescriptionFlagBits Bitmask specifying additional properties of an attachment
|
|
include::../api/enums/VkAttachmentDescriptionFlagBits.txt[]
|
|
--
|
|
* pname:format is a elink:VkFormat value specifying the format of the
|
|
image that will be used for the attachment.
|
|
* pname:samples is the number of samples of the image as defined in
|
|
elink:VkSampleCountFlagBits.
|
|
* pname:loadOp specifies how the contents of color and depth components of
|
|
the attachment are treated at the beginning of the subpass where it is
|
|
first used:
|
|
+
|
|
--
|
|
// refBegin VkAttachmentLoadOp Specify how contents of an attachment are treated at the beginning of a subpass
|
|
include::../api/enums/VkAttachmentLoadOp.txt[]
|
|
--
|
|
** ename:VK_ATTACHMENT_LOAD_OP_LOAD means the previous contents of the
|
|
image within the render area will be preserved.
|
|
For attachments with a depth/stencil format, this uses the access type
|
|
ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT.
|
|
For attachments with a color format, this uses the access type
|
|
ename:VK_ACCESS_COLOR_ATTACHMENT_READ_BIT.
|
|
** ename:VK_ATTACHMENT_LOAD_OP_CLEAR means the contents within the render
|
|
area will be cleared to a uniform value, which is specified when a
|
|
render pass instance is begun.
|
|
For attachments with a depth/stencil format, this uses the access type
|
|
ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.
|
|
For attachments with a color format, this uses the access type
|
|
ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.
|
|
** ename:VK_ATTACHMENT_LOAD_OP_DONT_CARE means the previous contents
|
|
within the area need not be preserved; the contents of the attachment
|
|
will be undefined inside the render area.
|
|
For attachments with a depth/stencil format, this uses the access type
|
|
ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.
|
|
For attachments with a color format, this uses the access type
|
|
ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.
|
|
* pname:storeOp specifies how the contents of color and depth components
|
|
of the attachment are treated at the end of the subpass where it is last
|
|
used:
|
|
+
|
|
--
|
|
// refBegin VkAttachmentStoreOp Specify how contents of an attachment are treated at the end of a subpass
|
|
include::../api/enums/VkAttachmentStoreOp.txt[]
|
|
--
|
|
** ename:VK_ATTACHMENT_STORE_OP_STORE means the contents generated during
|
|
the render pass and within the render area are written to memory.
|
|
For attachments with a depth/stencil format, this uses the access type
|
|
ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.
|
|
For attachments with a color format, this uses the access type
|
|
ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.
|
|
** ename:VK_ATTACHMENT_STORE_OP_DONT_CARE means the contents within the
|
|
render area are not needed after rendering, and may: be discarded; the
|
|
contents of the attachment will be undefined inside the render area.
|
|
For attachments with a depth/stencil format, this uses the access type
|
|
ename:VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.
|
|
For attachments with a color format, this uses the access type
|
|
ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.
|
|
* pname:stencilLoadOp specifies how the contents of stencil components of
|
|
the attachment are treated at the beginning of the subpass where it is
|
|
first used, and must: be one of the same values allowed for pname:loadOp
|
|
above.
|
|
* pname:stencilStoreOp specifies how the contents of stencil components of
|
|
the attachment are treated at the end of the last subpass where it is
|
|
used, and must: be one of the same values allowed for pname:storeOp
|
|
above.
|
|
* pname:initialLayout is the layout the attachment image subresource will
|
|
be in when a render pass instance begins.
|
|
* pname:finalLayout is the layout the attachment image subresource will be
|
|
transitioned to when a render pass instance ends.
|
|
During a render pass instance, an attachment can: use a different layout
|
|
in each subpass, if desired.
|
|
|
|
[[renderpass-load-store-ops]]
|
|
If the attachment uses a color format, then pname:loadOp and pname:storeOp
|
|
are used, and pname:stencilLoadOp and pname:stencilStoreOp are ignored.
|
|
If the format has depth and/or stencil components, pname:loadOp and
|
|
pname:storeOp apply only to the depth data, while pname:stencilLoadOp and
|
|
pname:stencilStoreOp define how the stencil data is handled.
|
|
pname:loadOp and pname:stencilLoadOp define the _load operations_ that
|
|
execute as part of the first subpass that uses the attachment.
|
|
pname:storeOp and pname:stencilStoreOp define the _store operations_ that
|
|
execute as part of the last subpass that uses the attachment.
|
|
|
|
The load operation for each value in an attachment used by a subpass
|
|
happens-before any command recorded into that subpass reads from that value.
|
|
Load operations for attachments with a depth/stencil format execute in the
|
|
ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT pipeline stage.
|
|
Load operations for attachments with a color format execute in the
|
|
ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage.
|
|
|
|
Store operations for each value in an attachment used by a subpass
|
|
happen-after any command recorded into that subpass writes to that value.
|
|
Store operations for attachments with a depth/stencil format execute in the
|
|
ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT pipeline stage.
|
|
Store operations for attachments with a color format execute in the
|
|
ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage.
|
|
|
|
If an attachment is not used by any subpass, then pname:loadOp,
|
|
pname:storeOp, pname:stencilStoreOp, and pname:stencilLoadOp are ignored,
|
|
and the attachment's memory contents will not be modified by execution of a
|
|
render pass instance.
|
|
|
|
[[renderpass-precision]]
|
|
During a render pass instance, input/color attachments with color formats
|
|
that have a component size of 8, 16, or 32 bits must: be represented in the
|
|
attachment's format throughout the instance.
|
|
Attachments with other floating- or fixed-point color formats, or with depth
|
|
components may: be represented in a format with a precision higher than the
|
|
attachment format, but must: be represented with the same range.
|
|
When such a component is loaded via the pname:loadOp, it will be converted
|
|
into an implementation-dependent format used by the render pass.
|
|
Such components must: be converted from the render pass format, to the
|
|
format of the attachment, before they are resolved or stored at the end of a
|
|
render pass instance via pname:storeOp.
|
|
Conversions occur as described in <<fundamentals-numerics,Numeric
|
|
Representation and Computation>> and <<fundamentals-fixedconv, Fixed-Point
|
|
Data Conversions>>.
|
|
|
|
[[renderpass-aliasing]]
|
|
If pname:flags includes ename:VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT, then
|
|
the attachment is treated as if it shares physical memory with another
|
|
attachment in the same render pass.
|
|
This information limits the ability of the implementation to reorder certain
|
|
operations (like layout transitions and the pname:loadOp) such that it is
|
|
not improperly reordered against other uses of the same physical memory via
|
|
a different attachment.
|
|
This is described in more detail below.
|
|
|
|
.Valid Usage
|
|
****
|
|
* pname:finalLayout must: not be ename:VK_IMAGE_LAYOUT_UNDEFINED or
|
|
ename:VK_IMAGE_LAYOUT_PREINITIALIZED
|
|
****
|
|
|
|
include::../validity/structs/VkAttachmentDescription.txt[]
|
|
|
|
ifdef::editing-notes[]
|
|
[NOTE]
|
|
.editing-note
|
|
====
|
|
TODO (Jon) - the following text may need to be moved back to combine with
|
|
flink:vkCreateRenderPass above for automatic ref page generation.
|
|
====
|
|
endif::editing-notes[]
|
|
|
|
If a render pass uses multiple attachments that alias the same device
|
|
memory, those attachments must: each include the
|
|
ename:VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT bit in their attachment
|
|
description flags.
|
|
Attachments aliasing the same memory occurs in multiple ways:
|
|
|
|
* Multiple attachments being assigned the same image view as part of
|
|
framebuffer creation.
|
|
* Attachments using distinct image views that correspond to the same image
|
|
subresource of an image.
|
|
* Attachments using views of distinct image subresources which are bound
|
|
to overlapping memory ranges.
|
|
|
|
.Note
|
|
[NOTE]
|
|
====
|
|
Render passes must: include subpass dependencies (either directly or via a
|
|
subpass dependency chain) between any two subpasses that operate on the same
|
|
attachment or aliasing attachments and those subpass dependencies must:
|
|
include execution and memory dependencies separating uses of the aliases, if
|
|
at least one of those subpasses writes to one of the aliases.
|
|
These dependencies must: not include the ename:VK_DEPENDENCY_BY_REGION_BIT
|
|
if the aliases are views of distinct image subresources which overlap in
|
|
memory.
|
|
====
|
|
|
|
Multiple attachments that alias the same memory must: not be used in a
|
|
single subpass.
|
|
A given attachment index must: not be used multiple times in a single
|
|
subpass, with one exception: two subpass attachments can: use the same
|
|
attachment index if at least one use is as an input attachment and neither
|
|
use is as a resolve or preserve attachment.
|
|
In other words, the same view can: be used simultaneously as an input and
|
|
color or depth/stencil attachment, but must: not be used as multiple color
|
|
or depth/stencil attachments nor as resolve or preserve attachments.
|
|
The precise set of valid scenarios is described in more detail
|
|
<<renderpass-feedbackloop, below>>.
|
|
|
|
If a set of attachments alias each other, then all except the first to be
|
|
used in the render pass must: use an pname:initialLayout of
|
|
ename:VK_IMAGE_LAYOUT_UNDEFINED, since the earlier uses of the other aliases
|
|
make their contents undefined.
|
|
Once an alias has been used and a different alias has been used after it,
|
|
the first alias must: not be used in any later subpasses.
|
|
However, an application can: assign the same image view to multiple aliasing
|
|
attachment indices, which allows that image view to be used multiple times
|
|
even if other aliases are used in between.
|
|
|
|
[NOTE]
|
|
.Note
|
|
====
|
|
Once an attachment needs the ename:VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT
|
|
bit, there should: be no additional cost of introducing additional aliases,
|
|
and using these additional aliases may: allow more efficient clearing of the
|
|
attachments on multiple uses via ename:VK_ATTACHMENT_LOAD_OP_CLEAR.
|
|
====
|
|
|
|
// refBegin VkSubpassDescription Structure specifying a subpass description
|
|
|
|
The sname:VkSubpassDescription structure is defined as:
|
|
|
|
include::../api/structs/VkSubpassDescription.txt[]
|
|
|
|
* pname:flags is reserved for future use.
|
|
* pname:pipelineBindPoint is a elink:VkPipelineBindPoint value specifying
|
|
whether this is a compute or graphics subpass.
|
|
Currently, only graphics subpasses are supported.
|
|
* pname:inputAttachmentCount is the number of input attachments.
|
|
* pname:pInputAttachments is an array of slink:VkAttachmentReference
|
|
structures (defined below) that lists which of the render pass's
|
|
attachments can: be read in the shader during the subpass, and what
|
|
layout each attachment will be in during the subpass.
|
|
Each element of the array corresponds to an input attachment unit number
|
|
in the shader, i.e. if the shader declares an input variable
|
|
`layout(input_attachment_index=X, set=Y, binding=Z)` then it uses the
|
|
attachment provided in pname:pInputAttachments[X].
|
|
Input attachments must: also be bound to the pipeline with a descriptor
|
|
set, with the input attachment descriptor written in the location
|
|
(set=Y, binding=Z).
|
|
* pname:colorAttachmentCount is the number of color attachments.
|
|
* pname:pColorAttachments is an array of pname:colorAttachmentCount
|
|
slink:VkAttachmentReference structures that lists which of the render
|
|
pass's attachments will be used as color attachments in the subpass, and
|
|
what layout each attachment will be in during the subpass.
|
|
Each element of the array corresponds to a fragment shader output
|
|
location, i.e. if the shader declared an output variable
|
|
`layout(location=X)` then it uses the attachment provided in
|
|
pname:pColorAttachments[X].
|
|
* pname:pResolveAttachments is `NULL` or an array of
|
|
pname:colorAttachmentCount slink:VkAttachmentReference structures that
|
|
lists which of the render pass's attachments are resolved to at the end
|
|
of the subpass, and what layout each attachment will be in during the
|
|
multisample resolve operation.
|
|
If pname:pResolveAttachments is not `NULL`, each of its elements
|
|
corresponds to a color attachment (the element in
|
|
pname:pColorAttachments at the same index), and a multisample resolve
|
|
operation is defined for each attachment.
|
|
At the end of each subpass, multisample resolve operations read the
|
|
subpass's color attachments, and resolve the samples for each pixel to
|
|
the same pixel location in the corresponding resolve attachments, unless
|
|
the resolve attachment index is ename:VK_ATTACHMENT_UNUSED.
|
|
If the first use of an attachment in a render pass is as a resolve
|
|
attachment, then the pname:loadOp is effectively ignored as the resolve
|
|
is guaranteed to overwrite all pixels in the render area.
|
|
* pname:pDepthStencilAttachment is a pointer to a
|
|
slink:VkAttachmentReference specifying which attachment will be used for
|
|
depth/stencil data and the layout it will be in during the subpass.
|
|
Setting the attachment index to ename:VK_ATTACHMENT_UNUSED or leaving
|
|
this pointer as `NULL` indicates that no depth/stencil attachment will
|
|
be used in the subpass.
|
|
* pname:preserveAttachmentCount is the number of preserved attachments.
|
|
* pname:pPreserveAttachments is an array of pname:preserveAttachmentCount
|
|
render pass attachment indices describing the attachments that are not
|
|
used by a subpass, but whose contents must: be preserved throughout the
|
|
subpass.
|
|
|
|
The contents of an attachment within the render area become undefined at the
|
|
start of a subpass *S* if all of the following conditions are true:
|
|
|
|
* The attachment is used as a color, depth/stencil, or resolve attachment
|
|
in any subpass in the render pass.
|
|
* There is a subpass *S~1~* that uses or preserves the attachment, and a
|
|
subpass dependency from *S~1~* to *S*.
|
|
* The attachment is not used or preserved in subpass *S*.
|
|
|
|
Once the contents of an attachment become undefined in subpass *S*, they
|
|
remain undefined for subpasses in subpass dependency chains starting with
|
|
subpass *S* until they are written again.
|
|
However, they remain valid for subpasses in other subpass dependency chains
|
|
starting with subpass *S~1~* if those subpasses use or preserve the
|
|
attachment.
|
|
|
|
.Valid Usage
|
|
****
|
|
* pname:pipelineBindPoint must: be ename:VK_PIPELINE_BIND_POINT_GRAPHICS
|
|
* pname:colorAttachmentCount must: be less than or equal to
|
|
sname:VkPhysicalDeviceLimits::pname:maxColorAttachments
|
|
* If the first use of an attachment in this render pass is as an input
|
|
attachment, and the attachment is not also used as a color or
|
|
depth/stencil attachment in the same subpass, then pname:loadOp must:
|
|
not be ename:VK_ATTACHMENT_LOAD_OP_CLEAR
|
|
* If pname:pResolveAttachments is not `NULL`, for each resolve attachment
|
|
that does not have the value ename:VK_ATTACHMENT_UNUSED, the
|
|
corresponding color attachment must: not have the value
|
|
ename:VK_ATTACHMENT_UNUSED
|
|
* If pname:pResolveAttachments is not `NULL`, the sample count of each
|
|
element of pname:pColorAttachments must: be anything other than
|
|
ename:VK_SAMPLE_COUNT_1_BIT
|
|
* Any given element of pname:pResolveAttachments must: have a sample count
|
|
of ename:VK_SAMPLE_COUNT_1_BIT
|
|
* Any given element of pname:pResolveAttachments must: have the same
|
|
elink:VkFormat as its corresponding color attachment
|
|
* All attachments in pname:pColorAttachments and
|
|
pname:pDepthStencilAttachment that are not ename:VK_ATTACHMENT_UNUSED
|
|
must: have the same sample count
|
|
* If any input attachments are ename:VK_ATTACHMENT_UNUSED, then any
|
|
pipelines bound during the subpass must: not access those input
|
|
attachments from the fragment shader
|
|
* The pname:attachment member of any element of pname:pPreserveAttachments
|
|
must: not be ename:VK_ATTACHMENT_UNUSED
|
|
* Any given element of pname:pPreserveAttachments must: not also be an
|
|
element of any other member of the subpass description
|
|
* If any attachment is used as both an input attachment and a color or
|
|
depth/stencil attachment, then each use must: use the same pname:layout
|
|
****
|
|
|
|
include::../validity/structs/VkSubpassDescription.txt[]
|
|
|
|
// refBegin VkAttachmentReference Structure specifying an attachment reference
|
|
|
|
The sname:VkAttachmentReference structure is defined as:
|
|
|
|
include::../api/structs/VkAttachmentReference.txt[]
|
|
|
|
* pname:attachment is the index of the attachment of the render pass, and
|
|
corresponds to the index of the corresponding element in the
|
|
pname:pAttachments array of the sname:VkRenderPassCreateInfo structure.
|
|
If any color or depth/stencil attachments are
|
|
ename:VK_ATTACHMENT_UNUSED, then no writes occur for those attachments.
|
|
* pname:layout is a elink:VkImageLayout value specifying the layout the
|
|
attachment uses during the subpass.
|
|
|
|
.Valid Usage
|
|
****
|
|
* pname:layout must: not be ename:VK_IMAGE_LAYOUT_UNDEFINED or
|
|
ename:VK_IMAGE_LAYOUT_PREINITIALIZED
|
|
****
|
|
|
|
include::../validity/structs/VkAttachmentReference.txt[]
|
|
|
|
// refBegin VkSubpassDependency Structure specifying a subpass dependency
|
|
|
|
The sname:VkSubpassDependency structure is defined as:
|
|
|
|
include::../api/structs/VkSubpassDependency.txt[]
|
|
|
|
* pname:srcSubpass is the subpass index of the first subpass in the
|
|
dependency, or ename:VK_SUBPASS_EXTERNAL.
|
|
* pname:dstSubpass is the subpass index of the second subpass in the
|
|
dependency, or ename:VK_SUBPASS_EXTERNAL.
|
|
* pname:srcStageMask defines a <<synchronization-pipeline-stages-masks,
|
|
source stage mask>>.
|
|
* pname:dstStageMask defines a <<synchronization-pipeline-stages-masks,
|
|
destination stage mask>>.
|
|
* pname:srcAccessMask defines a <<synchronization-access-masks, source
|
|
access mask>>.
|
|
* pname:dstAccessMask defines a <<synchronization-access-masks,
|
|
destination access mask>>.
|
|
* pname:dependencyFlags is a bitmask of elink:VkDependencyFlagBits.
|
|
|
|
If pname:srcSubpass is equal to pname:dstSubpass then the
|
|
slink:VkSubpassDependency describes a
|
|
<<synchronization-pipeline-barriers-subpass-self-dependencies, subpass
|
|
self-dependency>>, and only constrains the pipeline barriers allowed within
|
|
a subpass instance.
|
|
Otherwise, when a render pass instance which includes a subpass dependency
|
|
is submitted to a queue, it defines a memory dependency between the
|
|
subpasses identified by pname:srcSubpass and pname:dstSubpass.
|
|
|
|
If pname:srcSubpass is equal to ename:VK_SUBPASS_EXTERNAL, the first
|
|
<<synchronization-dependencies-scopes, synchronization scope>> includes
|
|
commands submitted to the queue before the render pass instance began.
|
|
Otherwise, the first set of commands includes all commands submitted as part
|
|
of the subpass instance identified by pname:srcSubpass and any load, store
|
|
or multisample resolve operations on attachments used in pname:srcSubpass.
|
|
In either case, the first synchronization scope is limited to operations on
|
|
the pipeline stages determined by the
|
|
<<synchronization-pipeline-stages-masks, source stage mask>> specified by
|
|
pname:srcStageMask.
|
|
|
|
If pname:dstSubpass is equal to ename:VK_SUBPASS_EXTERNAL, the second
|
|
<<synchronization-dependencies-scopes, synchronization scope>> includes
|
|
commands submitted after the render pass instance is ended.
|
|
Otherwise, the second set of commands includes all commands submitted as
|
|
part of the subpass instance identified by pname:dstSubpass and any load,
|
|
store or multisample resolve operations on attachments used in
|
|
pname:dstSubpass.
|
|
In either case, the second synchronization scope is limited to operations on
|
|
the pipeline stages determined by the
|
|
<<synchronization-pipeline-stages-masks, destination stage mask>> specified
|
|
by pname:dstStageMask.
|
|
|
|
The first <<synchronization-dependencies-access-scopes, access scope>> is
|
|
limited to access in the pipeline stages determined by the
|
|
<<synchronization-pipeline-stages-masks, source stage mask>> specified by
|
|
pname:srcStageMask.
|
|
It is also limited to access types in the <<synchronization-access-masks,
|
|
source access mask>> specified by pname:srcAccessMask.
|
|
|
|
The second <<synchronization-dependencies-access-scopes, access scope>> is
|
|
limited to access in the pipeline stages determined by the
|
|
<<synchronization-pipeline-stages-masks, destination stage mask>> specified
|
|
by pname:dstStageMask.
|
|
It is also limited to access types in the <<synchronization-access-masks,
|
|
destination access mask>> specified by pname:dstAccessMask.
|
|
|
|
The <<synchronization-dependencies-available-and-visible, availability and
|
|
visibility operations>> defined by a subpass dependency affect the execution
|
|
of <<renderpass-layout-transitions, image layout transitions>> within the
|
|
render pass.
|
|
|
|
.Valid Usage
|
|
****
|
|
* If pname:srcSubpass is not ename:VK_SUBPASS_EXTERNAL, pname:srcStageMask
|
|
must: not include ename:VK_PIPELINE_STAGE_HOST_BIT
|
|
* If pname:dstSubpass is not ename:VK_SUBPASS_EXTERNAL, pname:dstStageMask
|
|
must: not include ename:VK_PIPELINE_STAGE_HOST_BIT
|
|
* If the <<features-features-geometryShader,geometry shaders>> feature is
|
|
not enabled, pname:srcStageMask must: not contain
|
|
ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
|
|
* If the <<features-features-geometryShader,geometry shaders>> feature is
|
|
not enabled, pname:dstStageMask must: not contain
|
|
ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
|
|
* If the <<features-features-tessellationShader,tessellation shaders>>
|
|
feature is not enabled, pname:srcStageMask must: not contain
|
|
ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT or
|
|
ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
|
|
* If the <<features-features-tessellationShader,tessellation shaders>>
|
|
feature is not enabled, pname:dstStageMask must: not contain
|
|
ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT or
|
|
ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
|
|
* pname:srcSubpass must: be less than or equal to pname:dstSubpass, unless
|
|
one of them is ename:VK_SUBPASS_EXTERNAL, to avoid cyclic dependencies
|
|
and ensure a valid execution order
|
|
* pname:srcSubpass and pname:dstSubpass must: not both be equal to
|
|
ename:VK_SUBPASS_EXTERNAL
|
|
* If pname:srcSubpass is equal to pname:dstSubpass, pname:srcStageMask and
|
|
pname:dstStageMask must: only contain one of
|
|
ename:VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
|
ename:VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT,
|
|
ename:VK_PIPELINE_STAGE_VERTEX_INPUT_BIT,
|
|
ename:VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
|
|
ename:VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT,
|
|
ename:VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT,
|
|
ename:VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT,
|
|
ename:VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
|
ename:VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
|
ename:VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
|
ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
ename:VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, or
|
|
ename:VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT
|
|
* If pname:srcSubpass is equal to pname:dstSubpass, the
|
|
<<synchronization-pipeline-stages-order, logically latest>> pipeline
|
|
stage in pname:srcStageMask must: be
|
|
<<synchronization-pipeline-stages-order, logically earlier>> than or
|
|
equal to the <<synchronization-pipeline-stages-order, logically
|
|
earliest>> pipeline stage in pname:dstStageMask
|
|
* Any access flag included in pname:srcAccessMask must: be supported by
|
|
one of the pipeline stages in pname:srcStageMask, as specified in the
|
|
<<synchronization-access-types-supported, table of supported access
|
|
types>>.
|
|
* Any access flag included in pname:dstAccessMask must: be supported by
|
|
one of the pipeline stages in pname:dstStageMask, as specified in the
|
|
<<synchronization-access-types-supported, table of supported access
|
|
types>>.
|
|
****
|
|
|
|
include::../validity/structs/VkSubpassDependency.txt[]
|
|
|
|
ifdef::editing-notes[]
|
|
[NOTE]
|
|
.editing-note
|
|
====
|
|
The following two alleged implicit dependencies are practically no-ops, as
|
|
the operations they describe are already guaranteed by semaphores and
|
|
submission order (so they're almost entirely no-ops on their own).
|
|
The *only* reason they exist is because it simplifies reasoning about where
|
|
<<renderpass-layout-transitions, automatic layout transitions>> happen.
|
|
Further rewrites of this chapter could potentially remove the need for
|
|
these.
|
|
====
|
|
endif::editing-notes[]
|
|
|
|
If there is no subpass dependency from ename:VK_SUBPASS_EXTERNAL to the
|
|
first subpass that uses an attachment, then an implicit subpass dependency
|
|
exists from ename:VK_SUBPASS_EXTERNAL to the first subpass it is used in.
|
|
The subpass dependency operates as if defined with the following parameters:
|
|
|
|
[source,c]
|
|
----
|
|
VkSubpassDependency implicitDependency = {
|
|
.srcSubpass = VK_SUBPASS_EXTERNAL;
|
|
.dstSubpass = firstSubpass; // First subpass attachment is used in
|
|
.srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
|
.dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
|
.srcAccessMask = 0;
|
|
.dstAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
|
|
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
|
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
|
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
.dependencyFlags = 0;
|
|
};
|
|
----
|
|
|
|
Similarly, if there is no subpass dependency from the last subpass that uses
|
|
an attachment to ename:VK_SUBPASS_EXTERNAL, then an implicit subpass
|
|
dependency exists from the last subpass it is used in to
|
|
ename:VK_SUBPASS_EXTERNAL.
|
|
The subpass dependency operates as if defined with the following parameters:
|
|
|
|
[source,c]
|
|
----
|
|
VkSubpassDependency implicitDependency = {
|
|
.srcSubpass = lastSubpass; // Last subpass attachment is used in
|
|
.dstSubpass = VK_SUBPASS_EXTERNAL;
|
|
.srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
|
.dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
|
.srcAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
|
|
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
|
|
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
|
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
.dstAccessMask = 0;
|
|
.dependencyFlags = 0;
|
|
};
|
|
----
|
|
|
|
[[renderpass-layout-transitions]]
|
|
As subpasses may: overlap or execute out of order with regards to other
|
|
subpasses unless a subpass dependency chain describes otherwise, the layout
|
|
transitions required between subpasses cannot: be known to an application.
|
|
Instead, an application provides the layout that each attachment must: be in
|
|
at the start and end of a renderpass, and the layout it must: be in during
|
|
each subpass it is used in.
|
|
The implementation then must: execute layout transitions between subpasses
|
|
in order to guarantee that the images are in the layouts required by each
|
|
subpass, and in the final layout at the end of the render pass.
|
|
|
|
Automatic layout transitions away from the layout used in a subpass
|
|
happen-after the availability operations for all dependencies with that
|
|
subpass as the pname:srcSubpass.
|
|
|
|
Automatic layout transitions into the layout used in a subpass happen-before
|
|
the visibility operations for all dependencies with that subpass as the
|
|
pname:dstSubpass.
|
|
|
|
Automatic layout transitions away from pname:initialLayout happens-after the
|
|
availability operations for all dependencies with a pname:srcSubpass equal
|
|
to ename:VK_SUBPASS_EXTERNAL, where pname:dstSubpass uses the attachment
|
|
that will be transitioned.
|
|
For attachments created with ename:VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT,
|
|
automatic layout transitions away from pname:initialLayout happen-after the
|
|
availability operations for all dependencies with a pname:srcSubpass equal
|
|
to ename:VK_SUBPASS_EXTERNAL, where pname:dstSubpass uses any aliased
|
|
attachment.
|
|
|
|
Automatic layout transitions into pname:finalLayout happens-before the
|
|
visibility operations for all dependencies with a pname:dstSubpass equal to
|
|
ename:VK_SUBPASS_EXTERNAL, where pname:srcSubpass uses the attachment that
|
|
will be transitioned.
|
|
For attachments created with ename:VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT,
|
|
automatic layout transitions into pname:finalLayout happen-before the
|
|
visibility operations for all dependencies with a pname:dstSubpass equal to
|
|
ename:VK_SUBPASS_EXTERNAL, where pname:srcSubpass uses any aliased
|
|
attachment.
|
|
|
|
If two subpasses use the same attachment in different layouts, and both
|
|
layouts are read-only, no subpass dependency needs to be specified between
|
|
those subpasses.
|
|
If an implementation treats those layouts separately, it must: insert an
|
|
implicit subpass dependency between those subpasses to separate the uses in
|
|
each layout.
|
|
The subpass dependency operates as if defined with the following parameters:
|
|
|
|
[source,c]
|
|
----
|
|
// Used for input attachments
|
|
VkPipelineStageFlags inputAttachmentStages = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
|
VkAccessFlags inputAttachmentAccess = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
|
|
|
|
// Used for depth stencil attachments
|
|
VkPipelineStageFlags depthStencilAttachmentStages = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
|
VkAccessFlags depthStencilAttachmentAccess = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
|
|
|
|
VkSubpassDependency implicitDependency = {
|
|
.srcSubpass = firstSubpass;
|
|
.dstSubpass = secondSubpass;
|
|
.srcStageMask = inputAttachmentStages | depthStencilAttachmentStages;
|
|
.dstStageMask = inputAttachmentStages | depthStencilAttachmentStages;
|
|
.srcAccessMask = inputAttachmentAccess | depthStencilAttachmentAccess;
|
|
.dstAccessMask = inputAttachmentAccess | depthStencilAttachmentAccess;
|
|
.dependencyFlags = 0;
|
|
};
|
|
----
|
|
|
|
[[renderpass-feedbackloop]]
|
|
If a subpass uses the same attachment as both an input attachment and either
|
|
a color attachment or a depth/stencil attachment, writes via the color or
|
|
depth/stencil attachment are not automatically made visible to reads via the
|
|
input attachment, causing a _feedback loop_, except in any of the following
|
|
conditions:
|
|
|
|
* If the color components or depth/stencil components read by the input
|
|
attachment are mutually exclusive with the components written by the
|
|
color or depth/stencil attachments, then there is no feedback loop.
|
|
This requires the graphics pipelines used by the subpass to disable
|
|
writes to color components that are read as inputs via the
|
|
pname:colorWriteMask, and to disable writes to depth/stencil components
|
|
that are read as inputs via pname:depthWriteEnable or
|
|
pname:stencilTestEnable.
|
|
* If the attachment is used as an input attachment and depth/stencil
|
|
attachment only, and the depth/stencil attachment is not written to.
|
|
* If a memory dependency is inserted between when the attachment is
|
|
written and when it is subsequently read by later fragments.
|
|
<<synchronization-pipeline-barriers, Pipeline barriers>> expressing a
|
|
<<synchronization-pipeline-barriers-subpass-self-dependencies, subpass
|
|
self-dependency>> are the only way to achieve this, and one must: be
|
|
inserted every time a fragment will read values at a particular sample
|
|
(x, y, layer, sample) coordinate, if those values have been written
|
|
since the most recent pipeline barrier; or the since start of the
|
|
subpass if there have been no pipeline barriers since the start of the
|
|
subpass.
|
|
|
|
An attachment used as both an input attachment and a color attachment must:
|
|
be in the ename:VK_IMAGE_LAYOUT_GENERAL layout.
|
|
An attachment used as an input attachment and depth/stencil attachment must:
|
|
be in either ename:VK_IMAGE_LAYOUT_GENERAL or
|
|
ename:VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL.
|
|
An attachment must: not be used as both a depth/stencil attachment and a
|
|
color attachment.
|
|
|
|
// refBegin vkDestroyRenderPass Destroy a render pass object
|
|
|
|
To destroy a render pass, call:
|
|
|
|
include::../api/protos/vkDestroyRenderPass.txt[]
|
|
|
|
* pname:device is the logical device that destroys the render pass.
|
|
* pname:renderPass is the handle of the render pass to destroy.
|
|
* pname:pAllocator controls host memory allocation as described in the
|
|
<<memory-allocation, Memory Allocation>> chapter.
|
|
|
|
.Valid Usage
|
|
****
|
|
* All submitted commands that refer to pname:renderPass must: have
|
|
completed execution
|
|
* If sname:VkAllocationCallbacks were provided when pname:renderPass was
|
|
created, a compatible set of callbacks must: be provided here
|
|
* If no sname:VkAllocationCallbacks were provided when pname:renderPass
|
|
was created, pname:pAllocator must: be `NULL`
|
|
****
|
|
|
|
include::../validity/protos/vkDestroyRenderPass.txt[]
|
|
|
|
|
|
[[renderpass-compatibility]]
|
|
== Render Pass Compatibility
|
|
|
|
Framebuffers and graphics pipelines are created based on a specific render
|
|
pass object.
|
|
They must: only be used with that render pass object, or one compatible with
|
|
it.
|
|
|
|
Two attachment references are compatible if they have matching format and
|
|
sample count, or are both ename:VK_ATTACHMENT_UNUSED or the pointer that
|
|
would contain the reference is `NULL`.
|
|
|
|
Two arrays of attachment references are compatible if all corresponding
|
|
pairs of attachments are compatible.
|
|
If the arrays are of different lengths, attachment references not present in
|
|
the smaller array are treated as ename:VK_ATTACHMENT_UNUSED.
|
|
|
|
Two render passes that contain only a single subpass are compatible if their
|
|
corresponding color, input, resolve, and depth/stencil attachment references
|
|
are compatible.
|
|
|
|
If two render passes contain more than one subpass, they are compatible if
|
|
they are identical except for:
|
|
|
|
* Initial and final image layout in attachment descriptions
|
|
* Load and store operations in attachment descriptions
|
|
* Image layout in attachment references
|
|
|
|
A framebuffer is compatible with a render pass if it was created using the
|
|
same render pass or a compatible render pass.
|
|
|
|
|
|
== Framebuffers
|
|
|
|
// refBegin VkFramebuffer Opaque handle to a framebuffer object
|
|
|
|
Render passes operate in conjunction with _framebuffers_.
|
|
Framebuffers represent a collection of specific memory attachments that a
|
|
render pass instance uses.
|
|
|
|
Framebuffers are represented by sname:VkFramebuffer handles:
|
|
|
|
include::../api/handles/VkFramebuffer.txt[]
|
|
|
|
// refEnd VkFramebuffer
|
|
|
|
// refBegin vkCreateFramebuffer Create a new framebuffer object
|
|
|
|
To create a framebuffer, call:
|
|
|
|
include::../api/protos/vkCreateFramebuffer.txt[]
|
|
|
|
* pname:device is the logical device that creates the framebuffer.
|
|
* pname:pCreateInfo points to a slink:VkFramebufferCreateInfo structure
|
|
which describes additional information about framebuffer creation.
|
|
* pname:pAllocator controls host memory allocation as described in the
|
|
<<memory-allocation, Memory Allocation>> chapter.
|
|
* pname:pFramebuffer points to a sname:VkFramebuffer handle in which the
|
|
resulting framebuffer object is returned.
|
|
|
|
include::../validity/protos/vkCreateFramebuffer.txt[]
|
|
|
|
// refBegin VkFramebufferCreateInfo Structure specifying parameters of a newly created framebuffer
|
|
|
|
The sname:VkFramebufferCreateInfo structure is defined as:
|
|
|
|
include::../api/structs/VkFramebufferCreateInfo.txt[]
|
|
|
|
* pname:sType is the type of this structure.
|
|
* pname:pNext is `NULL` or a pointer to an extension-specific structure.
|
|
* pname:flags is reserved for future use.
|
|
* pname:renderPass is a render pass that defines what render passes the
|
|
framebuffer will be compatible with.
|
|
See <<renderpass-compatibility,Render Pass Compatibility>> for details.
|
|
* pname:attachmentCount is the number of attachments.
|
|
* pname:pAttachments is an array of sname:VkImageView handles, each of
|
|
which will be used as the corresponding attachment in a render pass
|
|
instance.
|
|
* pname:width, pname:height and pname:layers define the dimensions of the
|
|
framebuffer.
|
|
|
|
Image subresources used as attachments must: not be used via any
|
|
non-attachment usage for the duration of a render pass instance.
|
|
|
|
[NOTE]
|
|
.Note
|
|
====
|
|
This restriction means that the render pass has full knowledge of all uses
|
|
of all of the attachments, so that the implementation is able to make
|
|
correct decisions about when and how to perform layout transitions, when to
|
|
overlap execution of subpasses, etc.
|
|
====
|
|
|
|
[[renderpass-noattachments]]
|
|
It is legal for a subpass to use no color or depth/stencil attachments, and
|
|
rather use shader side effects such as image stores and atomics to produce
|
|
an output.
|
|
In this case, the subpass continues to use the pname:width, pname:height,
|
|
and pname:layers of the framebuffer to define the dimensions of the
|
|
rendering area, and the pname:rasterizationSamples from each pipeline's
|
|
slink:VkPipelineMultisampleStateCreateInfo to define the number of samples
|
|
used in rasterization; however, if
|
|
slink:VkPhysicalDeviceFeatures::pname:variableMultisampleRate is
|
|
code:VK_FALSE, then all pipelines to be bound with a given zero-attachment
|
|
subpass must: have the same value for
|
|
slink:VkPipelineMultisampleStateCreateInfo::pname:rasterizationSamples.
|
|
|
|
.Valid Usage
|
|
****
|
|
* pname:attachmentCount must: be equal to the attachment count specified
|
|
in pname:renderPass
|
|
* Any given element of pname:pAttachments that is used as a color
|
|
attachment or resolve attachment by pname:renderPass must: have been
|
|
created with a pname:usage value including
|
|
ename:VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
|
* Any given element of pname:pAttachments that is used as a depth/stencil
|
|
attachment by pname:renderPass must: have been created with a
|
|
pname:usage value including
|
|
ename:VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
|
|
* Any given element of pname:pAttachments that is used as an input
|
|
attachment by pname:renderPass must: have been created with a
|
|
pname:usage value including ename:VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
|
|
* Any given element of pname:pAttachments must: have been created with an
|
|
elink:VkFormat value that matches the elink:VkFormat specified by the
|
|
corresponding sname:VkAttachmentDescription in pname:renderPass
|
|
* Any given element of pname:pAttachments must: have been created with a
|
|
pname:samples value that matches the pname:samples value specified by
|
|
the corresponding sname:VkAttachmentDescription in pname:renderPass
|
|
* Any given element of pname:pAttachments must: have dimensions at least
|
|
as large as the corresponding framebuffer dimension
|
|
* Any given element of pname:pAttachments must: only specify a single mip
|
|
level
|
|
* Any given element of pname:pAttachments must: have been created with the
|
|
identity swizzle
|
|
* pname:width must: be less than or equal to
|
|
sname:VkPhysicalDeviceLimits::pname:maxFramebufferWidth
|
|
* pname:height must: be less than or equal to
|
|
sname:VkPhysicalDeviceLimits::pname:maxFramebufferHeight
|
|
* pname:layers must: be less than or equal to
|
|
sname:VkPhysicalDeviceLimits::pname:maxFramebufferLayers
|
|
ifdef::VK_KHR_maintenance1[]
|
|
* Any given element of pname:pAttachments that is a 2D or 2D array image
|
|
view taken from a 3D image must: not be a depth/stencil format
|
|
endif::VK_KHR_maintenance1[]
|
|
****
|
|
|
|
include::../validity/structs/VkFramebufferCreateInfo.txt[]
|
|
|
|
// refBegin vkDestroyFramebuffer Destroy a framebuffer object
|
|
|
|
To destroy a framebuffer, call:
|
|
|
|
include::../api/protos/vkDestroyFramebuffer.txt[]
|
|
|
|
* pname:device is the logical device that destroys the framebuffer.
|
|
* pname:framebuffer is the handle of the framebuffer to destroy.
|
|
* pname:pAllocator controls host memory allocation as described in the
|
|
<<memory-allocation, Memory Allocation>> chapter.
|
|
|
|
.Valid Usage
|
|
****
|
|
* All submitted commands that refer to pname:framebuffer must: have
|
|
completed execution
|
|
* If sname:VkAllocationCallbacks were provided when pname:framebuffer was
|
|
created, a compatible set of callbacks must: be provided here
|
|
* If no sname:VkAllocationCallbacks were provided when pname:framebuffer
|
|
was created, pname:pAllocator must: be `NULL`
|
|
****
|
|
|
|
include::../validity/protos/vkDestroyFramebuffer.txt[]
|
|
|
|
|
|
[[renderpass-commands]]
|
|
== Render Pass Commands
|
|
|
|
An application records the commands for a render pass instance one subpass
|
|
at a time, by beginning a render pass instance, iterating over the subpasses
|
|
to record commands for that subpass, and then ending the render pass
|
|
instance.
|
|
|
|
// refBegin vkCmdBeginRenderPass Begin a new render pass
|
|
|
|
To begin a render pass instance, call:
|
|
|
|
include::../api/protos/vkCmdBeginRenderPass.txt[]
|
|
|
|
* pname:commandBuffer is the command buffer in which to record the
|
|
command.
|
|
* pname:pRenderPassBegin is a pointer to a slink:VkRenderPassBeginInfo
|
|
structure (defined below) which indicates the render pass to begin an
|
|
instance of, and the framebuffer the instance uses.
|
|
* pname:contents specifies how the commands in the first subpass will be
|
|
provided, and is one of the values:
|
|
+
|
|
--
|
|
// refBegin VkSubpassContents Specify how commands in the first subpass of a render pass are provided
|
|
include::../api/enums/VkSubpassContents.txt[]
|
|
--
|
|
+
|
|
If pname:contents is ename:VK_SUBPASS_CONTENTS_INLINE, the contents of the
|
|
subpass will be recorded inline in the primary command buffer, and secondary
|
|
command buffers must: not be executed within the subpass.
|
|
If pname:contents is ename:VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS,
|
|
the contents are recorded in secondary command buffers that will be called
|
|
from the primary command buffer, and fname:vkCmdExecuteCommands is the only
|
|
valid command on the command buffer until fname:vkCmdNextSubpass or
|
|
fname:vkCmdEndRenderPass.
|
|
|
|
After beginning a render pass instance, the command buffer is ready to
|
|
record the commands for the first subpass of that render pass.
|
|
|
|
.Valid Usage
|
|
****
|
|
* If any of the pname:initialLayout or pname:finalLayout member of the
|
|
sname:VkAttachmentDescription structures or the pname:layout member of
|
|
the sname:VkAttachmentReference structures specified when creating the
|
|
render pass specified in the pname:renderPass member of
|
|
pname:pRenderPassBegin is ename:VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
|
then the corresponding attachment image subresource of the framebuffer
|
|
specified in the pname:framebuffer member of pname:pRenderPassBegin
|
|
must: have been created with ename:VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
|
set
|
|
* If any of the pname:initialLayout or pname:finalLayout member of the
|
|
sname:VkAttachmentDescription structures or the pname:layout member of
|
|
the sname:VkAttachmentReference structures specified when creating the
|
|
render pass specified in the pname:renderPass member of
|
|
pname:pRenderPassBegin is
|
|
ename:VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL or
|
|
ename:VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL then the
|
|
corresponding attachment image subresource of the framebuffer specified
|
|
in the pname:framebuffer member of pname:pRenderPassBegin must: have
|
|
been created with ename:VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT set
|
|
* If any of the pname:initialLayout or pname:finalLayout member of the
|
|
sname:VkAttachmentDescription structures or the pname:layout member of
|
|
the sname:VkAttachmentReference structures specified when creating the
|
|
render pass specified in the pname:renderPass member of
|
|
pname:pRenderPassBegin is ename:VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
|
then the corresponding attachment image subresource of the framebuffer
|
|
specified in the pname:framebuffer member of pname:pRenderPassBegin
|
|
must: have been created with ename:VK_IMAGE_USAGE_SAMPLED_BIT or
|
|
ename:VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set
|
|
* If any of the pname:initialLayout or pname:finalLayout member of the
|
|
sname:VkAttachmentDescription structures or the pname:layout member of
|
|
the sname:VkAttachmentReference structures specified when creating the
|
|
render pass specified in the pname:renderPass member of
|
|
pname:pRenderPassBegin is ename:VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
|
|
then the corresponding attachment image subresource of the framebuffer
|
|
specified in the pname:framebuffer member of pname:pRenderPassBegin
|
|
must: have been created with ename:VK_IMAGE_USAGE_TRANSFER_SRC_BIT set
|
|
* If any of the pname:initialLayout or pname:finalLayout member of the
|
|
sname:VkAttachmentDescription structures or the pname:layout member of
|
|
the sname:VkAttachmentReference structures specified when creating the
|
|
render pass specified in the pname:renderPass member of
|
|
pname:pRenderPassBegin is ename:VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
|
|
then the corresponding attachment image subresource of the framebuffer
|
|
specified in the pname:framebuffer member of pname:pRenderPassBegin
|
|
must: have been created with ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT set
|
|
* If any of the pname:initialLayout members of the
|
|
sname:VkAttachmentDescription structures specified when creating the
|
|
render pass specified in the pname:renderPass member of
|
|
pname:pRenderPassBegin is not ename:VK_IMAGE_LAYOUT_UNDEFINED, then each
|
|
such pname:initialLayout must: be equal to the current layout of the
|
|
corresponding attachment image subresource of the framebuffer specified
|
|
in the pname:framebuffer member of pname:pRenderPassBegin
|
|
* The pname:srcStageMask and pname:dstStageMask members of any element of
|
|
the pname:pDependencies member of slink:VkRenderPassCreateInfo used to
|
|
create pname:renderpass must: be supported by the capabilities of the
|
|
queue family identified by the pname:queueFamilyIndex member of the
|
|
slink:VkCommandPoolCreateInfo used to create the command pool which
|
|
pname:commandBuffer was allocated from.
|
|
****
|
|
|
|
include::../validity/protos/vkCmdBeginRenderPass.txt[]
|
|
|
|
// refBegin VkRenderPassBeginInfo Structure specifying render pass begin info
|
|
|
|
The sname:VkRenderPassBeginInfo structure is defined as:
|
|
|
|
include::../api/structs/VkRenderPassBeginInfo.txt[]
|
|
|
|
* pname:sType is the type of this structure.
|
|
* pname:pNext is `NULL` or a pointer to an extension-specific structure.
|
|
* pname:renderPass is the render pass to begin an instance of.
|
|
* pname:framebuffer is the framebuffer containing the attachments that are
|
|
used with the render pass.
|
|
* pname:renderArea is the render area that is affected by the render pass
|
|
instance, and is described in more detail below.
|
|
* pname:clearValueCount is the number of elements in pname:pClearValues.
|
|
* pname:pClearValues is an array of slink:VkClearValue structures that
|
|
contains clear values for each attachment, if the attachment uses a
|
|
pname:loadOp value of ename:VK_ATTACHMENT_LOAD_OP_CLEAR or if the
|
|
attachment has a depth/stencil format and uses a pname:stencilLoadOp
|
|
value of ename:VK_ATTACHMENT_LOAD_OP_CLEAR.
|
|
The array is indexed by attachment number.
|
|
Only elements corresponding to cleared attachments are used.
|
|
Other elements of pname:pClearValues are ignored.
|
|
|
|
pname:renderArea is the render area that is affected by the render pass
|
|
instance.
|
|
The effects of attachment load, store and multisample resolve operations are
|
|
restricted to the pixels whose x and y coordinates fall within the render
|
|
area on all attachments.
|
|
The render area extends to all layers of pname:framebuffer.
|
|
The application must: ensure (using scissor if necessary) that all rendering
|
|
is contained within the render area, otherwise the pixels outside of the
|
|
render area become undefined and shader side effects may: occur for
|
|
fragments outside the render area.
|
|
The render area must: be contained within the framebuffer dimensions.
|
|
|
|
[NOTE]
|
|
.Note
|
|
====
|
|
There may: be a performance cost for using a render area smaller than the
|
|
framebuffer, unless it matches the render area granularity for the render
|
|
pass.
|
|
====
|
|
|
|
.Valid Usage
|
|
****
|
|
* pname:clearValueCount must: be greater than the largest attachment index
|
|
in pname:renderPass that specifies a pname:loadOp (or
|
|
pname:stencilLoadOp, if the attachment has a depth/stencil format) of
|
|
ename:VK_ATTACHMENT_LOAD_OP_CLEAR
|
|
* If pname:clearValueCount is not `0`, pname:pClearValues must: be a
|
|
pointer to an array of pname:clearValueCount valid sname:VkClearValue
|
|
unions
|
|
* pname:renderPass must: be <<renderpass-compatibility,compatible>> with
|
|
the pname:renderPass member of the sname:VkFramebufferCreateInfo
|
|
structure specified when creating pname:framebuffer.
|
|
****
|
|
|
|
include::../validity/structs/VkRenderPassBeginInfo.txt[]
|
|
|
|
// refBegin vkGetRenderAreaGranularity Returns the granularity for optimal render area
|
|
|
|
To query the render area granularity, call:
|
|
|
|
include::../api/protos/vkGetRenderAreaGranularity.txt[]
|
|
|
|
* pname:device is the logical device that owns the render pass.
|
|
* pname:renderPass is a handle to a render pass.
|
|
* pname:pGranularity points to a slink:VkExtent2D structure in which the
|
|
granularity is returned.
|
|
|
|
The conditions leading to an optimal pname:renderArea are:
|
|
|
|
* the pname:offset.x member in pname:renderArea is a multiple of the
|
|
pname:width member of the returned slink:VkExtent2D (the horizontal
|
|
granularity).
|
|
* the pname:offset.y member in pname:renderArea is a multiple of the
|
|
pname:height of the returned slink:VkExtent2D (the vertical
|
|
granularity).
|
|
* either the pname:offset.width member in pname:renderArea is a multiple
|
|
of the horizontal granularity or pname:offset.x+pname:offset.width is
|
|
equal to the pname:width of the pname:framebuffer in the
|
|
slink:VkRenderPassBeginInfo.
|
|
* either the pname:offset.height member in pname:renderArea is a multiple
|
|
of the vertical granularity or pname:offset.y+pname:offset.height is
|
|
equal to the pname:height of the pname:framebuffer in the
|
|
slink:VkRenderPassBeginInfo.
|
|
|
|
Subpass dependencies are not affected by the render area, and apply to the
|
|
entire image subresources attached to the framebuffer.
|
|
Similarly, pipeline barriers are valid even if their effect extends outside
|
|
the render area.
|
|
|
|
include::../validity/protos/vkGetRenderAreaGranularity.txt[]
|
|
|
|
// refBegin vkCmdNextSubpass Transition to the next subpass of a render pass
|
|
|
|
To transition to the next subpass in the render pass instance after
|
|
recording the commands for a subpass, call:
|
|
|
|
include::../api/protos/vkCmdNextSubpass.txt[]
|
|
|
|
* pname:commandBuffer is the command buffer in which to record the
|
|
command.
|
|
* pname:contents specifies how the commands in the next subpass will be
|
|
provided, in the same fashion as the corresponding parameter of
|
|
flink:vkCmdBeginRenderPass.
|
|
|
|
The subpass index for a render pass begins at zero when
|
|
fname:vkCmdBeginRenderPass is recorded, and increments each time
|
|
fname:vkCmdNextSubpass is recorded.
|
|
|
|
Moving to the next subpass automatically performs any multisample resolve
|
|
operations in the subpass being ended.
|
|
End-of-subpass multisample resolves are treated as color attachment writes
|
|
for the purposes of synchronization.
|
|
That is, they are considered to execute in the
|
|
ename:VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage and their
|
|
writes are synchronized with ename:VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT.
|
|
Synchronization between rendering within a subpass and any resolve
|
|
operations at the end of the subpass occurs automatically, without need for
|
|
explicit dependencies or pipeline barriers.
|
|
However, if the resolve attachment is also used in a different subpass, an
|
|
explicit dependency is needed.
|
|
|
|
After transitioning to the next subpass, the application can: record the
|
|
commands for that subpass.
|
|
|
|
.Valid Usage
|
|
****
|
|
* The current subpass index must: be less than the number of subpasses in
|
|
the render pass minus one
|
|
****
|
|
|
|
include::../validity/protos/vkCmdNextSubpass.txt[]
|
|
|
|
// refBegin vkCmdEndRenderPass End the current render pass
|
|
|
|
To record a command to end a render pass instance after recording the
|
|
commands for the last subpass, call:
|
|
|
|
include::../api/protos/vkCmdEndRenderPass.txt[]
|
|
|
|
* pname:commandBuffer is the command buffer in which to end the current
|
|
render pass instance.
|
|
|
|
Ending a render pass instance performs any multisample resolve operations on
|
|
the final subpass.
|
|
|
|
.Valid Usage
|
|
****
|
|
* The current subpass index must: be equal to the number of subpasses in
|
|
the render pass minus one
|
|
****
|
|
|
|
include::../validity/protos/vkCmdEndRenderPass.txt[]
|
|
|