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
,
275 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
276 const VkSubpassDescription
*desc
= &pCreateInfo
->pSubpasses
[i
];
277 struct anv_subpass
*subpass
= &pass
->subpasses
[i
];
279 subpass
->input_count
= desc
->inputAttachmentCount
;
280 subpass
->color_count
= desc
->colorAttachmentCount
;
281 subpass
->attachment_count
= num_subpass_attachments(desc
);
282 subpass
->attachments
= subpass_attachments
;
283 subpass
->view_mask
= 0;
285 if (desc
->inputAttachmentCount
> 0) {
286 subpass
->input_attachments
= subpass_attachments
;
287 subpass_attachments
+= desc
->inputAttachmentCount
;
289 for (uint32_t j
= 0; j
< desc
->inputAttachmentCount
; j
++) {
290 subpass
->input_attachments
[j
] = (struct anv_subpass_attachment
) {
291 .usage
= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
,
292 .attachment
= desc
->pInputAttachments
[j
].attachment
,
293 .layout
= desc
->pInputAttachments
[j
].layout
,
298 if (desc
->colorAttachmentCount
> 0) {
299 subpass
->color_attachments
= subpass_attachments
;
300 subpass_attachments
+= desc
->colorAttachmentCount
;
302 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
303 subpass
->color_attachments
[j
] = (struct anv_subpass_attachment
) {
304 .usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
305 .attachment
= desc
->pColorAttachments
[j
].attachment
,
306 .layout
= desc
->pColorAttachments
[j
].layout
,
311 if (desc
->pResolveAttachments
) {
312 subpass
->resolve_attachments
= subpass_attachments
;
313 subpass_attachments
+= desc
->colorAttachmentCount
;
315 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
316 subpass
->resolve_attachments
[j
] = (struct anv_subpass_attachment
) {
317 .usage
= VK_IMAGE_USAGE_TRANSFER_DST_BIT
,
318 .attachment
= desc
->pResolveAttachments
[j
].attachment
,
319 .layout
= desc
->pResolveAttachments
[j
].layout
,
324 if (desc
->pDepthStencilAttachment
) {
325 subpass
->depth_stencil_attachment
= subpass_attachments
++;
327 *subpass
->depth_stencil_attachment
= (struct anv_subpass_attachment
) {
328 .usage
= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
,
329 .attachment
= desc
->pDepthStencilAttachment
->attachment
,
330 .layout
= desc
->pDepthStencilAttachment
->layout
,
335 for (uint32_t i
= 0; i
< pCreateInfo
->dependencyCount
; i
++) {
336 /* Convert to a Dependency2KHR */
337 struct VkSubpassDependency2KHR dep2
= {
338 .srcSubpass
= pCreateInfo
->pDependencies
[i
].srcSubpass
,
339 .dstSubpass
= pCreateInfo
->pDependencies
[i
].dstSubpass
,
340 .srcStageMask
= pCreateInfo
->pDependencies
[i
].srcStageMask
,
341 .dstStageMask
= pCreateInfo
->pDependencies
[i
].dstStageMask
,
342 .srcAccessMask
= pCreateInfo
->pDependencies
[i
].srcAccessMask
,
343 .dstAccessMask
= pCreateInfo
->pDependencies
[i
].dstAccessMask
,
344 .dependencyFlags
= pCreateInfo
->pDependencies
[i
].dependencyFlags
,
346 anv_render_pass_add_subpass_dep(pass
, &dep2
);
349 vk_foreach_struct(ext
, pCreateInfo
->pNext
) {
350 switch (ext
->sType
) {
351 case VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO
:
352 /* We don't care about this information */
355 case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO
: {
356 VkRenderPassMultiviewCreateInfo
*mv
= (void *)ext
;
358 for (uint32_t i
= 0; i
< mv
->subpassCount
; i
++) {
359 pass
->subpasses
[i
].view_mask
= mv
->pViewMasks
[i
];
365 anv_debug_ignored_stype(ext
->sType
);
369 anv_render_pass_compile(pass
);
371 *pRenderPass
= anv_render_pass_to_handle(pass
);
377 num_subpass_attachments2(const VkSubpassDescription2KHR
*desc
)
379 const VkSubpassDescriptionDepthStencilResolveKHR
*ds_resolve
=
380 vk_find_struct_const(desc
->pNext
,
381 SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR
);
383 return desc
->inputAttachmentCount
+
384 desc
->colorAttachmentCount
+
385 (desc
->pResolveAttachments
? desc
->colorAttachmentCount
: 0) +
386 (desc
->pDepthStencilAttachment
!= NULL
) +
387 (ds_resolve
&& ds_resolve
->pDepthStencilResolveAttachment
);
390 VkResult
anv_CreateRenderPass2KHR(
392 const VkRenderPassCreateInfo2KHR
* pCreateInfo
,
393 const VkAllocationCallbacks
* pAllocator
,
394 VkRenderPass
* pRenderPass
)
396 ANV_FROM_HANDLE(anv_device
, device
, _device
);
398 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR
);
400 struct anv_render_pass
*pass
;
401 struct anv_subpass
*subpasses
;
402 struct anv_render_pass_attachment
*attachments
;
403 enum anv_pipe_bits
*subpass_flushes
;
406 anv_multialloc_add(&ma
, &pass
, 1);
407 anv_multialloc_add(&ma
, &subpasses
, pCreateInfo
->subpassCount
);
408 anv_multialloc_add(&ma
, &attachments
, pCreateInfo
->attachmentCount
);
409 anv_multialloc_add(&ma
, &subpass_flushes
, pCreateInfo
->subpassCount
+ 1);
411 struct anv_subpass_attachment
*subpass_attachments
;
412 uint32_t subpass_attachment_count
= 0;
413 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
414 subpass_attachment_count
+=
415 num_subpass_attachments2(&pCreateInfo
->pSubpasses
[i
]);
417 anv_multialloc_add(&ma
, &subpass_attachments
, subpass_attachment_count
);
419 if (!anv_multialloc_alloc2(&ma
, &device
->alloc
, pAllocator
,
420 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
))
421 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
423 /* Clear the subpasses along with the parent pass. This required because
424 * each array member of anv_subpass must be a valid pointer if not NULL.
426 memset(pass
, 0, ma
.size
);
427 pass
->attachment_count
= pCreateInfo
->attachmentCount
;
428 pass
->subpass_count
= pCreateInfo
->subpassCount
;
429 pass
->attachments
= attachments
;
430 pass
->subpass_flushes
= subpass_flushes
;
432 for (uint32_t i
= 0; i
< pCreateInfo
->attachmentCount
; i
++) {
433 pass
->attachments
[i
] = (struct anv_render_pass_attachment
) {
434 .format
= pCreateInfo
->pAttachments
[i
].format
,
435 .samples
= pCreateInfo
->pAttachments
[i
].samples
,
436 .load_op
= pCreateInfo
->pAttachments
[i
].loadOp
,
437 .store_op
= pCreateInfo
->pAttachments
[i
].storeOp
,
438 .stencil_load_op
= pCreateInfo
->pAttachments
[i
].stencilLoadOp
,
439 .initial_layout
= pCreateInfo
->pAttachments
[i
].initialLayout
,
440 .final_layout
= pCreateInfo
->pAttachments
[i
].finalLayout
,
444 for (uint32_t i
= 0; i
< pCreateInfo
->subpassCount
; i
++) {
445 const VkSubpassDescription2KHR
*desc
= &pCreateInfo
->pSubpasses
[i
];
446 struct anv_subpass
*subpass
= &pass
->subpasses
[i
];
448 subpass
->input_count
= desc
->inputAttachmentCount
;
449 subpass
->color_count
= desc
->colorAttachmentCount
;
450 subpass
->attachment_count
= num_subpass_attachments2(desc
);
451 subpass
->attachments
= subpass_attachments
;
452 subpass
->view_mask
= desc
->viewMask
;
454 if (desc
->inputAttachmentCount
> 0) {
455 subpass
->input_attachments
= subpass_attachments
;
456 subpass_attachments
+= desc
->inputAttachmentCount
;
458 for (uint32_t j
= 0; j
< desc
->inputAttachmentCount
; j
++) {
459 subpass
->input_attachments
[j
] = (struct anv_subpass_attachment
) {
460 .usage
= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
,
461 .attachment
= desc
->pInputAttachments
[j
].attachment
,
462 .layout
= desc
->pInputAttachments
[j
].layout
,
467 if (desc
->colorAttachmentCount
> 0) {
468 subpass
->color_attachments
= subpass_attachments
;
469 subpass_attachments
+= desc
->colorAttachmentCount
;
471 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
472 subpass
->color_attachments
[j
] = (struct anv_subpass_attachment
) {
473 .usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
474 .attachment
= desc
->pColorAttachments
[j
].attachment
,
475 .layout
= desc
->pColorAttachments
[j
].layout
,
480 if (desc
->pResolveAttachments
) {
481 subpass
->resolve_attachments
= subpass_attachments
;
482 subpass_attachments
+= desc
->colorAttachmentCount
;
484 for (uint32_t j
= 0; j
< desc
->colorAttachmentCount
; j
++) {
485 subpass
->resolve_attachments
[j
] = (struct anv_subpass_attachment
) {
486 .usage
= VK_IMAGE_USAGE_TRANSFER_DST_BIT
,
487 .attachment
= desc
->pResolveAttachments
[j
].attachment
,
488 .layout
= desc
->pResolveAttachments
[j
].layout
,
493 if (desc
->pDepthStencilAttachment
) {
494 subpass
->depth_stencil_attachment
= subpass_attachments
++;
496 *subpass
->depth_stencil_attachment
= (struct anv_subpass_attachment
) {
497 .usage
= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
,
498 .attachment
= desc
->pDepthStencilAttachment
->attachment
,
499 .layout
= desc
->pDepthStencilAttachment
->layout
,
503 const VkSubpassDescriptionDepthStencilResolveKHR
*ds_resolve
=
504 vk_find_struct_const(desc
->pNext
,
505 SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR
);
507 if (ds_resolve
&& ds_resolve
->pDepthStencilResolveAttachment
) {
508 subpass
->ds_resolve_attachment
= subpass_attachments
++;
510 *subpass
->ds_resolve_attachment
= (struct anv_subpass_attachment
) {
511 .usage
= VK_IMAGE_USAGE_TRANSFER_DST_BIT
,
512 .attachment
= ds_resolve
->pDepthStencilResolveAttachment
->attachment
,
513 .layout
= ds_resolve
->pDepthStencilResolveAttachment
->layout
,
515 subpass
->depth_resolve_mode
= ds_resolve
->depthResolveMode
;
516 subpass
->stencil_resolve_mode
= ds_resolve
->stencilResolveMode
;
520 for (uint32_t i
= 0; i
< pCreateInfo
->dependencyCount
; i
++)
521 anv_render_pass_add_subpass_dep(pass
, &pCreateInfo
->pDependencies
[i
]);
523 vk_foreach_struct(ext
, pCreateInfo
->pNext
) {
524 switch (ext
->sType
) {
526 anv_debug_ignored_stype(ext
->sType
);
530 anv_render_pass_compile(pass
);
532 *pRenderPass
= anv_render_pass_to_handle(pass
);
537 void anv_DestroyRenderPass(
540 const VkAllocationCallbacks
* pAllocator
)
542 ANV_FROM_HANDLE(anv_device
, device
, _device
);
543 ANV_FROM_HANDLE(anv_render_pass
, pass
, _pass
);
545 vk_free2(&device
->alloc
, pAllocator
, pass
);
548 void anv_GetRenderAreaGranularity(
550 VkRenderPass renderPass
,
551 VkExtent2D
* pGranularity
)
553 ANV_FROM_HANDLE(anv_render_pass
, pass
, renderPass
);
555 /* This granularity satisfies HiZ fast clear alignment requirements
556 * for all sample counts.
558 for (unsigned i
= 0; i
< pass
->subpass_count
; ++i
) {
559 if (pass
->subpasses
[i
].depth_stencil_attachment
) {
560 *pGranularity
= (VkExtent2D
) { .width
= 8, .height
= 4 };
565 *pGranularity
= (VkExtent2D
) { 1, 1 };