2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "anv_private.h"
29 anv_render_pass_add_subpass_dep(struct anv_render_pass
*pass
,
30 const VkSubpassDependency2KHR
*dep
)
32 if (dep
->dstSubpass
== VK_SUBPASS_EXTERNAL
) {
33 pass
->subpass_flushes
[pass
->subpass_count
] |=
34 anv_pipe_invalidate_bits_for_access_flags(dep
->dstAccessMask
);
36 assert(dep
->dstSubpass
< pass
->subpass_count
);
37 pass
->subpass_flushes
[dep
->dstSubpass
] |=
38 anv_pipe_invalidate_bits_for_access_flags(dep
->dstAccessMask
);
41 if (dep
->srcSubpass
== VK_SUBPASS_EXTERNAL
) {
42 pass
->subpass_flushes
[0] |=
43 anv_pipe_flush_bits_for_access_flags(dep
->srcAccessMask
);
45 assert(dep
->srcSubpass
< pass
->subpass_count
);
46 pass
->subpass_flushes
[dep
->srcSubpass
+ 1] |=
47 anv_pipe_flush_bits_for_access_flags(dep
->srcAccessMask
);
51 /* Do a second "compile" step on a render pass */
53 anv_render_pass_compile(struct anv_render_pass
*pass
)
55 /* The CreateRenderPass code zeros the entire render pass and also uses a
56 * designated initializer for filling these out. There's no need for us to
59 * for (uint32_t i = 0; i < pass->attachment_count; i++) {
60 * pass->attachments[i].usage = 0;
61 * pass->attachments[i].first_subpass_layout = VK_IMAGE_LAYOUT_UNDEFINED;
65 VkImageUsageFlags all_usage
= 0;
66 for (uint32_t i
= 0; i
< pass
->subpass_count
; i
++) {
67 struct anv_subpass
*subpass
= &pass
->subpasses
[i
];
69 /* We don't allow depth_stencil_attachment to be non-NULL and be
70 * VK_ATTACHMENT_UNUSED. This way something can just check for NULL
71 * and be guaranteed that they have a valid attachment.
73 if (subpass
->depth_stencil_attachment
&&
74 subpass
->depth_stencil_attachment
->attachment
== VK_ATTACHMENT_UNUSED
)
75 subpass
->depth_stencil_attachment
= NULL
;
77 if (subpass
->ds_resolve_attachment
&&
78 subpass
->ds_resolve_attachment
->attachment
== VK_ATTACHMENT_UNUSED
)
79 subpass
->ds_resolve_attachment
= NULL
;
81 for (uint32_t j
= 0; j
< subpass
->attachment_count
; j
++) {
82 struct anv_subpass_attachment
*subpass_att
= &subpass
->attachments
[j
];
83 if (subpass_att
->attachment
== VK_ATTACHMENT_UNUSED
)
86 struct anv_render_pass_attachment
*pass_att
=
87 &pass
->attachments
[subpass_att
->attachment
];
89 assert(__builtin_popcount(subpass_att
->usage
) == 1);
90 pass_att
->usage
|= subpass_att
->usage
;
91 pass_att
->last_subpass_idx
= i
;
93 all_usage
|= subpass_att
->usage
;
95 if (pass_att
->first_subpass_layout
== VK_IMAGE_LAYOUT_UNDEFINED
) {
96 pass_att
->first_subpass_layout
= subpass_att
->layout
;
97 assert(pass_att
->first_subpass_layout
!= VK_IMAGE_LAYOUT_UNDEFINED
);
100 if (subpass_att
->usage
== VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
&&
101 subpass
->depth_stencil_attachment
&&
102 subpass_att
->attachment
== subpass
->depth_stencil_attachment
->attachment
)
103 subpass
->has_ds_self_dep
= true;
106 /* We have to handle resolve attachments specially */
107 subpass
->has_color_resolve
= false;
108 if (subpass
->resolve_attachments
) {
109 for (uint32_t j
= 0; j
< subpass
->color_count
; j
++) {
110 struct anv_subpass_attachment
*color_att
=
111 &subpass
->color_attachments
[j
];
112 struct anv_subpass_attachment
*resolve_att
=
113 &subpass
->resolve_attachments
[j
];
114 if (resolve_att
->attachment
== VK_ATTACHMENT_UNUSED
)
117 subpass
->has_color_resolve
= true;
119 assert(resolve_att
->usage
== VK_IMAGE_USAGE_TRANSFER_DST_BIT
);
120 color_att
->usage
|= VK_IMAGE_USAGE_TRANSFER_SRC_BIT
;
124 if (subpass
->ds_resolve_attachment
) {
125 struct anv_subpass_attachment
*ds_att
=
126 subpass
->depth_stencil_attachment
;
127 UNUSED
struct anv_subpass_attachment
*resolve_att
=
128 subpass
->ds_resolve_attachment
;
130 assert(resolve_att
->usage
== VK_IMAGE_USAGE_TRANSFER_DST_BIT
);
131 ds_att
->usage
|= VK_IMAGE_USAGE_TRANSFER_SRC_BIT
;
135 /* From the Vulkan 1.0.39 spec:
137 * If there is no subpass dependency from VK_SUBPASS_EXTERNAL to the
138 * first subpass that uses an attachment, then an implicit subpass
139 * dependency exists from VK_SUBPASS_EXTERNAL to the first subpass it is
140 * used in. The subpass dependency operates as if defined with the
141 * following parameters:
143 * VkSubpassDependency implicitDependency = {
144 * .srcSubpass = VK_SUBPASS_EXTERNAL;
145 * .dstSubpass = firstSubpass; // First subpass attachment is used in
146 * .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
147 * .dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
148 * .srcAccessMask = 0;
149 * .dstAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
150 * VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
151 * VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
152 * VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
153 * VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
154 * .dependencyFlags = 0;
157 * Similarly, if there is no subpass dependency from the last subpass
158 * that uses an attachment to VK_SUBPASS_EXTERNAL, then an implicit
159 * subpass dependency exists from the last subpass it is used in to
160 * VK_SUBPASS_EXTERNAL. The subpass dependency operates as if defined
161 * with the following parameters:
163 * VkSubpassDependency implicitDependency = {
164 * .srcSubpass = lastSubpass; // Last subpass attachment is used in
165 * .dstSubpass = VK_SUBPASS_EXTERNAL;
166 * .srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
167 * .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
168 * .srcAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
169 * VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
170 * VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
171 * VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
172 * VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
173 * .dstAccessMask = 0;
174 * .dependencyFlags = 0;
177 * We could implement this by walking over all of the attachments and
178 * subpasses and checking to see if any of them don't have an external
179 * dependency. Or, we could just be lazy and add a couple extra flushes.
180 * We choose to be lazy.
182 * From the documentation for vkCmdNextSubpass:
184 * "Moving to the next subpass automatically performs any multisample
185 * resolve operations in the subpass being ended. End-of-subpass
186 * multisample resolves are treated as color attachment writes for the
187 * purposes of synchronization. This applies to resolve operations for
188 * both color and depth/stencil attachments. That is, they are
189 * considered to execute in the
190 * VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage and
191 * their writes are synchronized with
192 * VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT."
194 * Therefore, the above flags concerning color attachments also apply to
195 * color and depth/stencil resolve attachments.
197 if (all_usage
& VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
) {
198 pass
->subpass_flushes
[0] |=
199 ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT
;
201 if (all_usage
& (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
202 VK_IMAGE_USAGE_TRANSFER_DST_BIT
)) {
203 pass
->subpass_flushes
[pass
->subpass_count
] |=
204 ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT
;
206 if (all_usage
& VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
) {
207 pass
->subpass_flushes
[pass
->subpass_count
] |=
208 ANV_PIPE_DEPTH_CACHE_FLUSH_BIT
;
213 num_subpass_attachments(const VkSubpassDescription
*desc
)
215 return desc
->inputAttachmentCount
+
216 desc
->colorAttachmentCount
+
217 (desc
->pResolveAttachments
? desc
->colorAttachmentCount
: 0) +
218 (desc
->pDepthStencilAttachment
!= NULL
);
221 VkResult
anv_CreateRenderPass(
223 const VkRenderPassCreateInfo
* pCreateInfo
,
224 const VkAllocationCallbacks
* pAllocator
,
225 VkRenderPass
* pRenderPass
)
227 ANV_FROM_HANDLE(anv_device
, device
, _device
);
229 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO
);
231 struct anv_render_pass
*pass
;
232 struct anv_subpass
*subpasses
;
233 struct anv_render_pass_attachment
*attachments
;
234 enum anv_pipe_bits
*subpass_flushes
;
237 anv_multialloc_add(&ma
, &pass
, 1);
238 anv_multialloc_add(&ma
, &subpasses
, pCreateInfo
->subpassCount
);
239 anv_multialloc_add(&ma
, &attachments
, pCreateInfo
->attachmentCount
);
240 anv_multialloc_add(&ma
, &subpass_flushes
, pCreateInfo
->subpassCount
+ 1);
242 struct anv_subpass_attachment
*subpass_attachments
;
243 uint32_t subpass_attachment_count
= 0;
244 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
245 subpass_attachment_count
+=
246 num_subpass_attachments(&pCreateInfo
->pSubpasses
[i
]);
248 anv_multialloc_add(&ma
, &subpass_attachments
, subpass_attachment_count
);
250 if (!anv_multialloc_alloc2(&ma
, &device
->alloc
, pAllocator
,
251 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
))
252 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
254 /* Clear the subpasses along with the parent pass. This required because
255 * each array member of anv_subpass must be a valid pointer if not NULL.
257 memset(pass
, 0, ma
.size
);
258 pass
->attachment_count
= pCreateInfo
->attachmentCount
;
259 pass
->subpass_count
= pCreateInfo
->subpassCount
;
260 pass
->attachments
= attachments
;
261 pass
->subpass_flushes
= subpass_flushes
;
263 for (uint32_t i
= 0; i
< pCreateInfo
->attachmentCount
; i
++) {
264 pass
->attachments
[i
] = (struct anv_render_pass_attachment
) {
265 .format
= pCreateInfo
->pAttachments
[i
].format
,
266 .samples
= pCreateInfo
->pAttachments
[i
].samples
,
267 .load_op
= pCreateInfo
->pAttachments
[i
].loadOp
,
268 .store_op
= pCreateInfo
->pAttachments
[i
].storeOp
,
269 .stencil_load_op
= pCreateInfo
->pAttachments
[i
].stencilLoadOp
,
270 .initial_layout
= pCreateInfo
->pAttachments
[i
].initialLayout
,
271 .final_layout
= pCreateInfo
->pAttachments
[i
].finalLayout
,
273 .stencil_initial_layout
= pCreateInfo
->pAttachments
[i
].initialLayout
,
274 .stencil_final_layout
= pCreateInfo
->pAttachments
[i
].finalLayout
,
278 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
279 const VkSubpassDescription
*desc
= &pCreateInfo
->pSubpasses
[i
];
280 struct anv_subpass
*subpass
= &pass
->subpasses
[i
];
282 subpass
->input_count
= desc
->inputAttachmentCount
;
283 subpass
->color_count
= desc
->colorAttachmentCount
;
284 subpass
->attachment_count
= num_subpass_attachments(desc
);
285 subpass
->attachments
= subpass_attachments
;
286 subpass
->view_mask
= 0;
288 if (desc
->inputAttachmentCount
> 0) {
289 subpass
->input_attachments
= subpass_attachments
;
290 subpass_attachments
+= desc
->inputAttachmentCount
;
292 for (uint32_t j
= 0; j
< desc
->inputAttachmentCount
; j
++) {
293 subpass
->input_attachments
[j
] = (struct anv_subpass_attachment
) {
294 .usage
= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
,
295 .attachment
= desc
->pInputAttachments
[j
].attachment
,
296 .layout
= desc
->pInputAttachments
[j
].layout
,
301 if (desc
->colorAttachmentCount
> 0) {
302 subpass
->color_attachments
= subpass_attachments
;
303 subpass_attachments
+= desc
->colorAttachmentCount
;
305 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
306 subpass
->color_attachments
[j
] = (struct anv_subpass_attachment
) {
307 .usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
308 .attachment
= desc
->pColorAttachments
[j
].attachment
,
309 .layout
= desc
->pColorAttachments
[j
].layout
,
314 if (desc
->pResolveAttachments
) {
315 subpass
->resolve_attachments
= subpass_attachments
;
316 subpass_attachments
+= desc
->colorAttachmentCount
;
318 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
319 subpass
->resolve_attachments
[j
] = (struct anv_subpass_attachment
) {
320 .usage
= VK_IMAGE_USAGE_TRANSFER_DST_BIT
,
321 .attachment
= desc
->pResolveAttachments
[j
].attachment
,
322 .layout
= desc
->pResolveAttachments
[j
].layout
,
327 if (desc
->pDepthStencilAttachment
) {
328 subpass
->depth_stencil_attachment
= subpass_attachments
++;
330 *subpass
->depth_stencil_attachment
= (struct anv_subpass_attachment
) {
331 .usage
= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
,
332 .attachment
= desc
->pDepthStencilAttachment
->attachment
,
333 .layout
= desc
->pDepthStencilAttachment
->layout
,
334 .stencil_layout
= desc
->pDepthStencilAttachment
->layout
,
339 for (uint32_t i
= 0; i
< pCreateInfo
->dependencyCount
; i
++) {
340 /* Convert to a Dependency2KHR */
341 struct VkSubpassDependency2KHR dep2
= {
342 .srcSubpass
= pCreateInfo
->pDependencies
[i
].srcSubpass
,
343 .dstSubpass
= pCreateInfo
->pDependencies
[i
].dstSubpass
,
344 .srcStageMask
= pCreateInfo
->pDependencies
[i
].srcStageMask
,
345 .dstStageMask
= pCreateInfo
->pDependencies
[i
].dstStageMask
,
346 .srcAccessMask
= pCreateInfo
->pDependencies
[i
].srcAccessMask
,
347 .dstAccessMask
= pCreateInfo
->pDependencies
[i
].dstAccessMask
,
348 .dependencyFlags
= pCreateInfo
->pDependencies
[i
].dependencyFlags
,
350 anv_render_pass_add_subpass_dep(pass
, &dep2
);
353 vk_foreach_struct(ext
, pCreateInfo
->pNext
) {
354 switch (ext
->sType
) {
355 case VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO
:
356 /* We don't care about this information */
359 case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO
: {
360 VkRenderPassMultiviewCreateInfo
*mv
= (void *)ext
;
362 for (uint32_t i
= 0; i
< mv
->subpassCount
; i
++) {
363 pass
->subpasses
[i
].view_mask
= mv
->pViewMasks
[i
];
369 anv_debug_ignored_stype(ext
->sType
);
373 anv_render_pass_compile(pass
);
375 *pRenderPass
= anv_render_pass_to_handle(pass
);
381 num_subpass_attachments2(const VkSubpassDescription2KHR
*desc
)
383 const VkSubpassDescriptionDepthStencilResolveKHR
*ds_resolve
=
384 vk_find_struct_const(desc
->pNext
,
385 SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR
);
387 return desc
->inputAttachmentCount
+
388 desc
->colorAttachmentCount
+
389 (desc
->pResolveAttachments
? desc
->colorAttachmentCount
: 0) +
390 (desc
->pDepthStencilAttachment
!= NULL
) +
391 (ds_resolve
&& ds_resolve
->pDepthStencilResolveAttachment
);
394 VkResult
anv_CreateRenderPass2KHR(
396 const VkRenderPassCreateInfo2KHR
* pCreateInfo
,
397 const VkAllocationCallbacks
* pAllocator
,
398 VkRenderPass
* pRenderPass
)
400 ANV_FROM_HANDLE(anv_device
, device
, _device
);
402 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR
);
404 struct anv_render_pass
*pass
;
405 struct anv_subpass
*subpasses
;
406 struct anv_render_pass_attachment
*attachments
;
407 enum anv_pipe_bits
*subpass_flushes
;
410 anv_multialloc_add(&ma
, &pass
, 1);
411 anv_multialloc_add(&ma
, &subpasses
, pCreateInfo
->subpassCount
);
412 anv_multialloc_add(&ma
, &attachments
, pCreateInfo
->attachmentCount
);
413 anv_multialloc_add(&ma
, &subpass_flushes
, pCreateInfo
->subpassCount
+ 1);
415 struct anv_subpass_attachment
*subpass_attachments
;
416 uint32_t subpass_attachment_count
= 0;
417 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
418 subpass_attachment_count
+=
419 num_subpass_attachments2(&pCreateInfo
->pSubpasses
[i
]);
421 anv_multialloc_add(&ma
, &subpass_attachments
, subpass_attachment_count
);
423 if (!anv_multialloc_alloc2(&ma
, &device
->alloc
, pAllocator
,
424 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
))
425 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
427 /* Clear the subpasses along with the parent pass. This required because
428 * each array member of anv_subpass must be a valid pointer if not NULL.
430 memset(pass
, 0, ma
.size
);
431 pass
->attachment_count
= pCreateInfo
->attachmentCount
;
432 pass
->subpass_count
= pCreateInfo
->subpassCount
;
433 pass
->attachments
= attachments
;
434 pass
->subpass_flushes
= subpass_flushes
;
436 for (uint32_t i
= 0; i
< pCreateInfo
->attachmentCount
; i
++) {
437 const VkAttachmentDescriptionStencilLayoutKHR
*stencil_layout
=
438 vk_find_struct_const(pCreateInfo
->pAttachments
[i
].pNext
,
439 ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR
);
441 pass
->attachments
[i
] = (struct anv_render_pass_attachment
) {
442 .format
= pCreateInfo
->pAttachments
[i
].format
,
443 .samples
= pCreateInfo
->pAttachments
[i
].samples
,
444 .load_op
= pCreateInfo
->pAttachments
[i
].loadOp
,
445 .store_op
= pCreateInfo
->pAttachments
[i
].storeOp
,
446 .stencil_load_op
= pCreateInfo
->pAttachments
[i
].stencilLoadOp
,
447 .initial_layout
= pCreateInfo
->pAttachments
[i
].initialLayout
,
448 .final_layout
= pCreateInfo
->pAttachments
[i
].finalLayout
,
450 .stencil_initial_layout
= (stencil_layout
?
451 stencil_layout
->stencilInitialLayout
:
452 pCreateInfo
->pAttachments
[i
].initialLayout
),
453 .stencil_final_layout
= (stencil_layout
?
454 stencil_layout
->stencilFinalLayout
:
455 pCreateInfo
->pAttachments
[i
].finalLayout
),
459 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
460 const VkSubpassDescription2KHR
*desc
= &pCreateInfo
->pSubpasses
[i
];
461 struct anv_subpass
*subpass
= &pass
->subpasses
[i
];
463 subpass
->input_count
= desc
->inputAttachmentCount
;
464 subpass
->color_count
= desc
->colorAttachmentCount
;
465 subpass
->attachment_count
= num_subpass_attachments2(desc
);
466 subpass
->attachments
= subpass_attachments
;
467 subpass
->view_mask
= desc
->viewMask
;
469 if (desc
->inputAttachmentCount
> 0) {
470 subpass
->input_attachments
= subpass_attachments
;
471 subpass_attachments
+= desc
->inputAttachmentCount
;
473 for (uint32_t j
= 0; j
< desc
->inputAttachmentCount
; j
++) {
474 subpass
->input_attachments
[j
] = (struct anv_subpass_attachment
) {
475 .usage
= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
,
476 .attachment
= desc
->pInputAttachments
[j
].attachment
,
477 .layout
= desc
->pInputAttachments
[j
].layout
,
482 if (desc
->colorAttachmentCount
> 0) {
483 subpass
->color_attachments
= subpass_attachments
;
484 subpass_attachments
+= desc
->colorAttachmentCount
;
486 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
487 subpass
->color_attachments
[j
] = (struct anv_subpass_attachment
) {
488 .usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
489 .attachment
= desc
->pColorAttachments
[j
].attachment
,
490 .layout
= desc
->pColorAttachments
[j
].layout
,
495 if (desc
->pResolveAttachments
) {
496 subpass
->resolve_attachments
= subpass_attachments
;
497 subpass_attachments
+= desc
->colorAttachmentCount
;
499 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
500 subpass
->resolve_attachments
[j
] = (struct anv_subpass_attachment
) {
501 .usage
= VK_IMAGE_USAGE_TRANSFER_DST_BIT
,
502 .attachment
= desc
->pResolveAttachments
[j
].attachment
,
503 .layout
= desc
->pResolveAttachments
[j
].layout
,
508 if (desc
->pDepthStencilAttachment
) {
509 subpass
->depth_stencil_attachment
= subpass_attachments
++;
511 const VkAttachmentReferenceStencilLayoutKHR
*stencil_attachment
=
512 vk_find_struct_const(desc
->pDepthStencilAttachment
->pNext
,
513 ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR
);
515 *subpass
->depth_stencil_attachment
= (struct anv_subpass_attachment
) {
516 .usage
= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
,
517 .attachment
= desc
->pDepthStencilAttachment
->attachment
,
518 .layout
= desc
->pDepthStencilAttachment
->layout
,
519 .stencil_layout
= stencil_attachment
?
520 stencil_attachment
->stencilLayout
:
521 desc
->pDepthStencilAttachment
->layout
,
525 const VkSubpassDescriptionDepthStencilResolveKHR
*ds_resolve
=
526 vk_find_struct_const(desc
->pNext
,
527 SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR
);
529 if (ds_resolve
&& ds_resolve
->pDepthStencilResolveAttachment
) {
530 subpass
->ds_resolve_attachment
= subpass_attachments
++;
532 const VkAttachmentReferenceStencilLayoutKHR
*stencil_resolve_attachment
=
533 vk_find_struct_const(ds_resolve
->pDepthStencilResolveAttachment
->pNext
,
534 ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR
);
536 *subpass
->ds_resolve_attachment
= (struct anv_subpass_attachment
) {
537 .usage
= VK_IMAGE_USAGE_TRANSFER_DST_BIT
,
538 .attachment
= ds_resolve
->pDepthStencilResolveAttachment
->attachment
,
539 .layout
= ds_resolve
->pDepthStencilResolveAttachment
->layout
,
540 .stencil_layout
= stencil_resolve_attachment
?
541 stencil_resolve_attachment
->stencilLayout
:
542 ds_resolve
->pDepthStencilResolveAttachment
->layout
,
544 subpass
->depth_resolve_mode
= ds_resolve
->depthResolveMode
;
545 subpass
->stencil_resolve_mode
= ds_resolve
->stencilResolveMode
;
549 for (uint32_t i
= 0; i
< pCreateInfo
->dependencyCount
; i
++)
550 anv_render_pass_add_subpass_dep(pass
, &pCreateInfo
->pDependencies
[i
]);
552 vk_foreach_struct(ext
, pCreateInfo
->pNext
) {
553 switch (ext
->sType
) {
555 anv_debug_ignored_stype(ext
->sType
);
559 anv_render_pass_compile(pass
);
561 *pRenderPass
= anv_render_pass_to_handle(pass
);
566 void anv_DestroyRenderPass(
569 const VkAllocationCallbacks
* pAllocator
)
571 ANV_FROM_HANDLE(anv_device
, device
, _device
);
572 ANV_FROM_HANDLE(anv_render_pass
, pass
, _pass
);
574 vk_free2(&device
->alloc
, pAllocator
, pass
);
577 void anv_GetRenderAreaGranularity(
579 VkRenderPass renderPass
,
580 VkExtent2D
* pGranularity
)
582 ANV_FROM_HANDLE(anv_render_pass
, pass
, renderPass
);
584 /* This granularity satisfies HiZ fast clear alignment requirements
585 * for all sample counts.
587 for (unsigned i
= 0; i
< pass
->subpass_count
; ++i
) {
588 if (pass
->subpasses
[i
].depth_stencil_attachment
) {
589 *pGranularity
= (VkExtent2D
) { .width
= 8, .height
= 4 };
594 *pGranularity
= (VkExtent2D
) { 1, 1 };