[Mesa-stable] [PATCH] anv: Round u_vector element sizes to a power of two

Jason Ekstrand jason at jlekstrand.net
Wed Jul 12 02:27:58 UTC 2017


On Tue, Jul 11, 2017 at 7:09 PM, Jason Ekstrand <jason at jlekstrand.net>
wrote:

> This fixes 32-bit builds of the driver.
>

I just updated the commit message to be more descriptive:

    This fixes 32-bit builds of the driver.  Commit 08413a81b93dc537fb0c3
    changed things so that we now put struct anv_states in the u_vector for
    binding tables.  On 64-bit builds, sizeof(struct anv_state) is a power
    of two but it isn't on 32-bit builds.



> Fixes: 08413a81b93dc537fb0c34327ad162f07e8c3427
> Cc: Mark Janes <mark.a.janes at intel.com>
> Cc: mesa-stable at lists.freedesktop.org
> ---
>  src/intel/vulkan/anv_batch_chain.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_batch_chain.c
> b/src/intel/vulkan/anv_batch_chain.c
> index 47fee739..c895848 100644
> --- a/src/intel/vulkan/anv_batch_chain.c
> +++ b/src/intel/vulkan/anv_batch_chain.c
> @@ -672,6 +672,15 @@ anv_cmd_buffer_new_binding_table_block(struct
> anv_cmd_buffer *cmd_buffer)
>     return VK_SUCCESS;
>  }
>
> +static inline uint32_t
> +round_up_to_power_of_two(uint32_t value)
> +{
> +   if (value <= 1)
> +      return value;
> +
> +   return 1 << (32 - __builtin_clz(value - 1));
> +}
> +
>  VkResult
>  anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
>  {
> @@ -706,9 +715,11 @@ anv_cmd_buffer_init_batch_bo_chain(struct
> anv_cmd_buffer *cmd_buffer)
>
>     *(struct anv_batch_bo **)u_vector_add(&cmd_buffer->seen_bbos) =
> batch_bo;
>
> +   /* u_vector requires power-of-two size elements */
> +   uint32_t pow2_state_size =
> +      round_up_to_power_of_two(sizeof(struct anv_state));
>     success = u_vector_init(&cmd_buffer->bt_block_states,
> -                           sizeof(struct anv_state),
> -                           8 * sizeof(struct anv_state));
> +                           pow2_state_size, 8 * pow2_state_size);
>     if (!success)
>        goto fail_seen_bbos;
>
> --
> 2.5.0.400.gff86faf
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20170711/8cca6739/attachment.html>


More information about the mesa-stable mailing list