[Mesa-dev] [PATCH] anv: Round u_vector element sizes to a power of two
Jason Ekstrand
jason at jlekstrand.net
Wed Jul 12 03:43:31 UTC 2017
On Tue, Jul 11, 2017 at 8:18 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:
> On Tuesday, July 11, 2017 7:09:32 PM PDT Jason Ekstrand wrote:
> > This fixes 32-bit builds of the driver.
> >
> > 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));
> > +}
>
> Would be nice to have this in a src/util header, instead of
> src/gallium/auxiliary/util/u_math.h's util_next_power_of_two
> and src/mesa/main/imports.h's _mesa_next_pow_two_32, and again in anv.
>
We already pull in u_math.h (Thanks, Eric.) but I didn't find
next_power_of_two when I went looking for it. I'll use
util_next_power_of_two instead.
> But moving all that around is annoying, and you know CLZ works here,
> and it's not that much code, so *shrug*
>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
>
Thanks!
> > +
> > 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;
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170711/b1d69ae1/attachment.html>
More information about the mesa-dev
mailing list