Mesa (master): anv: Refactor framebuffer creation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 10 02:28:08 UTC 2021


Module: Mesa
Branch: master
Commit: 13036a62e4baf044fac8a7ee47e613f15441d674
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=13036a62e4baf044fac8a7ee47e613f15441d674

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Apr  8 16:17:22 2021 -0500

anv: Refactor framebuffer creation

This avoids having the create call duplicated.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10123>

---

 src/intel/vulkan/anv_device.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 07dbdf80fb5..78d3288127d 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -4505,26 +4505,13 @@ VkResult anv_CreateFramebuffer(
     *    If flags includes VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR,
     *    parameter pAttachments is ignored.
     */
-   if (!(pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR)) {
+   if (!(pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR))
       size += sizeof(struct anv_image_view *) * pCreateInfo->attachmentCount;
-      framebuffer = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
-                              VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
-      if (framebuffer == NULL)
-         return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-      for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
-         ANV_FROM_HANDLE(anv_image_view, iview, pCreateInfo->pAttachments[i]);
-         framebuffer->attachments[i] = iview;
-      }
-      framebuffer->attachment_count = pCreateInfo->attachmentCount;
-   } else {
-      framebuffer = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
-                              VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
-      if (framebuffer == NULL)
-         return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
-      framebuffer->attachment_count = 0;
-   }
+   framebuffer = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
+                           VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+   if (framebuffer == NULL)
+      return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
    vk_object_base_init(&device->vk, &framebuffer->base,
                        VK_OBJECT_TYPE_FRAMEBUFFER);
@@ -4533,6 +4520,14 @@ VkResult anv_CreateFramebuffer(
    framebuffer->height = pCreateInfo->height;
    framebuffer->layers = pCreateInfo->layers;
 
+   if (!(pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR)) {
+      for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
+         ANV_FROM_HANDLE(anv_image_view, iview, pCreateInfo->pAttachments[i]);
+         framebuffer->attachments[i] = iview;
+      }
+      framebuffer->attachment_count = pCreateInfo->attachmentCount;
+   }
+
    *pFramebuffer = anv_framebuffer_to_handle(framebuffer);
 
    return VK_SUCCESS;



More information about the mesa-commit mailing list