<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 7, 2017 at 1:14 AM, Chris Wilson <span dir="ltr"><<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Apr 06, 2017 at 10:53:07PM -0700, Jason Ekstrand wrote:<br>
> ---<br>
>  src/intel/vulkan/anv_<wbr>descriptor_set.c | 22 +++++++++++-----------<br>
>  1 file changed, 11 insertions(+), 11 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_<wbr>descriptor_set.c b/src/intel/vulkan/anv_<wbr>descriptor_set.c<br>
> index 56a08ce..6f2280d 100644<br>
> --- a/src/intel/vulkan/anv_<wbr>descriptor_set.c<br>
> +++ b/src/intel/vulkan/anv_<wbr>descriptor_set.c<br>
> @@ -42,7 +42,6 @@ VkResult anv_CreateDescriptorSetLayout(<br>
>      VkDescriptorSetLayout*                      pSetLayout)<br>
>  {<br>
>     ANV_FROM_HANDLE(anv_device, device, _device);<br>
> -   struct anv_descriptor_set_layout *set_layout;<br>
><br>
>     assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_<wbr>SET_LAYOUT_CREATE_INFO);<br>
><br>
> @@ -54,18 +53,19 @@ VkResult anv_CreateDescriptorSetLayout(<br>
>           immutable_sampler_count += pCreateInfo->pBindings[j].<wbr>descriptorCount;<br>
>     }<br>
><br>
> -   size_t size = sizeof(struct anv_descriptor_set_layout) +<br>
> -                 (max_binding + 1) * sizeof(set_layout->binding[0]) +<br>
> -                 immutable_sampler_count * sizeof(struct anv_sampler *);<br>
> +   struct anv_descriptor_set_layout *set_layout;<br>
> +   struct anv_descriptor_set_binding_<wbr>layout *bindings;<br>
> +   struct anv_sampler **samplers;<br>
><br>
> -   set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,<br>
> -                           VK_SYSTEM_ALLOCATION_SCOPE_<wbr>OBJECT);<br>
> -   if (!set_layout)<br>
> -      return vk_error(VK_ERROR_OUT_OF_HOST_<wbr>MEMORY);<br>
> +   struct anv_multialloc ma;<br>
> +   anv_multialloc_init2(&ma, &device->alloc, pAllocator,<br>
> +                        VK_SYSTEM_ALLOCATION_SCOPE_<wbr>OBJECT);<br>
> +   anv_multialloc_add(&ma, &set_layout, 1);<br>
> +   anv_multialloc_add(&ma, &bindings, max_binding + 1);<br>
> +   anv_multialloc_add(&ma, &samplers, immutable_sampler_count);<br>
><br>
> -   /* We just allocate all the samplers at the end of the struct */<br>
> -   struct anv_sampler **samplers =<br>
> -      (struct anv_sampler **)&set_layout->binding[max_<wbr>binding + 1];<br>
> +   if (!anv_multialloc_finish(&ma))<br>
> +      return vk_error(VK_ERROR_OUT_OF_HOST_<wbr>MEMORY);<br>
<br>
</div></div>As the outside observer, I suggest that using finish here is confusing.<br>
Something like.<br></blockquote><div><br></div><div>Yeah, I didn't really like finsh either.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   ANV_MULTIALLOC(ma);<br>
<br>
   anv_multialloc_add(&ma, &set_layout, 1);<br>
<span class="">   anv_multialloc_add(&ma, &bindings, max_binding + 1);<br>
</span>   anv_multialloc_add(&ma, &samplers, immutable_sampler_count);<br>
<br>
   if (!anv_multialloc_alloc(&ma,<br>
                             &device->alloc ?: pAllocator,<br>
                             VK_SYSTEM_ALLOCATION_SCOPE_<wbr>OBJECT))<br>
      return vk_error(VK_ERROR_OUT_OF_HOST_<wbr>MEMORY);<br>
<br>
fits your current vk_alloc pattern better?<br></blockquote><div><br></div><div>Perhaps.  I'm not sure whether I like putting the alloc and scope parameters early or late better.  I think I do like the ANV_MULTIALLOC(ma) declare+init helper.  Nanley? <br></div></div></div></div>