OSDN Git Service

Merge remote-tracking branch 'mesa/18.3' into oreo-x86
[android-x86/external-mesa.git] / src / intel / vulkan / anv_pass.c
1 /*
2  * Copyright © 2015 Intel Corporation
3  *
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:
10  *
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
13  * Software.
14  *
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
21  * IN THE SOFTWARE.
22  */
23
24 #include "anv_private.h"
25
26 #include "vk_util.h"
27
28 static void
29 anv_render_pass_add_subpass_dep(struct anv_render_pass *pass,
30                                 const VkSubpassDependency2KHR *dep)
31 {
32    if (dep->dstSubpass == VK_SUBPASS_EXTERNAL) {
33       pass->subpass_flushes[pass->subpass_count] |=
34          anv_pipe_invalidate_bits_for_access_flags(dep->dstAccessMask);
35    } else {
36       assert(dep->dstSubpass < pass->subpass_count);
37       pass->subpass_flushes[dep->dstSubpass] |=
38          anv_pipe_invalidate_bits_for_access_flags(dep->dstAccessMask);
39    }
40
41    if (dep->srcSubpass == VK_SUBPASS_EXTERNAL) {
42       pass->subpass_flushes[0] |=
43          anv_pipe_flush_bits_for_access_flags(dep->srcAccessMask);
44    } else {
45       assert(dep->srcSubpass < pass->subpass_count);
46       pass->subpass_flushes[dep->srcSubpass + 1] |=
47          anv_pipe_flush_bits_for_access_flags(dep->srcAccessMask);
48    }
49 }
50
51 /* Do a second "compile" step on a render pass */
52 static void
53 anv_render_pass_compile(struct anv_render_pass *pass)
54 {
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
57     * do it again.
58     *
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;
62     * }
63     */
64
65    VkImageUsageFlags all_usage = 0;
66    for (uint32_t i = 0; i < pass->subpass_count; i++) {
67       struct anv_subpass *subpass = &pass->subpasses[i];
68
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.
72        */
73       if (subpass->depth_stencil_attachment &&
74           subpass->depth_stencil_attachment->attachment == VK_ATTACHMENT_UNUSED)
75          subpass->depth_stencil_attachment = NULL;
76
77       for (uint32_t j = 0; j < subpass->attachment_count; j++) {
78          struct anv_subpass_attachment *subpass_att = &subpass->attachments[j];
79          if (subpass_att->attachment == VK_ATTACHMENT_UNUSED)
80             continue;
81
82          struct anv_render_pass_attachment *pass_att =
83             &pass->attachments[subpass_att->attachment];
84
85          assert(__builtin_popcount(subpass_att->usage) == 1);
86          pass_att->usage |= subpass_att->usage;
87          pass_att->last_subpass_idx = i;
88
89          all_usage |= subpass_att->usage;
90
91          if (pass_att->first_subpass_layout == VK_IMAGE_LAYOUT_UNDEFINED) {
92             pass_att->first_subpass_layout = subpass_att->layout;
93             assert(pass_att->first_subpass_layout != VK_IMAGE_LAYOUT_UNDEFINED);
94          }
95
96          if (subpass_att->usage == VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
97              subpass->depth_stencil_attachment &&
98              subpass_att->attachment == subpass->depth_stencil_attachment->attachment)
99             subpass->has_ds_self_dep = true;
100       }
101
102       /* We have to handle resolve attachments specially */
103       subpass->has_resolve = false;
104       if (subpass->resolve_attachments) {
105          for (uint32_t j = 0; j < subpass->color_count; j++) {
106             struct anv_subpass_attachment *color_att =
107                &subpass->color_attachments[j];
108             struct anv_subpass_attachment *resolve_att =
109                &subpass->resolve_attachments[j];
110             if (resolve_att->attachment == VK_ATTACHMENT_UNUSED)
111                continue;
112
113             subpass->has_resolve = true;
114
115             assert(resolve_att->usage == VK_IMAGE_USAGE_TRANSFER_DST_BIT);
116             color_att->usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
117          }
118       }
119    }
120
121    /* From the Vulkan 1.0.39 spec:
122     *
123     *    If there is no subpass dependency from VK_SUBPASS_EXTERNAL to the
124     *    first subpass that uses an attachment, then an implicit subpass
125     *    dependency exists from VK_SUBPASS_EXTERNAL to the first subpass it is
126     *    used in. The subpass dependency operates as if defined with the
127     *    following parameters:
128     *
129     *    VkSubpassDependency implicitDependency = {
130     *        .srcSubpass = VK_SUBPASS_EXTERNAL;
131     *        .dstSubpass = firstSubpass; // First subpass attachment is used in
132     *        .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
133     *        .dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
134     *        .srcAccessMask = 0;
135     *        .dstAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
136     *                         VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
137     *                         VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
138     *                         VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
139     *                         VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
140     *        .dependencyFlags = 0;
141     *    };
142     *
143     *    Similarly, if there is no subpass dependency from the last subpass
144     *    that uses an attachment to VK_SUBPASS_EXTERNAL, then an implicit
145     *    subpass dependency exists from the last subpass it is used in to
146     *    VK_SUBPASS_EXTERNAL. The subpass dependency operates as if defined
147     *    with the following parameters:
148     *
149     *    VkSubpassDependency implicitDependency = {
150     *        .srcSubpass = lastSubpass; // Last subpass attachment is used in
151     *        .dstSubpass = VK_SUBPASS_EXTERNAL;
152     *        .srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
153     *        .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
154     *        .srcAccessMask = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT |
155     *                         VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
156     *                         VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
157     *                         VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
158     *                         VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
159     *        .dstAccessMask = 0;
160     *        .dependencyFlags = 0;
161     *    };
162     *
163     * We could implement this by walking over all of the attachments and
164     * subpasses and checking to see if any of them don't have an external
165     * dependency.  Or, we could just be lazy and add a couple extra flushes.
166     * We choose to be lazy.
167     *
168     * From the documentation for vkCmdNextSubpass:
169     *
170     *    "Moving to the next subpass automatically performs any multisample
171     *    resolve operations in the subpass being ended. End-of-subpass
172     *    multisample resolves are treated as color attachment writes for the
173     *    purposes of synchronization. This applies to resolve operations for
174     *    both color and depth/stencil attachments. That is, they are
175     *    considered to execute in the
176     *    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage and
177     *    their writes are synchronized with
178     *    VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT."
179     *
180     * Therefore, the above flags concerning color attachments also apply to
181     * color and depth/stencil resolve attachments.
182     */
183    if (all_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) {
184       pass->subpass_flushes[0] |=
185          ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
186    }
187    if (all_usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
188                     VK_IMAGE_USAGE_TRANSFER_DST_BIT)) {
189       pass->subpass_flushes[pass->subpass_count] |=
190          ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
191    }
192    if (all_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
193       pass->subpass_flushes[pass->subpass_count] |=
194          ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
195    }
196 }
197
198 static unsigned
199 num_subpass_attachments(const VkSubpassDescription *desc)
200 {
201    return desc->inputAttachmentCount +
202           desc->colorAttachmentCount +
203           (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
204           (desc->pDepthStencilAttachment != NULL);
205 }
206
207 VkResult anv_CreateRenderPass(
208     VkDevice                                    _device,
209     const VkRenderPassCreateInfo*               pCreateInfo,
210     const VkAllocationCallbacks*                pAllocator,
211     VkRenderPass*                               pRenderPass)
212 {
213    ANV_FROM_HANDLE(anv_device, device, _device);
214
215    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO);
216
217    struct anv_render_pass *pass;
218    struct anv_subpass *subpasses;
219    struct anv_render_pass_attachment *attachments;
220    enum anv_pipe_bits *subpass_flushes;
221
222    ANV_MULTIALLOC(ma);
223    anv_multialloc_add(&ma, &pass, 1);
224    anv_multialloc_add(&ma, &subpasses, pCreateInfo->subpassCount);
225    anv_multialloc_add(&ma, &attachments, pCreateInfo->attachmentCount);
226    anv_multialloc_add(&ma, &subpass_flushes, pCreateInfo->subpassCount + 1);
227
228    struct anv_subpass_attachment *subpass_attachments;
229    uint32_t subpass_attachment_count = 0;
230    for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
231       subpass_attachment_count +=
232          num_subpass_attachments(&pCreateInfo->pSubpasses[i]);
233    }
234    anv_multialloc_add(&ma, &subpass_attachments, subpass_attachment_count);
235
236    if (!anv_multialloc_alloc2(&ma, &device->alloc, pAllocator,
237                               VK_SYSTEM_ALLOCATION_SCOPE_OBJECT))
238       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
239
240    /* Clear the subpasses along with the parent pass. This required because
241     * each array member of anv_subpass must be a valid pointer if not NULL.
242     */
243    memset(pass, 0, ma.size);
244    pass->attachment_count = pCreateInfo->attachmentCount;
245    pass->subpass_count = pCreateInfo->subpassCount;
246    pass->attachments = attachments;
247    pass->subpass_flushes = subpass_flushes;
248
249    for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
250       pass->attachments[i] = (struct anv_render_pass_attachment) {
251          .format                 = pCreateInfo->pAttachments[i].format,
252          .samples                = pCreateInfo->pAttachments[i].samples,
253          .load_op                = pCreateInfo->pAttachments[i].loadOp,
254          .store_op               = pCreateInfo->pAttachments[i].storeOp,
255          .stencil_load_op        = pCreateInfo->pAttachments[i].stencilLoadOp,
256          .initial_layout         = pCreateInfo->pAttachments[i].initialLayout,
257          .final_layout           = pCreateInfo->pAttachments[i].finalLayout,
258       };
259    }
260
261    for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
262       const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
263       struct anv_subpass *subpass = &pass->subpasses[i];
264
265       subpass->input_count = desc->inputAttachmentCount;
266       subpass->color_count = desc->colorAttachmentCount;
267       subpass->attachment_count = num_subpass_attachments(desc);
268       subpass->attachments = subpass_attachments;
269       subpass->view_mask = 0;
270
271       if (desc->inputAttachmentCount > 0) {
272          subpass->input_attachments = subpass_attachments;
273          subpass_attachments += desc->inputAttachmentCount;
274
275          for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
276             subpass->input_attachments[j] = (struct anv_subpass_attachment) {
277                .usage =       VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
278                .attachment =  desc->pInputAttachments[j].attachment,
279                .layout =      desc->pInputAttachments[j].layout,
280             };
281          }
282       }
283
284       if (desc->colorAttachmentCount > 0) {
285          subpass->color_attachments = subpass_attachments;
286          subpass_attachments += desc->colorAttachmentCount;
287
288          for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
289             subpass->color_attachments[j] = (struct anv_subpass_attachment) {
290                .usage =       VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
291                .attachment =  desc->pColorAttachments[j].attachment,
292                .layout =      desc->pColorAttachments[j].layout,
293             };
294          }
295       }
296
297       if (desc->pResolveAttachments) {
298          subpass->resolve_attachments = subpass_attachments;
299          subpass_attachments += desc->colorAttachmentCount;
300
301          for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
302             subpass->resolve_attachments[j] = (struct anv_subpass_attachment) {
303                .usage =       VK_IMAGE_USAGE_TRANSFER_DST_BIT,
304                .attachment =  desc->pResolveAttachments[j].attachment,
305                .layout =      desc->pResolveAttachments[j].layout,
306             };
307          }
308       }
309
310       if (desc->pDepthStencilAttachment) {
311          subpass->depth_stencil_attachment = subpass_attachments++;
312
313          *subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
314             .usage =       VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
315             .attachment =  desc->pDepthStencilAttachment->attachment,
316             .layout =      desc->pDepthStencilAttachment->layout,
317          };
318       }
319    }
320
321    for (uint32_t i = 0; i < pCreateInfo->dependencyCount; i++) {
322       /* Convert to a Dependency2KHR */
323       struct VkSubpassDependency2KHR dep2 = {
324          .srcSubpass       = pCreateInfo->pDependencies[i].srcSubpass,
325          .dstSubpass       = pCreateInfo->pDependencies[i].dstSubpass,
326          .srcStageMask     = pCreateInfo->pDependencies[i].srcStageMask,
327          .dstStageMask     = pCreateInfo->pDependencies[i].dstStageMask,
328          .srcAccessMask    = pCreateInfo->pDependencies[i].srcAccessMask,
329          .dstAccessMask    = pCreateInfo->pDependencies[i].dstAccessMask,
330          .dependencyFlags  = pCreateInfo->pDependencies[i].dependencyFlags,
331       };
332       anv_render_pass_add_subpass_dep(pass, &dep2);
333    }
334
335    vk_foreach_struct(ext, pCreateInfo->pNext) {
336       switch (ext->sType) {
337       case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR: {
338          VkRenderPassMultiviewCreateInfoKHR *mv = (void *)ext;
339
340          for (uint32_t i = 0; i < mv->subpassCount; i++) {
341             pass->subpasses[i].view_mask = mv->pViewMasks[i];
342          }
343          break;
344       }
345
346       default:
347          anv_debug_ignored_stype(ext->sType);
348       }
349    }
350
351    anv_render_pass_compile(pass);
352
353    *pRenderPass = anv_render_pass_to_handle(pass);
354
355    return VK_SUCCESS;
356 }
357
358 static unsigned
359 num_subpass_attachments2(const VkSubpassDescription2KHR *desc)
360 {
361    return desc->inputAttachmentCount +
362           desc->colorAttachmentCount +
363           (desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
364           (desc->pDepthStencilAttachment != NULL);
365 }
366
367 VkResult anv_CreateRenderPass2KHR(
368     VkDevice                                    _device,
369     const VkRenderPassCreateInfo2KHR*           pCreateInfo,
370     const VkAllocationCallbacks*                pAllocator,
371     VkRenderPass*                               pRenderPass)
372 {
373    ANV_FROM_HANDLE(anv_device, device, _device);
374
375    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR);
376
377    struct anv_render_pass *pass;
378    struct anv_subpass *subpasses;
379    struct anv_render_pass_attachment *attachments;
380    enum anv_pipe_bits *subpass_flushes;
381
382    ANV_MULTIALLOC(ma);
383    anv_multialloc_add(&ma, &pass, 1);
384    anv_multialloc_add(&ma, &subpasses, pCreateInfo->subpassCount);
385    anv_multialloc_add(&ma, &attachments, pCreateInfo->attachmentCount);
386    anv_multialloc_add(&ma, &subpass_flushes, pCreateInfo->subpassCount + 1);
387
388    struct anv_subpass_attachment *subpass_attachments;
389    uint32_t subpass_attachment_count = 0;
390    for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
391       subpass_attachment_count +=
392          num_subpass_attachments2(&pCreateInfo->pSubpasses[i]);
393    }
394    anv_multialloc_add(&ma, &subpass_attachments, subpass_attachment_count);
395
396    if (!anv_multialloc_alloc2(&ma, &device->alloc, pAllocator,
397                               VK_SYSTEM_ALLOCATION_SCOPE_OBJECT))
398       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
399
400    /* Clear the subpasses along with the parent pass. This required because
401     * each array member of anv_subpass must be a valid pointer if not NULL.
402     */
403    memset(pass, 0, ma.size);
404    pass->attachment_count = pCreateInfo->attachmentCount;
405    pass->subpass_count = pCreateInfo->subpassCount;
406    pass->attachments = attachments;
407    pass->subpass_flushes = subpass_flushes;
408
409    for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
410       pass->attachments[i] = (struct anv_render_pass_attachment) {
411          .format                 = pCreateInfo->pAttachments[i].format,
412          .samples                = pCreateInfo->pAttachments[i].samples,
413          .load_op                = pCreateInfo->pAttachments[i].loadOp,
414          .store_op               = pCreateInfo->pAttachments[i].storeOp,
415          .stencil_load_op        = pCreateInfo->pAttachments[i].stencilLoadOp,
416          .initial_layout         = pCreateInfo->pAttachments[i].initialLayout,
417          .final_layout           = pCreateInfo->pAttachments[i].finalLayout,
418       };
419    }
420
421    for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
422       const VkSubpassDescription2KHR *desc = &pCreateInfo->pSubpasses[i];
423       struct anv_subpass *subpass = &pass->subpasses[i];
424
425       subpass->input_count = desc->inputAttachmentCount;
426       subpass->color_count = desc->colorAttachmentCount;
427       subpass->attachment_count = num_subpass_attachments2(desc);
428       subpass->attachments = subpass_attachments;
429       subpass->view_mask = desc->viewMask;
430
431       if (desc->inputAttachmentCount > 0) {
432          subpass->input_attachments = subpass_attachments;
433          subpass_attachments += desc->inputAttachmentCount;
434
435          for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
436             subpass->input_attachments[j] = (struct anv_subpass_attachment) {
437                .usage =       VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
438                .attachment =  desc->pInputAttachments[j].attachment,
439                .layout =      desc->pInputAttachments[j].layout,
440             };
441          }
442       }
443
444       if (desc->colorAttachmentCount > 0) {
445          subpass->color_attachments = subpass_attachments;
446          subpass_attachments += desc->colorAttachmentCount;
447
448          for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
449             subpass->color_attachments[j] = (struct anv_subpass_attachment) {
450                .usage =       VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
451                .attachment =  desc->pColorAttachments[j].attachment,
452                .layout =      desc->pColorAttachments[j].layout,
453             };
454          }
455       }
456
457       if (desc->pResolveAttachments) {
458          subpass->resolve_attachments = subpass_attachments;
459          subpass_attachments += desc->colorAttachmentCount;
460
461          for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
462             subpass->resolve_attachments[j] = (struct anv_subpass_attachment) {
463                .usage =       VK_IMAGE_USAGE_TRANSFER_DST_BIT,
464                .attachment =  desc->pResolveAttachments[j].attachment,
465                .layout =      desc->pResolveAttachments[j].layout,
466             };
467          }
468       }
469
470       if (desc->pDepthStencilAttachment) {
471          subpass->depth_stencil_attachment = subpass_attachments++;
472
473          *subpass->depth_stencil_attachment = (struct anv_subpass_attachment) {
474             .usage =       VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
475             .attachment =  desc->pDepthStencilAttachment->attachment,
476             .layout =      desc->pDepthStencilAttachment->layout,
477          };
478       }
479    }
480
481    for (uint32_t i = 0; i < pCreateInfo->dependencyCount; i++)
482       anv_render_pass_add_subpass_dep(pass, &pCreateInfo->pDependencies[i]);
483
484    vk_foreach_struct(ext, pCreateInfo->pNext) {
485       switch (ext->sType) {
486       default:
487          anv_debug_ignored_stype(ext->sType);
488       }
489    }
490
491    anv_render_pass_compile(pass);
492
493    *pRenderPass = anv_render_pass_to_handle(pass);
494
495    return VK_SUCCESS;
496 }
497
498 void anv_DestroyRenderPass(
499     VkDevice                                    _device,
500     VkRenderPass                                _pass,
501     const VkAllocationCallbacks*                pAllocator)
502 {
503    ANV_FROM_HANDLE(anv_device, device, _device);
504    ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
505
506    vk_free2(&device->alloc, pAllocator, pass);
507 }
508
509 void anv_GetRenderAreaGranularity(
510     VkDevice                                    device,
511     VkRenderPass                                renderPass,
512     VkExtent2D*                                 pGranularity)
513 {
514    ANV_FROM_HANDLE(anv_render_pass, pass, renderPass);
515
516    /* This granularity satisfies HiZ fast clear alignment requirements
517     * for all sample counts.
518     */
519    for (unsigned i = 0; i < pass->subpass_count; ++i) {
520       if (pass->subpasses[i].depth_stencil_attachment) {
521          *pGranularity = (VkExtent2D) { .width = 8, .height = 4 };
522          return;
523       }
524    }
525
526    *pGranularity = (VkExtent2D) { 1, 1 };
527 }