1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2021 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci#ifndef VK_RENDER_PASS_H
24bf215546Sopenharmony_ci#define VK_RENDER_PASS_H
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "vk_object.h"
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#ifdef __cplusplus
29bf215546Sopenharmony_ciextern "C" {
30bf215546Sopenharmony_ci#endif
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci/**
33bf215546Sopenharmony_ci * Pseudo-extension struct that may be chained into VkRenderingInfo,
34bf215546Sopenharmony_ci * VkCommandBufferInheritanceRenderingInfo, or VkPipelineRenderingCreateInfo
35bf215546Sopenharmony_ci * to provide self-dependency information.
36bf215546Sopenharmony_ci */
37bf215546Sopenharmony_citypedef struct VkRenderingSelfDependencyInfoMESA {
38bf215546Sopenharmony_ci    VkStructureType    sType;
39bf215546Sopenharmony_ci#define VK_STRUCTURE_TYPE_RENDERING_SELF_DEPENDENCY_INFO_MESA (VkStructureType)1000044900
40bf215546Sopenharmony_ci    const void*        pNext;
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci    /** Bitset of which color attachments have self-dependencies */
43bf215546Sopenharmony_ci    uint32_t           colorSelfDependencies;
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci    /** True if there is a depth self-dependency */
46bf215546Sopenharmony_ci    VkBool32           depthSelfDependency;
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci    /** True if there is a stencil self-dependency */
49bf215546Sopenharmony_ci    VkBool32           stencilSelfDependency;
50bf215546Sopenharmony_ci} VkRenderingSelfDependencyInfoMESA;
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci/**
53bf215546Sopenharmony_ci * Pseudo-extension struct that may be chained into VkRenderingAttachmentInfo
54bf215546Sopenharmony_ci * to indicate an initial layout for the attachment.  This is only allowed if
55bf215546Sopenharmony_ci * all of the following conditions are met:
56bf215546Sopenharmony_ci *
57bf215546Sopenharmony_ci *    1. VkRenderingAttachmentInfo::loadOp == LOAD_OP_CLEAR
58bf215546Sopenharmony_ci *
59bf215546Sopenharmony_ci *    2. VkRenderingInfo::renderArea is tne entire image view LOD
60bf215546Sopenharmony_ci *
61bf215546Sopenharmony_ci *    3. For 3D image attachments, VkRenderingInfo::viewMask == 0 AND
62bf215546Sopenharmony_ci *       VkRenderingInfo::layerCount references the entire bound image view
63bf215546Sopenharmony_ci *       OR VkRenderingInfo::viewMask is dense (no holes) and references the
64bf215546Sopenharmony_ci *       entire bound image view.  (2D and 2D array images have no such
65bf215546Sopenharmony_ci *       requirement.)
66bf215546Sopenharmony_ci *
67bf215546Sopenharmony_ci * If this struct is included in the pNext chain of a
68bf215546Sopenharmony_ci * VkRenderingAttachmentInfo, the driver is responsible for transitioning the
69bf215546Sopenharmony_ci * bound region of the image from
70bf215546Sopenharmony_ci * VkRenderingAttachmentInitialLayoutInfoMESA::initialLayout to
71bf215546Sopenharmony_ci * VkRenderingAttachmentInfo::imageLayout prior to rendering.
72bf215546Sopenharmony_ci */
73bf215546Sopenharmony_citypedef struct VkRenderingAttachmentInitialLayoutInfoMESA {
74bf215546Sopenharmony_ci    VkStructureType    sType;
75bf215546Sopenharmony_ci#define VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INITIAL_LAYOUT_INFO_MESA (VkStructureType)1000044901
76bf215546Sopenharmony_ci    const void*        pNext;
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ci    /** Initial layout of the attachment */
79bf215546Sopenharmony_ci    VkImageLayout      initialLayout;
80bf215546Sopenharmony_ci} VkRenderingAttachmentInitialLayoutInfoMESA;
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci#define VK_IMAGE_LAYOUT_SUBPASS_SELF_DEPENDENCY_MESA (VkImageLayout)1000044902
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_cistruct vk_subpass_attachment {
85bf215546Sopenharmony_ci   /** VkAttachmentReference2::attachment */
86bf215546Sopenharmony_ci   uint32_t attachment;
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci   /** Aspects referenced by this attachment
89bf215546Sopenharmony_ci    *
90bf215546Sopenharmony_ci    * For an input attachment, this is VkAttachmentReference2::aspectMask.
91bf215546Sopenharmony_ci    * For all others, it's equal to the vk_render_pass_attachment::aspects.
92bf215546Sopenharmony_ci    */
93bf215546Sopenharmony_ci   VkImageAspectFlags aspects;
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci   /** Usage for this attachment
96bf215546Sopenharmony_ci    *
97bf215546Sopenharmony_ci    * This is a single VK_IMAGE_USAGE_* describing the usage of this subpass
98bf215546Sopenharmony_ci    * attachment.  Resolve attachments are VK_IMAGE_USAGE_TRANSFER_DST_BIT.
99bf215546Sopenharmony_ci    */
100bf215546Sopenharmony_ci   VkImageUsageFlagBits usage;
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ci   /** VkAttachmentReference2::layout */
103bf215546Sopenharmony_ci   VkImageLayout layout;
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci   /** VkAttachmentReferenceStencilLayout::stencilLayout
106bf215546Sopenharmony_ci    *
107bf215546Sopenharmony_ci    * If VK_KHR_separate_depth_stencil_layouts is not used, this will be
108bf215546Sopenharmony_ci    * layout if the attachment contains stencil and VK_IMAGE_LAYOUT_UNDEFINED
109bf215546Sopenharmony_ci    * otherwise.
110bf215546Sopenharmony_ci    */
111bf215546Sopenharmony_ci   VkImageLayout stencil_layout;
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_ci   /** A per-view mask for if this is the last use of this attachment
114bf215546Sopenharmony_ci    *
115bf215546Sopenharmony_ci    * If the same render pass attachment is used multiple ways within a
116bf215546Sopenharmony_ci    * subpass, corresponding last_subpass bits will be set in all of them.
117bf215546Sopenharmony_ci    * For the non-multiview case, only the first bit is used.
118bf215546Sopenharmony_ci    */
119bf215546Sopenharmony_ci   uint32_t last_subpass;
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci   /** Resolve attachment, if any */
122bf215546Sopenharmony_ci   struct vk_subpass_attachment *resolve;
123bf215546Sopenharmony_ci};
124bf215546Sopenharmony_ci
125bf215546Sopenharmony_cistruct vk_subpass {
126bf215546Sopenharmony_ci   /** Count of all attachments referenced by this subpass */
127bf215546Sopenharmony_ci   uint32_t attachment_count;
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci   /** Array of all attachments referenced by this subpass */
130bf215546Sopenharmony_ci   struct vk_subpass_attachment *attachments;
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci   /** VkSubpassDescription2::inputAttachmentCount */
133bf215546Sopenharmony_ci   uint32_t input_count;
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ci   /** VkSubpassDescription2::pInputAttachments */
136bf215546Sopenharmony_ci   struct vk_subpass_attachment *input_attachments;
137bf215546Sopenharmony_ci
138bf215546Sopenharmony_ci   /** VkSubpassDescription2::colorAttachmentCount */
139bf215546Sopenharmony_ci   uint32_t color_count;
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_ci   /** VkSubpassDescription2::pColorAttachments */
142bf215546Sopenharmony_ci   struct vk_subpass_attachment *color_attachments;
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci   /** VkSubpassDescription2::colorAttachmentCount or zero */
145bf215546Sopenharmony_ci   uint32_t color_resolve_count;
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci   /** VkSubpassDescription2::pResolveAttachments */
148bf215546Sopenharmony_ci   struct vk_subpass_attachment *color_resolve_attachments;
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci   /** VkSubpassDescription2::pDepthStencilAttachment */
151bf215546Sopenharmony_ci   struct vk_subpass_attachment *depth_stencil_attachment;
152bf215546Sopenharmony_ci
153bf215546Sopenharmony_ci   /** VkSubpassDescriptionDepthStencilResolve::pDepthStencilResolveAttachment */
154bf215546Sopenharmony_ci   struct vk_subpass_attachment *depth_stencil_resolve_attachment;
155bf215546Sopenharmony_ci
156bf215546Sopenharmony_ci   /** VkFragmentShadingRateAttachmentInfoKHR::pFragmentShadingRateAttachment */
157bf215546Sopenharmony_ci   struct vk_subpass_attachment *fragment_shading_rate_attachment;
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci   /** VkSubpassDescription2::viewMask or 1 for non-multiview
160bf215546Sopenharmony_ci    *
161bf215546Sopenharmony_ci    * For all view masks in the vk_render_pass data structure, we use a mask
162bf215546Sopenharmony_ci    * of 1 for non-multiview instead of a mask of 0.  To determine if the
163bf215546Sopenharmony_ci    * render pass is multiview or not, see vk_render_pass::is_multiview.
164bf215546Sopenharmony_ci    */
165bf215546Sopenharmony_ci   uint32_t view_mask;
166bf215546Sopenharmony_ci
167bf215546Sopenharmony_ci   /** VkSubpassDescriptionDepthStencilResolve::depthResolveMode */
168bf215546Sopenharmony_ci   VkResolveModeFlagBits depth_resolve_mode;
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ci   /** VkSubpassDescriptionDepthStencilResolve::stencilResolveMode */
171bf215546Sopenharmony_ci   VkResolveModeFlagBits stencil_resolve_mode;
172bf215546Sopenharmony_ci
173bf215546Sopenharmony_ci   /** VkFragmentShadingRateAttachmentInfoKHR::shadingRateAttachmentTexelSize */
174bf215546Sopenharmony_ci   VkExtent2D fragment_shading_rate_attachment_texel_size;
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ci   /** VkRenderingSelfDependencyInfoMESA for this subpass
177bf215546Sopenharmony_ci    *
178bf215546Sopenharmony_ci    * This is in the pNext chain of pipeline_info and inheritance_info.
179bf215546Sopenharmony_ci    */
180bf215546Sopenharmony_ci   VkRenderingSelfDependencyInfoMESA self_dep_info;
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ci   /** VkAttachmentSampleCountInfoAMD for this subpass
183bf215546Sopenharmony_ci    *
184bf215546Sopenharmony_ci    * This is in the pNext chain of pipeline_info and inheritance_info.
185bf215546Sopenharmony_ci    */
186bf215546Sopenharmony_ci   VkAttachmentSampleCountInfoAMD sample_count_info_amd;
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ci   /** VkPipelineRenderingCreateInfo for this subpass
189bf215546Sopenharmony_ci    *
190bf215546Sopenharmony_ci    * Returned by vk_get_pipeline_rendering_create_info() if
191bf215546Sopenharmony_ci    * VkGraphicsPipelineCreateInfo::renderPass != VK_NULL_HANDLE.
192bf215546Sopenharmony_ci    */
193bf215546Sopenharmony_ci   VkPipelineRenderingCreateInfo pipeline_info;
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ci   /** VkCommandBufferInheritanceRenderingInfo for this subpass
196bf215546Sopenharmony_ci    *
197bf215546Sopenharmony_ci    * Returned by vk_get_command_buffer_inheritance_rendering_info() if
198bf215546Sopenharmony_ci    * VkCommandBufferInheritanceInfo::renderPass != VK_NULL_HANDLE.
199bf215546Sopenharmony_ci    */
200bf215546Sopenharmony_ci   VkCommandBufferInheritanceRenderingInfo inheritance_info;
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci   /** VkMultisampledRenderToSingleSampledInfoEXT for this subpass */
203bf215546Sopenharmony_ci   VkMultisampledRenderToSingleSampledInfoEXT mrtss;
204bf215546Sopenharmony_ci};
205bf215546Sopenharmony_ci
206bf215546Sopenharmony_cistruct vk_render_pass_attachment {
207bf215546Sopenharmony_ci   /** VkAttachmentDescription2::format */
208bf215546Sopenharmony_ci   VkFormat format;
209bf215546Sopenharmony_ci
210bf215546Sopenharmony_ci   /** Aspects contained in format */
211bf215546Sopenharmony_ci   VkImageAspectFlags aspects;
212bf215546Sopenharmony_ci
213bf215546Sopenharmony_ci   /** VkAttachmentDescription2::samples */
214bf215546Sopenharmony_ci   uint32_t samples;
215bf215546Sopenharmony_ci
216bf215546Sopenharmony_ci   /** Views in which this attachment is used, 0 for unused
217bf215546Sopenharmony_ci    *
218bf215546Sopenharmony_ci    * For non-multiview, this will be 1 if the attachment is used.
219bf215546Sopenharmony_ci    */
220bf215546Sopenharmony_ci   uint32_t view_mask;
221bf215546Sopenharmony_ci
222bf215546Sopenharmony_ci   /** VkAttachmentDescription2::loadOp */
223bf215546Sopenharmony_ci   VkAttachmentLoadOp load_op;
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_ci   /** VkAttachmentDescription2::storeOp */
226bf215546Sopenharmony_ci   VkAttachmentStoreOp store_op;
227bf215546Sopenharmony_ci
228bf215546Sopenharmony_ci   /** VkAttachmentDescription2::stencilLoadOp */
229bf215546Sopenharmony_ci   VkAttachmentLoadOp stencil_load_op;
230bf215546Sopenharmony_ci
231bf215546Sopenharmony_ci   /** VkAttachmentDescription2::stencilStoreOp */
232bf215546Sopenharmony_ci   VkAttachmentStoreOp stencil_store_op;
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_ci   /** VkAttachmentDescription2::initialLayout */
235bf215546Sopenharmony_ci   VkImageLayout initial_layout;
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ci   /** VkAttachmentDescription2::finalLayout */
238bf215546Sopenharmony_ci   VkImageLayout final_layout;
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_ci   /** VkAttachmentDescriptionStencilLayout::stencilInitialLayout
241bf215546Sopenharmony_ci    *
242bf215546Sopenharmony_ci    * If VK_KHR_separate_depth_stencil_layouts is not used, this will be
243bf215546Sopenharmony_ci    * initial_layout if format contains stencil and VK_IMAGE_LAYOUT_UNDEFINED
244bf215546Sopenharmony_ci    * otherwise.
245bf215546Sopenharmony_ci    */
246bf215546Sopenharmony_ci   VkImageLayout initial_stencil_layout;
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ci   /** VkAttachmentDescriptionStencilLayout::stencilFinalLayout
249bf215546Sopenharmony_ci    *
250bf215546Sopenharmony_ci    * If VK_KHR_separate_depth_stencil_layouts is not used, this will be
251bf215546Sopenharmony_ci    * final_layout if format contains stencil and VK_IMAGE_LAYOUT_UNDEFINED
252bf215546Sopenharmony_ci    * otherwise.
253bf215546Sopenharmony_ci    */
254bf215546Sopenharmony_ci   VkImageLayout final_stencil_layout;
255bf215546Sopenharmony_ci};
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_cistruct vk_subpass_dependency {
258bf215546Sopenharmony_ci   /** VkSubpassDependency2::dependencyFlags */
259bf215546Sopenharmony_ci   VkDependencyFlags flags;
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci   /** VkSubpassDependency2::srcSubpass */
262bf215546Sopenharmony_ci   uint32_t src_subpass;
263bf215546Sopenharmony_ci
264bf215546Sopenharmony_ci   /** VkSubpassDependency2::dstSubpass */
265bf215546Sopenharmony_ci   uint32_t dst_subpass;
266bf215546Sopenharmony_ci
267bf215546Sopenharmony_ci   /** VkSubpassDependency2::srcStageMask */
268bf215546Sopenharmony_ci   VkPipelineStageFlags2 src_stage_mask;
269bf215546Sopenharmony_ci
270bf215546Sopenharmony_ci   /** VkSubpassDependency2::dstStageMask */
271bf215546Sopenharmony_ci   VkPipelineStageFlags2 dst_stage_mask;
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ci   /** VkSubpassDependency2::srcAccessMask */
274bf215546Sopenharmony_ci   VkAccessFlags2 src_access_mask;
275bf215546Sopenharmony_ci
276bf215546Sopenharmony_ci   /** VkSubpassDependency2::dstAccessMask */
277bf215546Sopenharmony_ci   VkAccessFlags2 dst_access_mask;
278bf215546Sopenharmony_ci
279bf215546Sopenharmony_ci   /** VkSubpassDependency2::viewOffset */
280bf215546Sopenharmony_ci   int32_t view_offset;
281bf215546Sopenharmony_ci};
282bf215546Sopenharmony_ci
283bf215546Sopenharmony_cistruct vk_render_pass {
284bf215546Sopenharmony_ci   struct vk_object_base base;
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_ci   /** True if this render pass uses multiview
287bf215546Sopenharmony_ci    *
288bf215546Sopenharmony_ci    * This is true if all subpasses have viewMask != 0.
289bf215546Sopenharmony_ci    */
290bf215546Sopenharmony_ci   bool is_multiview;
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci   /** Views used by this render pass or 1 for non-multiview */
293bf215546Sopenharmony_ci   uint32_t view_mask;
294bf215546Sopenharmony_ci
295bf215546Sopenharmony_ci   /** VkRenderPassCreateInfo2::attachmentCount */
296bf215546Sopenharmony_ci   uint32_t attachment_count;
297bf215546Sopenharmony_ci
298bf215546Sopenharmony_ci   /** VkRenderPassCreateInfo2::pAttachments */
299bf215546Sopenharmony_ci   struct vk_render_pass_attachment *attachments;
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_ci   /** VkRenderPassCreateInfo2::subpassCount */
302bf215546Sopenharmony_ci   uint32_t subpass_count;
303bf215546Sopenharmony_ci
304bf215546Sopenharmony_ci   /** VkRenderPassCreateInfo2::subpasses */
305bf215546Sopenharmony_ci   struct vk_subpass *subpasses;
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ci   /** VkRenderPassCreateInfo2::dependencyCount */
308bf215546Sopenharmony_ci   uint32_t dependency_count;
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_ci   /** VkRenderPassCreateInfo2::pDependencies */
311bf215546Sopenharmony_ci   struct vk_subpass_dependency *dependencies;
312bf215546Sopenharmony_ci};
313bf215546Sopenharmony_ci
314bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(vk_render_pass, base, VkRenderPass,
315bf215546Sopenharmony_ci                               VK_OBJECT_TYPE_RENDER_PASS);
316bf215546Sopenharmony_ci
317bf215546Sopenharmony_ci/** Returns the VkPipelineRenderingCreateInfo for a graphics pipeline
318bf215546Sopenharmony_ci *
319bf215546Sopenharmony_ci * For render-pass-free drivers, this can be used in the implementation of
320bf215546Sopenharmony_ci * vkCreateGraphicsPipelines to get the VkPipelineRenderingCreateInfo.  If
321bf215546Sopenharmony_ci * VkGraphicsPipelineCreateInfo::renderPass is not VK_NULL_HANDLE, it will
322bf215546Sopenharmony_ci * return a representation of the specified subpass as a
323bf215546Sopenharmony_ci * VkPipelineRenderingCreateInfo.  If VkGraphicsPipelineCreateInfo::renderPass
324bf215546Sopenharmony_ci * is VK_NULL_HANDLE and there is a VkPipelineRenderingCreateInfo in the pNext
325bf215546Sopenharmony_ci * chain of VkGraphicsPipelineCreateInfo, it will return that.
326bf215546Sopenharmony_ci *
327bf215546Sopenharmony_ci * @param[in]  info  One of the pCreateInfos from vkCreateGraphicsPipelines
328bf215546Sopenharmony_ci */
329bf215546Sopenharmony_ciconst VkPipelineRenderingCreateInfo *
330bf215546Sopenharmony_civk_get_pipeline_rendering_create_info(const VkGraphicsPipelineCreateInfo *info);
331bf215546Sopenharmony_ci
332bf215546Sopenharmony_ci/** Returns the VkAttachmentSampleCountInfoAMD for a graphics pipeline
333bf215546Sopenharmony_ci *
334bf215546Sopenharmony_ci * For render-pass-free drivers, this can be used in the implementaiton of
335bf215546Sopenharmony_ci * vkCreateGraphicsPipelines to get the VkAttachmentSampleCountInfoAMD.  If
336bf215546Sopenharmony_ci * VkGraphicsPipelineCreateInfo::renderPass is not VK_NULL_HANDLE, it will
337bf215546Sopenharmony_ci * return the sample counts from the specified subpass as a
338bf215546Sopenharmony_ci * VkAttachmentSampleCountInfoAMD.  If VkGraphicsPipelineCreateInfo::renderPass
339bf215546Sopenharmony_ci * is VK_NULL_HANDLE and there is a VkAttachmentSampleCountInfoAMD in the pNext
340bf215546Sopenharmony_ci * chain of VkGraphicsPipelineCreateInfo, it will return that.
341bf215546Sopenharmony_ci *
342bf215546Sopenharmony_ci * @param[in]  info  One of the pCreateInfos from vkCreateGraphicsPipelines
343bf215546Sopenharmony_ci */
344bf215546Sopenharmony_ciconst VkAttachmentSampleCountInfoAMD *
345bf215546Sopenharmony_civk_get_pipeline_sample_count_info_amd(const VkGraphicsPipelineCreateInfo *info);
346bf215546Sopenharmony_ci
347bf215546Sopenharmony_ci/**
348bf215546Sopenharmony_ci * Returns the VkCommandBufferInheritanceRenderingInfo for secondary command
349bf215546Sopenharmony_ci * buffer execution
350bf215546Sopenharmony_ci *
351bf215546Sopenharmony_ci * For render-pass-free drivers, this can be used in the implementation of
352bf215546Sopenharmony_ci * vkCmdExecuteCommands to get the VkCommandBufferInheritanceRenderingInfo.
353bf215546Sopenharmony_ci * If VkCommandBufferInheritanceInfo::renderPass is not VK_NULL_HANDLE, it
354bf215546Sopenharmony_ci * will return a representation of the specified subpass as a
355bf215546Sopenharmony_ci * VkCommandBufferInheritanceRenderingInfo.  If
356bf215546Sopenharmony_ci * VkCommandBufferInheritanceInfo::renderPass is not VK_NULL_HANDLE and there
357bf215546Sopenharmony_ci * is a VkCommandBufferInheritanceRenderingInfo in the pNext chain of
358bf215546Sopenharmony_ci * VkCommandBufferBeginInfo, it will return that.
359bf215546Sopenharmony_ci *
360bf215546Sopenharmony_ci * @param[in]  level       The nesting level of this command buffer
361bf215546Sopenharmony_ci * @param[in]  pBeginInfo  The pBeginInfo from vkBeginCommandBuffer
362bf215546Sopenharmony_ci */
363bf215546Sopenharmony_ciconst VkCommandBufferInheritanceRenderingInfo *
364bf215546Sopenharmony_civk_get_command_buffer_inheritance_rendering_info(
365bf215546Sopenharmony_ci   VkCommandBufferLevel level,
366bf215546Sopenharmony_ci   const VkCommandBufferBeginInfo *pBeginInfo);
367bf215546Sopenharmony_ci
368bf215546Sopenharmony_cistruct vk_gcbiarr_data {
369bf215546Sopenharmony_ci   VkRenderingInfo rendering;
370bf215546Sopenharmony_ci   VkRenderingFragmentShadingRateAttachmentInfoKHR fsr_att;
371bf215546Sopenharmony_ci   VkRenderingAttachmentInfo attachments[];
372bf215546Sopenharmony_ci};
373bf215546Sopenharmony_ci
374bf215546Sopenharmony_ci#define VK_GCBIARR_DATA_SIZE(max_color_rts) (\
375bf215546Sopenharmony_ci   sizeof(struct vk_gcbiarr_data) + \
376bf215546Sopenharmony_ci   sizeof(VkRenderingAttachmentInfo) * ((max_color_rts) + 2) \
377bf215546Sopenharmony_ci)
378bf215546Sopenharmony_ci
379bf215546Sopenharmony_ci/**
380bf215546Sopenharmony_ci * Constructs a VkRenderingInfo for the inheritance rendering info
381bf215546Sopenharmony_ci *
382bf215546Sopenharmony_ci * For render-pass-free drivers, this can be used in the implementaiton of
383bf215546Sopenharmony_ci * vkCmdExecuteCommands to get a VkRenderingInfo representing the subpass and
384bf215546Sopenharmony_ci * framebuffer provided via the inheritance info for a command buffer created
385bf215546Sopenharmony_ci * with VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT.  The mental model
386bf215546Sopenharmony_ci * here is that VkExecuteCommands() implicitly suspends the render pass and
387bf215546Sopenharmony_ci * VkBeginCommandBuffer() resumes it.  If a VkRenderingInfo cannot be
388bf215546Sopenharmony_ci * constructed due to a missing framebuffer or similar, NULL will be
389bf215546Sopenharmony_ci * returned.
390bf215546Sopenharmony_ci *
391bf215546Sopenharmony_ci * @param[in]  level       The nesting level of this command buffer
392bf215546Sopenharmony_ci * @param[in]  pBeginInfo  The pBeginInfo from vkBeginCommandBuffer
393bf215546Sopenharmony_ci * @param[out] stack_data  An opaque blob of data which will be overwritten by
394bf215546Sopenharmony_ci *                         this function, passed in from the caller to avoid
395bf215546Sopenharmony_ci *                         heap allocations.  It must be at least
396bf215546Sopenharmony_ci *                         VK_GCBIARR_DATA_SIZE(max_color_rts) bytes.
397bf215546Sopenharmony_ci */
398bf215546Sopenharmony_ciconst VkRenderingInfo *
399bf215546Sopenharmony_civk_get_command_buffer_inheritance_as_rendering_resume(
400bf215546Sopenharmony_ci   VkCommandBufferLevel level,
401bf215546Sopenharmony_ci   const VkCommandBufferBeginInfo *pBeginInfo,
402bf215546Sopenharmony_ci   void *stack_data);
403bf215546Sopenharmony_ci
404bf215546Sopenharmony_ci#ifdef __cplusplus
405bf215546Sopenharmony_ci}
406bf215546Sopenharmony_ci#endif
407bf215546Sopenharmony_ci
408bf215546Sopenharmony_ci#endif /* VK_RENDER_PASS_H */
409