From: Chad Versace Date: Wed, 19 Aug 2015 22:10:14 +0000 (-0700) Subject: vk: Improve memory locality of anv_render_pass X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c24a191cd41133e72a8e8db605faf508a632079;p=mesa.git vk: Improve memory locality of anv_render_pass Allocate the pass's array of attachments, anv_render_pass::attachments, in the same allocation as the pass itself. --- diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 89f6ec697d8..177986183e1 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -2207,11 +2207,15 @@ VkResult anv_CreateRenderPass( ANV_FROM_HANDLE(anv_device, device, _device); struct anv_render_pass *pass; size_t size; + size_t attachments_offset; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO); - size = sizeof(*pass) + - pCreateInfo->subpassCount * sizeof(pass->subpasses[0]); + size = sizeof(*pass); + size += pCreateInfo->subpassCount * sizeof(pass->subpasses[0]); + attachments_offset = size; + size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]); + pass = anv_device_alloc(device, size, 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT); if (pass == NULL) @@ -2221,13 +2225,10 @@ VkResult anv_CreateRenderPass( * each array member of anv_subpass must be a valid pointer if not NULL. */ memset(pass, 0, size); - pass->attachment_count = pCreateInfo->attachmentCount; pass->subpass_count = pCreateInfo->subpassCount; + pass->attachments = (void *) pass + attachments_offset; - size = pCreateInfo->attachmentCount * sizeof(*pass->attachments); - pass->attachments = anv_device_alloc(device, size, 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) { pass->attachments[i].format = anv_format_for_vk_format(pCreateInfo->pAttachments[i].format); @@ -2293,8 +2294,6 @@ VkResult anv_DestroyRenderPass( ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_render_pass, pass, _pass); - anv_device_free(device, pass->attachments); - for (uint32_t i = 0; i < pass->subpass_count; i++) { /* In VkSubpassCreateInfo, each of the attachment arrays may be null. * Don't free the null arrays.