anv/blorp: Use the new clear_attachments entrypoint for attachment clears
[mesa.git] / src / intel / vulkan / anv_pass.c
index 69c3c7e96b745b2d15ee1a9c7f12a468189fcb7f..6eaa5c85cab0ea3c7b9405599d02d02da331a915 100644 (file)
@@ -41,7 +41,7 @@ VkResult anv_CreateRenderPass(
    attachments_offset = size;
    size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]);
 
-   pass = anv_alloc2(&device->alloc, pAllocator, size, 8,
+   pass = vk_alloc2(&device->alloc, pAllocator, size, 8,
                      VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (pass == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -76,11 +76,11 @@ VkResult anv_CreateRenderPass(
    }
 
    pass->subpass_attachments =
-      anv_alloc2(&device->alloc, pAllocator,
+      vk_alloc2(&device->alloc, pAllocator,
                  subpass_attachment_count * sizeof(uint32_t), 8,
                  VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (pass->subpass_attachments == NULL) {
-      anv_free2(&device->alloc, pAllocator, pass);
+      vk_free2(&device->alloc, pAllocator, pass);
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
    }
 
@@ -146,8 +146,8 @@ void anv_DestroyRenderPass(
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
 
-   anv_free2(&device->alloc, pAllocator, pass->subpass_attachments);
-   anv_free2(&device->alloc, pAllocator, pass);
+   vk_free2(&device->alloc, pAllocator, pass->subpass_attachments);
+   vk_free2(&device->alloc, pAllocator, pass);
 }
 
 void anv_GetRenderAreaGranularity(
@@ -155,5 +155,18 @@ void anv_GetRenderAreaGranularity(
     VkRenderPass                                renderPass,
     VkExtent2D*                                 pGranularity)
 {
+   ANV_FROM_HANDLE(anv_render_pass, pass, renderPass);
+
+   /* This granularity satisfies HiZ fast clear alignment requirements
+    * for all sample counts.
+    */
+   for (unsigned i = 0; i < pass->subpass_count; ++i) {
+      if (pass->subpasses[i].depth_stencil_attachment !=
+          VK_ATTACHMENT_UNUSED) {
+         *pGranularity = (VkExtent2D) { .width = 8, .height = 4 };
+         return;
+      }
+   }
+
    *pGranularity = (VkExtent2D) { 1, 1 };
 }